updating the qemu-ifup scripts to reflect the new versions usling local files

This commit is contained in:
toby 2018-10-05 18:29:12 +00:00
parent bc97208b34
commit 928142ce70
2 changed files with 11 additions and 6 deletions

View File

@ -3,7 +3,8 @@ set -e
IFACE=$1
# vm<vm_id>.<num>
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"

View File

@ -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