xenserver: Fix VLANs on virtual interfaces.
authorBen Pfaff <blp@nicira.com>
Wed, 20 May 2009 23:18:45 +0000 (16:18 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 21 May 2009 16:42:54 +0000 (09:42 -0700)
xenserver/etc_xensource_scripts_vif
xenserver/opt_xensource_libexec_interface-reconfigure

index 6051d9a2182be64f1d9967ab92e46c2c4e4e3ae8..3a8d264aa650f50635035aacde01e30fbe4a8c24 100755 (executable)
@@ -72,8 +72,8 @@ add_to_bridge()
     logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}"
 
     vid=
-    if [ -e "/etc/sysconfig/network-scripts/ifcfg-$bridge" ]; then
-       . "/etc/sysconfig/network-scripts/ifcfg-$bridge"
+    if [ -e "/etc/sysconfig/vswitch/br-$bridge" ]; then
+       . "/etc/sysconfig/vswitch/br-$bridge"
        if [ -n "$VLAN_SLAVE" -a -n "$VLAN_VID" ]; then
            bridge=$VLAN_SLAVE
            vid="--add=vlan.$vif.tag=$VLAN_VID"
index 27c8f502642a6d4f4875be23b1f1763600849480..d29d1cf64aa5fa8b402b5b253d9b6261bbe494dd 100755 (executable)
@@ -70,6 +70,7 @@ db = None
 management_pif = None
 
 dbcache_file = "/etc/vswitch.dbcache"
+vswitch_config_dir = "/etc/sysconfig/vswitch"
 
 class Usage(Exception):
     def __init__(self, msg):
@@ -762,6 +763,7 @@ def configure_bond(pif):
 def action_up(pif):
     pifrec = db.get_pif_record(pif)
 
+    bridge = bridge_name(pif)
     interface = interface_name(pif)
     ipdev = ipdev_name(pif)
     datapath = datapath_name(pif)
@@ -829,6 +831,16 @@ def action_up(pif):
         # xapi insists that its attempts to create the bridge succeed,
         # so force that to happen.
         argv += ['--add=iface.%s.fake-bridge=true' % (ipdev)]
+
+        # /etc/xensource/scripts/vif needs to know where to add VIFs.
+        if not os.path.exists(vswitch_config_dir):
+            os.mkdir(vswitch_config_dir)
+        f = ConfigurationFile("br-%s" % bridge, vswitch_config_dir)
+        f.write("VLAN_SLAVE=%s\n" % datapath)
+        f.write("VLAN_VID=%s\n" % pifrec['VLAN'])
+        f.close()
+        f.apply()
+        f.commit()
     if bond_master:
         argv += configure_bond(bond_master)
     modify_config(argv)