From 04ce9e66e3c86029b4f2524fcf3f05aa9fa40625 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 27 Feb 2017 10:40:39 -0600 Subject: [PATCH] functions/vmip: Correctly handle multiple addresses When a virtual machine has multiple matching addresses, only the first will be printed. --- functions/vmip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/vmip b/functions/vmip index 3a4d189..e00ac2b 100644 --- a/functions/vmip +++ b/functions/vmip @@ -1,2 +1,2 @@ virsh qemu-agent-command $1 '{"execute":"guest-network-get-interfaces"}' \ - | jq -r '.return | .[] | select(.name=="eth0") | .["ip-addresses"] | .[] | select(.["ip-address-type"] == "ipv6" and (.["ip-address"]|startswith("fe80")|not)) | .["ip-address"]' + | jq -r '.return | .[] | select(.name=="eth0") | .["ip-addresses"] | map(select(.["ip-address-type"] == "ipv6" and (.["ip-address"]|startswith("fe80")|not)))[0]["ip-address"]'