[ovs-dev] [PATCH] xenserver: Add support for disabling in-band management via XAPI.

Andrew Evans aevans at nicira.com
Mon Feb 28 23:02:51 UTC 2011


Allow users or applications to enable or disable in-band management of
individual bridges by setting the 'vswitch-disable-in-band' key in the
'other_config' attribute of the corresponding network to 'true' or
'false'.
---
 tests/interface-reconfigure.at                     |   10 ++++++++-
 .../etc_xapi.d_plugins_openvswitch-cfg-update      |   22 ++++++++++++++++++++
 .../opt_xensource_libexec_InterfaceReconfigure.py  |    6 ++++-
 ...ensource_libexec_InterfaceReconfigureVswitch.py |    8 +++++++
 .../usr_share_openvswitch_scripts_ovs-xapi-sync    |   13 +++++++++++
 5 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at
index ad70263..1470967 100644
--- a/tests/interface-reconfigure.at
+++ b/tests/interface-reconfigure.at
@@ -584,7 +584,11 @@ EOF
 		<bridge>
 			xenbr0
 		</bridge>
-		<other_config/>
+		<other_config>
+			<vswitch-disable-in-band>
+				true
+			</vswitch-disable-in-band>
+		</other_config>
 		<uuid>
 			c9eecb03-560d-61de-b6a8-56dfc766f67e
 		</uuid>
@@ -671,6 +675,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xenbr2 configuration
     --may-exist add-port xenbr2 eth2
     set Bridge xenbr2 other-config:hwaddr="00:15:17:a0:29:80"
     set Bridge xenbr2 fail_mode=standalone
+    remove Bridge xenbr2 other_config disable-in-band
     br-set-external-id xenbr2 xs-network-uuids d08c8749-0c8f-9e8d-ce25-fd364661ee99
 /sbin/ifup xenbr2
 /sbin/update-issue
@@ -736,6 +741,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi3 configuration
     --may-exist add-port xenbr3 eth3
     set Bridge xenbr3 other-config:hwaddr="00:15:17:a0:29:81"
     set Bridge xenbr3 fail_mode=standalone
+    remove Bridge xenbr3 other_config disable-in-band
     br-set-external-id xenbr3 xs-network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
     --may-exist add-br xapi3 xenbr3 123
     br-set-external-id xapi3 xs-network-uuids 2902ae1b-8013-897a-b697-0b200ea3aaa5;db7bdc03-074d-42ae-fc73-9b06de1d57f6
@@ -823,6 +829,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi1 configuration
     set Port bond0 MAC="00:22:19:22:4b:af" other-config:bond-miimon-interval=100 bond_downdelay=200 bond_updelay=31000 other-config:bond-detect-mode=carrier lacp=off bond_mode=balance-slb
     set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af"
     set Bridge xapi1 fail_mode=standalone
+    remove Bridge xapi1 other_config disable-in-band
     br-set-external-id xapi1 xs-network-uuids 45cbbb43-113d-a712-3231-c6463f253cef;99be2da4-6c33-6f8e-49ea-3bc592fe3c85
 /sbin/ifup xapi1
 action_up: bring up bond0
@@ -907,6 +914,7 @@ Applying changes to /etc/sysconfig/network-scripts/ifcfg-xapi2 configuration
     set Port bond0 MAC="00:22:19:22:4b:af" other-config:bond-miimon-interval=100 bond_downdelay=200 bond_updelay=31000 other-config:bond-detect-mode=carrier lacp=off bond_mode=balance-slb
     set Bridge xapi1 other-config:hwaddr="00:22:19:22:4b:af"
     set Bridge xapi1 fail_mode=standalone
+    remove Bridge xapi1 other_config disable-in-band
     br-set-external-id xapi1 xs-network-uuids 45cbbb43-113d-a712-3231-c6463f253cef;99be2da4-6c33-6f8e-49ea-3bc592fe3c85
     --may-exist add-br xapi2 xapi1 4
     br-set-external-id xapi2 xs-network-uuids 45cbbb43-113d-a712-3231-c6463f253cef;99be2da4-6c33-6f8e-49ea-3bc592fe3c85
diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
index 721fe64..0f51fa8 100755
--- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
+++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
@@ -97,9 +97,29 @@ def update(session, args):
         except KeyError:
             pass
 
+    dib_changed = False
     fail_mode_changed = False
     for bridge in vswitchCfgQuery(['list-br']).split():
+        network = bton[bridge]
         bridge = vswitchCfgQuery(['br-to-parent', bridge])
+
+        # Change bridge disable_in_band option if XAPI and OVS states differ.
+        xapi_dib = network['other_config'].get('vswitch-disable-in-band')
+        if not xapi_dib:
+            xapi_dib = '';
+        ovs_dib = vswitchCfgQuery(['get', 'Bridge', bridge,
+                                   'other_config:disable-in-band']).strip('"')
+
+        if xapi_dib != ovs_dib:
+            if xapi_dib:
+                vswitchCfgMod(['--', 'set', 'Bridge', bridge,
+                               'other_config:disable-in-band=' + xapi_dib])
+            else:
+                vswitchCfgMod(['--', 'remove', 'Bridge', bridge,
+                               'other_config', 'disable-in-band'])
+            dib_changed = True
+
+        # Change bridge fail_mode if XAPI state differs from OVS state.
         bridge_fail_mode = vswitchCfgQuery(["get", "Bridge",
             bridge, "fail_mode"]).strip('[]"')
 
@@ -119,6 +139,8 @@ def update(session, args):
                 "fail_mode=%s" % fail_mode])
             fail_mode_changed = True
 
+    if dib_changed:
+        ret_str += "Updated in-band management.  "
     if fail_mode_changed:
         ret_str += "Updated fail_mode.  "
 
diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
index a9bbf07..0fd79e6 100644
--- a/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
+++ b/xenserver/opt_xensource_libexec_InterfaceReconfigure.py
@@ -332,7 +332,11 @@ _BOND_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml),
                           lambda n: _strlist_from_xml(n, 'slaves', 'slave')),
               }
 
-_NETWORK_OTHERCONFIG_ATTRS = [ 'mtu', 'static-routes', 'vswitch-controller-fail-mode' ] + _ETHTOOL_OTHERCONFIG_ATTRS
+_NETWORK_OTHERCONFIG_ATTRS = [ 'mtu',
+                               'static-routes',
+                               'vswitch-controller-fail-mode',
+                               'vswitch-disable-in-band' ] \
+                               + _ETHTOOL_OTHERCONFIG_ATTRS
 
 _NETWORK_ATTRS = { 'uuid': (_str_to_xml,_str_from_xml),
                    'bridge': (_str_to_xml,_str_from_xml),
diff --git a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
index 6a1d4ed..16aee77 100644
--- a/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
+++ b/xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py
@@ -351,6 +351,7 @@ def configure_datapath(pif):
 
     pool = db().get_pool_record()
     network = db().get_network_by_bridge(bridge)
+    network_rec = None
     fail_mode = None
     valid_fail_modes = ['standalone', 'secure']
 
@@ -366,6 +367,13 @@ def configure_datapath(pif):
 
     vsctl_argv += ['--', 'set', 'Bridge', bridge, 'fail_mode=%s' % fail_mode]
 
+    if network_rec:
+        dib = network_rec['other_config'].get('vswitch-disable-in-band')
+        if dib:
+            vsctl_argv += ['--', 'set', 'Bridge', bridge, 'other_config:disable-in-band=' + dib]
+        else:
+            vsctl_argv += ['--', 'remove', 'Bridge', bridge, 'other_config', 'disable-in-band']
+
     vsctl_argv += set_br_external_ids(pif)
     vsctl_argv += ['## done configuring datapath %s' % bridge]
 
diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
index 4d030fd..6f13567 100755
--- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
@@ -148,6 +148,18 @@ def update_fail_mode(name):
 
     call_vsctl(["set", "bridge", name, "fail_mode=" + fail_mode])
 
+def update_in_band_mgmt(name):
+    rec = get_network_by_bridge(name)
+
+    if not rec:
+        return
+
+    dib = rec['other_config'].get('vswitch-disable-in-band')
+    if dib:
+        call_vsctl(['set', 'bridge', name, 'other_config:disable-in-band=' + dib])
+    else:
+        call_vsctl(['remove', 'bridge', name, 'other_config', 'disable-in-band'])
+
 def update_bridge_id(name, ids):
     id = get_bridge_id(name, ids.get("xs-network-uuids"))
 
@@ -279,6 +291,7 @@ def main(argv):
             for name,ids in new_bridges.items():
                 if name not in bridges:
                     update_fail_mode(name)
+                    update_in_band_mgmt(name)
 
                 if (name not in bridges) or (bridges[name] != ids):
                     update_bridge_id(name, ids)
-- 
1.7.2.3





More information about the dev mailing list