fix comments,
fix handleResponse Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
b16ef89577
commit
c45f582fc1
20
main.js
20
main.js
@ -157,7 +157,7 @@ app.get("/api/user/nodes", async (req, res) => {
|
|||||||
* - vmid: Number - vm id number
|
* - vmid: Number - vm id number
|
||||||
* - disk: String - disk id (sata0, NOT unused)
|
* - disk: String - disk id (sata0, NOT unused)
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -187,7 +187,7 @@ app.post("/api/instance/disk/detach", async (req, res) => {
|
|||||||
* - disk: String - disk id (sata0)
|
* - disk: String - disk id (sata0)
|
||||||
* - source: Number - source unused disk number (0 => unused0)
|
* - source: Number - source unused disk number (0 => unused0)
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -224,7 +224,7 @@ app.post("/api/instance/disk/attach", async (req, res) => {
|
|||||||
* - disk: String - disk id (sata0)
|
* - disk: String - disk id (sata0)
|
||||||
* - size: Number - increase size in GiB
|
* - size: Number - increase size in GiB
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
@ -268,7 +268,7 @@ app.post("/api/instance/disk/resize", async (req, res) => {
|
|||||||
* - storage: String - target storage to move disk
|
* - storage: String - target storage to move disk
|
||||||
* - delete: Number - delete original disk (0, 1)
|
* - delete: Number - delete original disk (0, 1)
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
@ -325,7 +325,7 @@ app.post("/api/instance/disk/move", async (req, res) => {
|
|||||||
* - vmid: Number - vm id number
|
* - vmid: Number - vm id number
|
||||||
* - disk: String - disk id (sata0)
|
* - disk: String - disk id (sata0)
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -359,7 +359,7 @@ app.post("/api/instance/disk/delete", async (req, res) => {
|
|||||||
* - storage: String - storage to hold disk
|
* - storage: String - storage to hold disk
|
||||||
* - size: Number size of disk in GiB
|
* - size: Number size of disk in GiB
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -407,7 +407,7 @@ app.post("/api/instance/disk/create", async (req, res) => {
|
|||||||
* - netid: Number - network interface id number (0 => net0)
|
* - netid: Number - network interface id number (0 => net0)
|
||||||
* - rate: Number - new bandwidth rate for interface in MB/s
|
* - rate: Number - new bandwidth rate for interface in MB/s
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -450,7 +450,7 @@ app.post("/api/instance/network", async (req, res) => {
|
|||||||
* - memory: Number - new amount of memory for instance
|
* - memory: Number - new amount of memory for instance
|
||||||
* - swap: Number, optional - new amount of swap for instance
|
* - swap: Number, optional - new amount of swap for instance
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
@ -503,7 +503,7 @@ app.post("/api/instance/resources", async (req, res) => {
|
|||||||
* - rootfslocation: String, optional - storage name for lxc instance rootfs
|
* - rootfslocation: String, optional - storage name for lxc instance rootfs
|
||||||
* - rootfssize: Number, optional, - size of lxc instance rootfs
|
* - rootfssize: Number, optional, - size of lxc instance rootfs
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: {error: String}
|
* - 500: {error: String}
|
||||||
* - 500: {request: Object, error: String}
|
* - 500: {request: Object, error: String}
|
||||||
@ -576,7 +576,7 @@ app.post("/api/instance", async (req, res) => {
|
|||||||
* - type: String - vm type (lxc, qemu)
|
* - type: String - vm type (lxc, qemu)
|
||||||
* - vmid: Number - vm id number to destroy
|
* - vmid: Number - vm id number to destroy
|
||||||
* responses:
|
* responses:
|
||||||
* - 200: Object(pve_auth_object)
|
* - 200: Object(pve_task_object)
|
||||||
* - 401: {auth: false, path: String}
|
* - 401: {auth: false, path: String}
|
||||||
* - 500: Object(pve_task_object)
|
* - 500: Object(pve_task_object)
|
||||||
*/
|
*/
|
||||||
|
3
pve.js
3
pve.js
@ -56,9 +56,9 @@ export async function handleResponse(node, result, res) {
|
|||||||
let upid = result.data.data;
|
let upid = result.data.data;
|
||||||
while (true) {
|
while (true) {
|
||||||
let taskStatus = await requestPVE(`/nodes/${node}/tasks/${upid}/status`, "GET", null, null, pveAPIToken);
|
let taskStatus = await requestPVE(`/nodes/${node}/tasks/${upid}/status`, "GET", null, null, pveAPIToken);
|
||||||
let taskLog = await requestPVE(`/nodes/${node}/tasks/${upid}/log`, "GET", null, null, pveAPIToken);
|
|
||||||
if (taskStatus.data.data.status === "stopped" && taskStatus.data.data.exitstatus === "OK") {
|
if (taskStatus.data.data.status === "stopped" && taskStatus.data.data.exitstatus === "OK") {
|
||||||
let result = taskStatus.data.data;
|
let result = taskStatus.data.data;
|
||||||
|
let taskLog = await requestPVE(`/nodes/${node}/tasks/${upid}/log`, "GET", null, null, pveAPIToken);
|
||||||
result.log = taskLog.data.data;
|
result.log = taskLog.data.data;
|
||||||
res.status(200).send(result);
|
res.status(200).send(result);
|
||||||
res.end();
|
res.end();
|
||||||
@ -66,6 +66,7 @@ export async function handleResponse(node, result, res) {
|
|||||||
}
|
}
|
||||||
else if (taskStatus.data.data.status === "stopped") {
|
else if (taskStatus.data.data.status === "stopped") {
|
||||||
let result = taskStatus.data.data;
|
let result = taskStatus.data.data;
|
||||||
|
let taskLog = await requestPVE(`/nodes/${node}/tasks/${upid}/log`, "GET", null, null, pveAPIToken);
|
||||||
result.log = taskLog.data.data;
|
result.log = taskLog.data.data;
|
||||||
res.status(500).send(result);
|
res.status(500).send(result);
|
||||||
res.end();
|
res.end();
|
||||||
|
Loading…
Reference in New Issue
Block a user