@@ -330,33 +330,33 @@ get_node_host() {
330330}
331331
332332get_console () {
333- check_required_fields node vmid
333+ check_required_fields node vmid
334334
335- local api_resp port ticket
336- if ! api_resp=" $( call_proxmox_api POST " /nodes/${node} /qemu/${vmid} /vncproxy" ) " ; then
335+ local api_resp port ticket
336+ if ! api_resp=" $( call_proxmox_api POST " /nodes/${node} /qemu/${vmid} /vncproxy" ) " ; then
337337 echo " $api_resp " | jq -c ' {status:"error", error:(.errors.curl // (.errors|tostring))}'
338338 exit 1
339- fi
339+ fi
340340
341- port=" $( echo " $api_resp " | jq -re ' .data.port // empty' 2> /dev/null || true) "
342- ticket=" $( echo " $api_resp " | jq -re ' .data.ticket // empty' 2> /dev/null || true) "
341+ port=" $( echo " $api_resp " | jq -re ' .data.port // empty' 2> /dev/null || true) "
342+ ticket=" $( echo " $api_resp " | jq -re ' .data.ticket // empty' 2> /dev/null || true) "
343343
344- if [[ -z " $port " || -z " $ticket " ]]; then
344+ if [[ -z " $port " || -z " $ticket " ]]; then
345345 jq -n --arg raw " $api_resp " \
346346 ' {status:"error", error:"Proxmox response missing port/ticket", upstream:$raw}'
347347 exit 1
348- fi
348+ fi
349349
350- # Derive host from node’s network info
351- local host
352- host=" $( get_node_host) "
353- if [[ -z " $host " ]]; then
350+ # Derive host from node’s network info
351+ local host
352+ host=" $( get_node_host) "
353+ if [[ -z " $host " ]]; then
354354 jq -n --arg msg " Could not determine host IP for node $node " \
355355 ' {status:"error", error:$msg}'
356356 exit 1
357- fi
357+ fi
358358
359- jq -n \
359+ jq -n \
360360 --arg host " $host " \
361361 --arg port " $port " \
362362 --arg password " $ticket " \
@@ -408,23 +408,23 @@ statuses() {
408408list_snapshots () {
409409 snapshot_response=$( call_proxmox_api GET " /nodes/${node} /qemu/${vmid} /snapshot" )
410410 echo " $snapshot_response " | jq '
411- def to_date:
412- if . == "-" then "-"
413- elif . == null then "-"
414- else (. | tonumber | strftime("%Y-%m-%d %H:%M:%S"))
415- end;
416-
417- {
418- status: "success",
419- printmessage: "true",
420- message: [.data[] | {
421- name: .name,
422- snaptime: ((.snaptime // "-") | to_date),
423- description: .description,
424- parent: (.parent // "-"),
425- vmstate: (.vmstate // "-")
426- }]
427- }
411+ def to_date:
412+ if . == "-" then "-"
413+ elif . == null then "-"
414+ else (. | tonumber | strftime("%Y-%m-%d %H:%M:%S"))
415+ end;
416+
417+ {
418+ status: "success",
419+ printmessage: "true",
420+ message: [.data[] | {
421+ name: .name,
422+ snaptime: ((.snaptime // "-") | to_date),
423+ description: .description,
424+ parent: (.parent // "-"),
425+ vmstate: (.vmstate // "-")
426+ }]
427+ }
428428 '
429429}
430430
@@ -492,9 +492,9 @@ parse_json "$parameters" || exit 1
492492
493493cleanup_vm=0
494494cleanup () {
495- if (( cleanup_vm == 1 )) ; then
496- execute_and_wait DELETE " /nodes/${node} /qemu/${vmid} "
497- fi
495+ if (( cleanup_vm == 1 )) ; then
496+ execute_and_wait DELETE " /nodes/${node} /qemu/${vmid} "
497+ fi
498498}
499499
500500trap cleanup EXIT
0 commit comments