From 1c38fef482f59d31e20e3fde4fef787efc4aef7d Mon Sep 17 00:00:00 2001 From: toby Date: Tue, 9 Apr 2019 20:38:44 +0000 Subject: [PATCH] updateting qemu-ifup to support the VNI passed in the ifname --- files/qemu-ifdown | 1 - files/qemu-ifup | 25 ++++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/files/qemu-ifdown b/files/qemu-ifdown index ccbb78d..6be47b0 100755 --- a/files/qemu-ifdown +++ b/files/qemu-ifdown @@ -1,5 +1,4 @@ #!/bin/bash -set -x IFACE=$1 diff --git a/files/qemu-ifup b/files/qemu-ifup index b1fbcb7..63bcd0a 100755 --- a/files/qemu-ifup +++ b/files/qemu-ifup @@ -7,35 +7,26 @@ if [ ${#IFACE} -gt 14 ]; then exit 10 fi -if [ -e /etc/libvirt/hooks/$IFACE ] - then - source /etc/libvirt/hooks/$IFACE - else - eval $( - curl --fail --connect-timeout 5 -s http://stackapi.usw3.admin.stage.wit.com:4000/network_interface?interface_name=$IFACE && \ - curl --fail --connect-timeout 5 -s http://stackapi.usw3.admin.stage.wit.com:4001/network_interface?interface_name=$IFACE - ) - CLUSTER=${VNI:-""} -fi +VNI=$(printf '%d' $((16#${IFACE##*.}))) -if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then - echo "CLUSTER '$CLUSTER' seems not to be valid" +if ! [[ $VNI =~ ^[0-9]+$ ]]; then + echo "VNI '$VNI' seems not to be valid" exit 10 fi LOOPBACKIP=$(ip -4 addr show dev lo | grep -Po 'inet \K[\d.]+' | grep -v "^127.0.0.1$") -BRIDGE=br${CLUSTER} -VIF=vxlan${CLUSTER} -[ -z ${PARENTIF:=""} ] || VIF=vlan${CLUSTER} ### if we have a parentif set we're just going to handle it as a legacy old school vlan +BRIDGE=br${VNI} +VIF=vxlan${VNI} +[ -z ${PARENTIF:=""} ] || VIF=vlan${VNI} ### if we have a parentif set we're just going to handle it as a legacy old school vlan ip link set up ${IFACE} if ! ip link show dev ${VIF} &>/dev/null; then if [ -z ${PARENTIF:=""} ] then - ip link add ${VIF} type vxlan id ${CLUSTER} dstport 4789 local ${LOOPBACKIP} nolearning + ip link add ${VIF} type vxlan id ${VNI} dstport 4789 local ${LOOPBACKIP} nolearning else - ip link add link ${PARENTIF} name ${VIF} type vlan protocol 802.1q id ${CLUSTER} + ip link add link ${PARENTIF} name ${VIF} type vlan protocol 802.1q id ${VNI} fi ip link set up ${VIF} fi