X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fetc_xapi.d_plugins_openvswitch-cfg-update;h=e1c854610ea679fb27a07cde81e697648ad4839c;hb=29722bcc53774a763c583dfeec12af492a035008;hp=5189d0436c333a5f90b6f46e6c65b2811aff7676;hpb=2dd26837037ee6b9ff3d8fbdb1eb64b203ad7b02;p=openvswitch diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update index 5189d043..e1c85461 100755 --- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update +++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update @@ -55,15 +55,7 @@ def update(session, args): if len(pools) > 1: raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", []) pool = session.xenapi.pool.get_record(pools[0]) - try: - try: - controller = pool["vswitch_controller"] - except KeyError: - # On systems older than XenServer 5.6.0, we needed to store - # the key in "other_config". - controller = pool["other_config"]["vSwitchController"] - except KeyError, e: - controller = "" + controller = pool.get("vswitch_controller", "") ret_str = "" currentController = vswitchCurrentController() if controller == "" and currentController != "": @@ -97,9 +89,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 +140,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. " @@ -128,8 +151,7 @@ def update(session, args): return "No change to configuration" def vswitchCurrentController(): - controller = vswitchCfgQuery(["get", "Open_vSwitch", - ".", "managers"]).strip('[]"') + controller = vswitchCfgQuery(["get-manager"]) if controller == "": return controller if len(controller) < 4 or controller[0:4] != "ssl:": @@ -138,20 +160,19 @@ def vswitchCurrentController(): return controller.split(':')[1] def removeControllerCfg(): - vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", + vswitchCfgMod(["--", "del-manager", "--", "del-ssl"]) def setControllerCfg(controller): # /etc/xensource/xapi-ssl.pem is mentioned twice below because it # contains both the private key and the certificate. - vswitchCfgMod(["--", "clear", "Open_vSwitch", ".", "managers", + vswitchCfgMod(["--", "del-manager", "--", "del-ssl", "--", "--bootstrap", "set-ssl", "/etc/xensource/xapi-ssl.pem", "/etc/xensource/xapi-ssl.pem", cacert_filename, - "--", "set", "Open_vSwitch", ".", - 'managers="ssl:' + controller + ':6632"']) + "--", "set-manager", 'ssl:' + controller + ':6632']) def vswitchCfgQuery(action_args): cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args