updateting qemu-ifup to support the VNI passed in the ifname
This commit is contained in:
parent
7d5a761793
commit
1c38fef482
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
|
||||||
IFACE=$1
|
IFACE=$1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,35 +7,26 @@ if [ ${#IFACE} -gt 14 ]; then
|
||||||
exit 10
|
exit 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e /etc/libvirt/hooks/$IFACE ]
|
VNI=$(printf '%d' $((16#${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
|
|
||||||
|
|
||||||
if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then
|
if ! [[ $VNI =~ ^[0-9]+$ ]]; then
|
||||||
echo "CLUSTER '$CLUSTER' seems not to be valid"
|
echo "VNI '$VNI' seems not to be valid"
|
||||||
exit 10
|
exit 10
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LOOPBACKIP=$(ip -4 addr show dev lo | grep -Po 'inet \K[\d.]+' | grep -v "^127.0.0.1$")
|
LOOPBACKIP=$(ip -4 addr show dev lo | grep -Po 'inet \K[\d.]+' | grep -v "^127.0.0.1$")
|
||||||
BRIDGE=br${CLUSTER}
|
BRIDGE=br${VNI}
|
||||||
VIF=vxlan${CLUSTER}
|
VIF=vxlan${VNI}
|
||||||
[ -z ${PARENTIF:=""} ] || VIF=vlan${CLUSTER} ### if we have a parentif set we're just going to handle it as a legacy old school vlan
|
[ -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}
|
ip link set up ${IFACE}
|
||||||
|
|
||||||
if ! ip link show dev ${VIF} &>/dev/null; then
|
if ! ip link show dev ${VIF} &>/dev/null; then
|
||||||
if [ -z ${PARENTIF:=""} ]
|
if [ -z ${PARENTIF:=""} ]
|
||||||
then
|
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
|
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
|
fi
|
||||||
ip link set up ${VIF}
|
ip link set up ${VIF}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue