[Devstack] Replace tap with veth

This patch replace tap interfaces by veth pairs which
ensures that port is always present in ovs even when VM
is powered off.

Closes-Bug: #1722158

Change-Id: I04ff6a97bebf15636a794b51f748c62eda627d36
This commit is contained in:
Vasyl Saienko 2017-10-09 13:14:41 +03:00
parent b8a38d9731
commit f357c76cd5
3 changed files with 13 additions and 8 deletions

View File

@ -2120,7 +2120,7 @@ function cleanup_baremetal_basic_ops {
# Cleanup node bridge/interfaces
for i in $(seq 1 $IRONIC_VM_INTERFACE_COUNT); do
sudo ip tuntap del dev tap-${vm_name}i${i} mode tap
sudo ip link del dev tap-${vm_name}i${i}
done
done

View File

@ -94,10 +94,15 @@ INTERFACE_COUNT=${INTERFACE_COUNT:-1}
for int in $(seq 1 $INTERFACE_COUNT); do
tapif=tap-${NAME}i${int}
sudo ip tuntap add dev $tapif mode tap
sudo ip link set $tapif mtu $INTERFACE_MTU
sudo ip link set $tapif up
sudo ovs-vsctl add-port $BRIDGE $tapif
ovsif=ovs-${NAME}i${int}
# NOTE(vsaienko) use veth pair here to ensure that interface
# exists in OVS even when VM is powered off.
sudo ip link add dev $tapif type veth peer name $ovsif
for l in $tapif $ovsif; do
sudo ip link set dev $l up
sudo ip link set $l mtu $INTERFACE_MTU
done
sudo ovs-vsctl add-port $BRIDGE $ovsif
done
if ! virsh list --all | grep -q $NAME; then
@ -126,5 +131,5 @@ if ! virsh list --all | grep -q $NAME; then
fi
# echo mac in format mac1,ovs-node-0i1;mac2,ovs-node-0i2;...;macN,ovs-node0iN
VM_MAC=$(echo -n $(virsh domiflist $NAME |awk '/tap-/{print $5","$1}')|tr ' ' ';')
VM_MAC=$(echo -n $(virsh domiflist $NAME |awk '/tap-/{print $5","$3}')|tr ' ' ';' |sed s/tap-/ovs-/g)
echo -n "$VM_MAC $VBMC_PORT $PDU_OUTLET"

View File

@ -45,8 +45,8 @@
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
{% for n in range(1, interface_count+1) %}
<interface type='ethernet'>
<target dev='{{ "tap-" + name + "i" + n|string }}'/>
<interface type='direct'>
<source dev='{{ "tap-" + name + "i" + n|string }}'/>
<model type='{{ nicdriver }}'/>
<address type='pci' domain='0x0000' bus='0x01' slot='{{ "0x0" + n|string }}' function='0x0'/>
</interface>