shwstppr commented on code in PR #11601:
URL: https://github.com/apache/cloudstack/pull/11601#discussion_r2341972358
##########
extensions/Proxmox/proxmox.sh:
##########
@@ -285,6 +285,88 @@ status() {
echo "{\"status\": \"success\", \"power_state\": \"$powerstate\"}"
}
+get_node_host() {
+ check_required_fields node
+ local net_json host
+
+ if ! net_json="$(call_proxmox_api GET "/nodes/${node}/network")"; then
+ echo ""
+ return 1
+ fi
+
+ # Prefer a static non-bridge IP
+ host="$(echo "$net_json" | jq -r '
+ .data
+ | map(select(
+ (.type // "") != "bridge" and
+ (.type // "") != "bond" and
+ (.method // "") == "static" and
+ ((.address // .cidr // "") != "")
+ ))
+ | map(.address // (.cidr | split("/")[0]))
+ | .[0] // empty
+ ' 2>/dev/null)"
+
+ # Fallback: first interface with a CIDR
+ if [[ -z "$host" ]]; then
+ host="$(echo "$net_json" | jq -r '
+ .data
+ | map(select((.cidr // "") != ""))
+ | map(.cidr | split("/")[0])
+ | .[0] // empty
+ ' 2>/dev/null)"
+ fi
+
+ echo "$host"
+ }
+
+ get_console() {
+ check_required_fields node vmid
+
+ # Request VNC proxy from Proxmox
+ local api_resp port ticket
+ if ! api_resp="$(call_proxmox_api POST
"/nodes/${node}/qemu/${vmid}/vncproxy")"; then
Review Comment:
Added handling
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]