# Keep other-config/ keys in sync with device.ml:vif_udev_keys
cfg_mod="/usr/bin/ovs-cfg-mod"
+vsctl="/usr/bin/ovs-vsctl"
dump_vif_details="/usr/share/vswitch/scripts/dump-vif-details"
service="/sbin/service"
fi
logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}"
- vid=
- if [ -e "/var/lib/openvswitch/br-$bridge" ]; then
- . "/var/lib/openvswitch/br-$bridge"
- if [ -n "$VLAN_SLAVE" -a -n "$VLAN_VID" ]; then
- bridge=$VLAN_SLAVE
- vid="--add=vlan.$vif.tag=$VLAN_VID"
- fi
+ local VLAN_ID=$($vsctl br-to-vlan $bridge)
+ local vid=
+ if [ "$VLAN_ID" -ne 0 ] ; then
+ bridge=$($vsctl br-to-parent $bridge)
+ vid="--add=vlan.${dev}.tag=${VLAN_ID}"
fi
${IP} link set "${vif}" down || logger -t scripts-vif "Failed to ip link set ${vif} down"
cfgmod_argv += ['--add=vlan.%s.tag=%s' % (ipdev, pifrec['VLAN'])]
cfgmod_argv += ['--add=iface.%s.internal=true' % (ipdev)]
cfgmod_argv += ['--add=iface.%s.fake-bridge=true' % (ipdev)]
- if not os.path.exists(vswitch_state_dir):
- os.mkdir(vswitch_state_dir)
- br = ConfigurationFile("br-%s" % ipdev, vswitch_state_dir)
- br.write("VLAN_SLAVE=%s\n" % bridge)
- br.write("VLAN_VID=%s\n" % pifrec['VLAN'])
- br.close()
- f.attach_child(br)
- else:
- br = ConfigurationFile("br-%s" % ipdev, vswitch_state_dir)
- br.unlink()
- f.attach_child(br)
# Apply updated configuration.
try: