From 347520af222481b930cb289584ed92d9ee3be4a2 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 23 Oct 2016 19:35:00 +0200 Subject: kvmInformation: output JSON --- vcp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/vcp b/vcp index 182e415..bd55277 100755 --- a/vcp +++ b/vcp @@ -26,6 +26,29 @@ _netcup_vcp_cmd_kvmInformation() { -q page=vServerKVMGeneral \ -q section=kvmInformation \ -q selectedVServerId="$1" + + text=$(w3m -T text/html -dump -cols 4096 "$_netcup_vcp_content_cache") + vsname=$(echo "$text" | sed -n 's/^vServer-Name\s*\(\S\+\).*/\1/p') \ + state=$(echo "$text" | sed -n 's/^Status\s*\(\S\+\).*/\1/p') \ + boot_device=$(echo "$text" | sed -n 's/^Startlaufwerk\s*\(\S\+\).*/\1/p') \ + attached_iso=$(echo "$text" | sed -n 's/^Momentan eingelegt:\s*\(\S\+\).*/\1/p') \ + net1_mac=$(echo "$text" | grep '^1\s' | awk '{print$2}') \ + net1_ipv4=$(echo "$text" | grep '^1\s' | awk '{print$3}') \ + net1_ipv6=$(echo "$text" | grep '^1\s' | awk '{print$4}') \ + ftp_host=$(echo "$text" | sed -n 's/^Hostname:\s*\(\S\+\).*/\1/p') \ + ftp_user=$(echo "$text" | sed -n 's/^Benutzername:\s*\(\S\+\).*/\1/p') \ + ftp_pass=$(echo "$text" | sed -n 's/^Passwort:\s*\(\S\+\).*/\1/p') \ + jq -n '{ + vsname: env.vsname, + state: { gestartet: "online", gestoppt: "offline" }[env.state], + boot_device: env.boot_device, + attached_iso: + (if env.attached_iso == "n/a" then null else env.attached_iso end), + network: [ + { mac: env.net1_mac, ipv4: env.net1_ipv4, ipv6: env.net1_ipv6 } + ], + ftp: { host: env.ftp_host, pass: env.ftp_pass, user: env.ftp_user } + }' } # attachCdrom : VServerID, ImageName -> TODO -- cgit v1.2.3