From da54975c9d79313ba27d80ee8901eee160653e3a Mon Sep 17 00:00:00 2001 From: Andrew Evans Date: Mon, 28 Feb 2011 18:26:04 -0800 Subject: [PATCH] xenserver: Add support for disabling in-band management via XAPI. 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'. Bug #4749. --- tests/interface-reconfigure.at | 10 +++++- .../etc_xapi.d_plugins_openvswitch-cfg-update | 31 +++++++++++++++++++ ..._xensource_libexec_InterfaceReconfigure.py | 6 +++- ...rce_libexec_InterfaceReconfigureVswitch.py | 10 ++++++ ...sr_share_openvswitch_scripts_ovs-xapi-sync | 19 ++++++++++++ 5 files changed, 74 insertions(+), 2 deletions(-) diff --git a/tests/interface-reconfigure.at b/tests/interface-reconfigure.at index ad7026374..147096761 100644 --- a/tests/interface-reconfigure.at +++ b/tests/interface-reconfigure.at @@ -584,7 +584,11 @@ EOF xenbr0 - + + + true + + c9eecb03-560d-61de-b6a8-56dfc766f67e @@ -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 721fe6476..e2dc939f0 100755 --- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update +++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update @@ -97,9 +97,38 @@ 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]) + + 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('"') + + # Do nothing if setting is invalid, and warn the user. + if xapi_dib not in ['true', 'false', '']: + ret_str += '"' + xapi_dib + '"' + \ + ' is an invalid value for vswitch-disable-in-band on ' + \ + bridge + ' ' + + # Change bridge disable-in-band option if XAPI and OVS states differ. + elif xapi_dib != ovs_dib: + # 'true' or 'false' + if xapi_dib: + vswitchCfgMod(['--', 'set', 'Bridge', bridge, + 'other_config:disable-in-band=' + xapi_dib]) + # '' or None + 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 +148,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 a9bbf07e2..0fd79e69e 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 6a1d4edc8..661199b4a 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,15 @@ 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 not dib: + vsctl_argv += ['--', 'remove', 'Bridge', bridge, 'other_config', 'disable-in-band'] + elif dib in ['true', 'false']: + vsctl_argv += ['--', 'set', 'Bridge', bridge, 'other_config:disable-in-band=' + dib] + else: + log('"' + dib + '"' "isn't a valid setting for other_config:disable-in-band on " + bridge) + 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 4d030fd05..4d82b9981 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -148,6 +148,24 @@ 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 not dib: + call_vsctl(['remove', 'bridge', name, 'other_config', + 'disable-in-band']) + elif dib in ['true', 'false']: + call_vsctl(['set', 'bridge', name, + 'other_config:disable-in-band=' + dib]) + else: + s_log.warning('"' + dib + '"' + "isn't a valid setting for other_config:disable-in-band on " + + bridge) + def update_bridge_id(name, ids): id = get_bridge_id(name, ids.get("xs-network-uuids")) @@ -279,6 +297,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) -- 2.43.0