From 7ebd95796c6c5aa888a6e5b57c7fa2c2549e812b Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Mon, 8 Feb 2021 21:21:47 +0000 Subject: [PATCH] Ensure to grab the network that is /24, hence ipv4 Fix this better, for a better check, but this works for the time being --- manage-hypervisor-nodes.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage-hypervisor-nodes.sh b/manage-hypervisor-nodes.sh index 0acaa15..de0386e 100755 --- a/manage-hypervisor-nodes.sh +++ b/manage-hypervisor-nodes.sh @@ -13,14 +13,14 @@ maas_assign_networks() system_id=$1 # Get the details of the physical interface - phsy_int=$(maas ${maas_profile} interfaces read ${system_id} | jq ".[] | {id:.id, name:.name,parent:.parents}" --compact-output | grep "parent.*\[\]") + phsy_int=$(maas ${maas_profile} interfaces read ${system_id} | jq -c ".[] | {id:.id, name:.name,parent:.parents}" | grep "parent.*\[\]") phys_int_name=$(echo $phsy_int | jq .name | sed s/\"//g) phys_int_id=$(echo $phsy_int | jq .id | sed s/\"//g) i=0 for vlan in ${vlans[*]} do - subnet_line=$(maas admin subnets read | jq ".[] | {subnet_id:.id, vlan:.vlan.vid, vlan_id:.vlan.id}" --compact-output | grep "vlan\":$vlan," | head -n 1) + subnet_line=$(maas admin subnets read | jq -rc --arg vlan "$vlan" ".[] | select(.vlan.vid == $vlan) | select(.name | contains(\"/24\"))| {subnet_id:.id, vlan_id:.vlan.id}") maas_vlan_id=$(echo $subnet_line | jq .vlan_id | sed s/\"//g) maas_subnet_id=$(echo $subnet_line | jq .subnet_id | sed s/\"//g) ip_addr=""