From 928142ce70764d7305ea923542c6e697390b86d4 Mon Sep 17 00:00:00 2001 From: toby Date: Fri, 5 Oct 2018 18:29:12 +0000 Subject: [PATCH] updating the qemu-ifup scripts to reflect the new versions usling local files --- files/qemu-ifup | 3 ++- files/qemu-ifup-public | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/files/qemu-ifup b/files/qemu-ifup index 12f4e93..f121df7 100755 --- a/files/qemu-ifup +++ b/files/qemu-ifup @@ -3,7 +3,8 @@ set -e IFACE=$1 # vm. -CLUSTER=$(curl -s -H 'X-Wit-Auth: true' http://10.0.0.1:4000/get-by-iface/${IFACE} | sed 's/"//g' | awk '{print $1}') +source /etc/libvirt/hooks/$IFACE +echo CLUSTER=$CLUSTER if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then echo "CLUSTER seems not to be valid" diff --git a/files/qemu-ifup-public b/files/qemu-ifup-public index 7d06a23..49eea54 100755 --- a/files/qemu-ifup-public +++ b/files/qemu-ifup-public @@ -1,15 +1,18 @@ #!/bin/bash set -e +set -x IFACE=$1 +source /etc/libvirt/hooks/$IFACE +echo CLUSTER=$CLUSTER +echo IP=$IP + maxprefixv6=64 -maxprefixv4=29 +maxprefixv4=25 publicmac=52:54:00:00:00:11 -IP=$(curl -s -H 'X-Wit-Auth: true' http://10.0.0.1:4000/get-by-iface/${IFACE} | sed 's/"//g' | awk '{print $2}') - if [ -z $IP ]; then echo "got nothing back from the API" exit 10 @@ -33,8 +36,9 @@ arp -i ${IFACE} -Ds 169.254.0.1 ${IFACE} netmask 255.255.255.255 pub IFS=',' read -ra IPS <<< "$IP" for IP in "${IPS[@]}"; do - if [[ $IP =~ ^170.199.21[0-9]\.[0-9]{1,3}/([0-9]{2})$ ]]; then ### we got a IPv4 prefix < maxprefixv4 - + echo $IP + if [[ $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]/([0-9]{2})$ ]]; then ### we got a IPv4 prefix < maxprefixv4 +echo matched ${BASH_REMATCH[1]} if [ ${BASH_REMATCH[1]} -lt $maxprefixv4 ]; then echo "we don't support such a big customer net?" continue