use new endpoint params
This commit is contained in:
parent
7e7155926b
commit
24c1ac00a5
@ -233,13 +233,7 @@ async function handleDiskDetach () {
|
|||||||
dialog(header, body, async (result, form) => {
|
dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${this.dataset.disk}/detach`, "POST");
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: this.dataset.disk
|
|
||||||
};
|
|
||||||
const result = await requestAPI("/instance/disk/detach", "POST", body);
|
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -262,13 +256,10 @@ async function handleDiskAttach () {
|
|||||||
const device = form.get("device");
|
const device = form.get("device");
|
||||||
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: `${type === "qemu" ? "sata" : "mp"}${device}`,
|
|
||||||
source: this.dataset.disk.replace("unused", "")
|
source: this.dataset.disk.replace("unused", "")
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/disk/attach", "POST", body);
|
const disk = `${type === "qemu" ? "sata" : "mp"}${device}`;
|
||||||
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${disk}/attach`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -290,13 +281,9 @@ async function handleDiskResize () {
|
|||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: this.dataset.disk,
|
|
||||||
size: form.get("size-increment")
|
size: form.get("size-increment")
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/disk/resize", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${this.dataset.disk}/resize`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -333,14 +320,10 @@ async function handleDiskMove () {
|
|||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: this.dataset.disk,
|
|
||||||
storage: form.get("storage-select"),
|
storage: form.get("storage-select"),
|
||||||
delete: form.get("delete-check") === "on" ? "1" : "0"
|
delete: form.get("delete-check") === "on" ? "1" : "0"
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/disk/move", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${this.dataset.disk}/move`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -361,13 +344,7 @@ async function handleDiskDelete () {
|
|||||||
dialog(header, body, async (result, form) => {
|
dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-disk="${this.dataset.disk}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${this.dataset.disk}/delete`, "DELETE");
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: this.dataset.disk
|
|
||||||
};
|
|
||||||
const result = await requestAPI("/instance/disk/delete", "DELETE", body);
|
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -404,14 +381,11 @@ async function handleDiskAdd () {
|
|||||||
dialog(header, body, async (result, form) => {
|
dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: `${type === "qemu" ? "sata" : "mp"}${form.get("device")}`,
|
|
||||||
storage: form.get("storage-select"),
|
storage: form.get("storage-select"),
|
||||||
size: form.get("size")
|
size: form.get("size")
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/disk/create", "POST", body);
|
const disk = `${type === "qemu" ? "sata" : "mp"}${form.get("device")}`;
|
||||||
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${disk}/create`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -448,13 +422,10 @@ async function handleCDAdd () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
disk: `ide${form.get("device")}`,
|
|
||||||
iso: form.get("iso-select")
|
iso: form.get("iso-select")
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/disk/create", "POST", body);
|
const disk = `ide${form.get("device")}`;
|
||||||
|
const result = await requestAPI(`/${node}/${type}/${vmid}/disk/${disk}/create`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
@ -554,13 +525,9 @@ async function handleNetworkConfig () {
|
|||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-network="${netID}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-network="${netID}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
netid: netID,
|
|
||||||
rate: form.get("rate")
|
rate: form.get("rate")
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/network/modify", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/net/net${netID}/modify`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateNetworks();
|
populateNetworks();
|
||||||
@ -584,13 +551,7 @@ async function handleNetworkDelete () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-network="${netID}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-network="${netID}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const result = await requestAPI(`/${node}/${type}/${vmid}/net/net${netID}/delete`, "DELETE");
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
netid: netID
|
|
||||||
};
|
|
||||||
const result = await requestAPI("/instance/network/delete", "DELETE", body);
|
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateNetworks();
|
populateNetworks();
|
||||||
@ -614,16 +575,13 @@ async function handleNetworkAdd () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
netid: form.get("netid"),
|
|
||||||
rate: form.get("rate")
|
rate: form.get("rate")
|
||||||
};
|
};
|
||||||
if (type === "lxc") {
|
if (type === "lxc") {
|
||||||
body.name = form.get("name");
|
body.name = form.get("name");
|
||||||
}
|
}
|
||||||
const result = await requestAPI("/instance/network/create", "POST", body);
|
const netID = form.get("netid");
|
||||||
|
const result = await requestAPI(`/${node}/${type}/${vmid}/net/net${netID}/create`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateNetworks();
|
populateNetworks();
|
||||||
@ -650,7 +608,7 @@ async function populateDevices () {
|
|||||||
});
|
});
|
||||||
const orderedKeys = getOrdered(devices);
|
const orderedKeys = getOrdered(devices);
|
||||||
orderedKeys.forEach(async (element) => {
|
orderedKeys.forEach(async (element) => {
|
||||||
const deviceData = await requestAPI(`/instance/pci?node=${node}&type=${type}&vmid=${vmid}&hostpci=${element}`, "GET");
|
const deviceData = await requestAPI(`/${node}/${type}/${vmid}/pci/hostpci${element}`, "GET");
|
||||||
addDeviceLine("devices", prefix, element, devices[element], deviceData.device_name);
|
addDeviceLine("devices", prefix, element, devices[element], deviceData.device_name);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -715,14 +673,10 @@ async function handleDeviceConfig () {
|
|||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-device="${deviceID}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-device="${deviceID}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
hostpci: deviceID,
|
|
||||||
device: form.get("device"),
|
device: form.get("device"),
|
||||||
pcie: form.get("pcie") ? 1 : 0
|
pcie: form.get("pcie") ? 1 : 0
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/pci/modify", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/pci/hostpci${deviceID}/modify`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDevices();
|
populateDevices();
|
||||||
@ -735,7 +689,7 @@ async function handleDeviceConfig () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const availDevices = await requestAPI(`/nodes/pci?node=${node}`, "GET");
|
const availDevices = await requestAPI(`/${node}/pci`, "GET");
|
||||||
d.querySelector("#device").append(new Option(deviceName, deviceDetails.split(",")[0]));
|
d.querySelector("#device").append(new Option(deviceName, deviceDetails.split(",")[0]));
|
||||||
for (const availDevice of availDevices) {
|
for (const availDevice of availDevices) {
|
||||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
||||||
@ -751,13 +705,7 @@ async function handleDeviceDelete () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
document.querySelector(`img[data-device="${deviceID}"]`).src = "images/status/loading.svg";
|
document.querySelector(`img[data-device="${deviceID}"]`).src = "images/status/loading.svg";
|
||||||
const body = {
|
const result = await requestAPI(`/${node}/${type}/${vmid}/pci/hostpci${deviceID}/delete`, "DELETE");
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
hostpci: deviceID
|
|
||||||
};
|
|
||||||
const result = await requestAPI("/instance/pci/delete", "DELETE", body);
|
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDevices();
|
populateDevices();
|
||||||
@ -778,13 +726,10 @@ async function handleDeviceAdd () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
device: form.get("device"),
|
device: form.get("device"),
|
||||||
pcie: form.get("pcie") ? 1 : 0
|
pcie: form.get("pcie") ? 1 : 0
|
||||||
};
|
};
|
||||||
const result = await requestAPI("/instance/pci/create", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/pci/create`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDevices();
|
populateDevices();
|
||||||
@ -797,7 +742,7 @@ async function handleDeviceAdd () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const availDevices = await requestAPI(`/nodes/pci?node=${node}`, "GET");
|
const availDevices = await requestAPI(`/${node}/pci`, "GET");
|
||||||
for (const availDevice of availDevices) {
|
for (const availDevice of availDevices) {
|
||||||
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
d.querySelector("#device").append(new Option(availDevice.device_name, availDevice.id));
|
||||||
}
|
}
|
||||||
@ -806,9 +751,6 @@ async function handleDeviceAdd () {
|
|||||||
|
|
||||||
async function handleFormExit () {
|
async function handleFormExit () {
|
||||||
const body = {
|
const body = {
|
||||||
node,
|
|
||||||
type,
|
|
||||||
vmid,
|
|
||||||
cores: document.querySelector("#cores").value,
|
cores: document.querySelector("#cores").value,
|
||||||
memory: document.querySelector("#ram").value
|
memory: document.querySelector("#ram").value
|
||||||
};
|
};
|
||||||
@ -818,7 +760,7 @@ async function handleFormExit () {
|
|||||||
else if (type === "qemu") {
|
else if (type === "qemu") {
|
||||||
body.proctype = document.querySelector("#proctype").value;
|
body.proctype = document.querySelector("#proctype").value;
|
||||||
}
|
}
|
||||||
const result = await requestAPI("/instance/resources", "POST", body);
|
const result = await requestAPI(`/${node}/${type}/${vmid}/resources`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
await getConfig();
|
await getConfig();
|
||||||
populateDisk();
|
populateDisk();
|
||||||
|
@ -102,10 +102,7 @@ async function handleInstanceAdd () {
|
|||||||
const d = dialog(header, body, async (result, form) => {
|
const d = dialog(header, body, async (result, form) => {
|
||||||
if (result === "confirm") {
|
if (result === "confirm") {
|
||||||
const body = {
|
const body = {
|
||||||
node: form.get("node"),
|
|
||||||
type: form.get("type"),
|
|
||||||
name: form.get("name"),
|
name: form.get("name"),
|
||||||
vmid: form.get("vmid"),
|
|
||||||
cores: form.get("cores"),
|
cores: form.get("cores"),
|
||||||
memory: form.get("memory")
|
memory: form.get("memory")
|
||||||
};
|
};
|
||||||
@ -116,7 +113,10 @@ async function handleInstanceAdd () {
|
|||||||
body.rootfslocation = form.get("rootfs-storage");
|
body.rootfslocation = form.get("rootfs-storage");
|
||||||
body.rootfssize = form.get("rootfs-size");
|
body.rootfssize = form.get("rootfs-size");
|
||||||
}
|
}
|
||||||
const result = await requestAPI("/instance", "POST", body);
|
const node = form.get("node");
|
||||||
|
const type = form.get("type");
|
||||||
|
const vmid = form.get("vmid");
|
||||||
|
const result = await requestAPI(`/${node}/${type}/${vmid}/create`, "POST", body);
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
populateInstances();
|
populateInstances();
|
||||||
}
|
}
|
||||||
@ -190,11 +190,11 @@ async function handleInstanceAdd () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const userResources = await requestAPI("/user/resources", "GET");
|
const userResources = await requestAPI("/user/resources", "GET");
|
||||||
const userInstances = await requestAPI("/user/config/instances", "GET");
|
const userCluster = await requestAPI("/user/config/cluster", "GET");
|
||||||
d.querySelector("#cores").max = userResources.avail.cores;
|
d.querySelector("#cores").max = userResources.avail.cores;
|
||||||
d.querySelector("#memory").max = userResources.avail.memory;
|
d.querySelector("#memory").max = userResources.avail.memory;
|
||||||
d.querySelector("#vmid").min = userInstances.vmid.min;
|
d.querySelector("#vmid").min = userCluster.vmid.min;
|
||||||
d.querySelector("#vmid").max = userInstances.vmid.max;
|
d.querySelector("#vmid").max = userCluster.vmid.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Instance {
|
class Instance {
|
||||||
@ -400,14 +400,7 @@ class Instance {
|
|||||||
action.purge = 1;
|
action.purge = 1;
|
||||||
action["destroy-unreferenced-disks"] = 1;
|
action["destroy-unreferenced-disks"] = 1;
|
||||||
|
|
||||||
const body = {
|
const result = await requestAPI(`/${this.node.name}/${this.type}/${this.vmid}/delete`, "DELETE");
|
||||||
node: this.node.name,
|
|
||||||
type: this.type,
|
|
||||||
vmid: this.vmid,
|
|
||||||
action: JSON.stringify(action)
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = await requestAPI("/instance", "DELETE", body);
|
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
this.shadowElement.parentElement.removeChild(this.shadowElement);
|
this.shadowElement.parentElement.removeChild(this.shadowElement);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user