Skip to content

Commit fccd6bb

Browse files
committed
address review
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent bc826b8 commit fccd6bb

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

extensions/Proxmox/proxmox.sh

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -330,33 +330,33 @@ get_node_host() {
330330
}
331331

332332
get_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() {
408408
list_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

493493
cleanup_vm=0
494494
cleanup() {
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

500500
trap cleanup EXIT

plugins/hypervisors/external/src/test/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisionerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ public void getVmPowerStatesReturnsNullWhenResponseIsFailure() {
790790
.getInstanceStatusesOnExternalSystem(anyString(), anyString(), anyString(), anyMap(), anyInt());
791791

792792
Map<String, HostVmStateReportEntry> result = provisioner.getVmPowerStates(host, accessDetails, "test-extension", "test-path");
793+
assertNull(result);
793794
}
794795

795796
@Test

0 commit comments

Comments
 (0)