From: Justin Pettit Date: Fri, 30 Apr 2010 22:09:34 +0000 (-0700) Subject: xenserver: Wire up emergency reset plug-in and call it on manager change X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59a81d829017956100170f9499dc690613fc1f6f;p=openvswitch xenserver: Wire up emergency reset plug-in and call it on manager change Add code to "emergency_reset" plug-in method to actually do its work. Also, when the manager is changed, call the emergency reset command to clear out any configuration that may have been done by a previous controller. --- diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update index 42bd09a1..04d0774b 100755 --- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update +++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update @@ -58,10 +58,18 @@ def update(session, args): currentController = vswitchCurrentController() if controller == "" and currentController != "": delete_cacert() + try: + emergency_reset(session, None) + except: + pass removeControllerCfg() return "Successfully removed controller config" elif controller != currentController: delete_cacert() + try: + emergency_reset(session, None) + except: + pass setControllerCfg(controller) return "Successfully set controller to " + controller else: @@ -110,10 +118,13 @@ def vswitchCfgMod(action_args): [ str(exitcode) , str(action_args) ]) def emergency_reset(session, args): - # This function is just a place holder for testing until the real - # functionality is implemented. - syslog.syslog("openvswitch-cfg-update: emergency_reset called") - return "Need to implement emergency_reset" + cmd = [vsctl, "emer-reset"] + exitcode = subprocess.call(cmd) + if exitcode != 0: + raise XenAPIPlugin.Failure("VSWITCH_EMER_RESET_FAILURE", + [ str(exitcode) ]) + + return "Successfully reset configuration" if __name__ == "__main__": XenAPIPlugin.dispatch({"update": update,