xenserver: Wire up emergency reset plug-in and call it on manager change
authorJustin Pettit <jpettit@nicira.com>
Fri, 30 Apr 2010 22:09:34 +0000 (15:09 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 30 Apr 2010 23:53:29 +0000 (16:53 -0700)
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.

xenserver/etc_xapi.d_plugins_openvswitch-cfg-update

index 42bd09a195772a06c3c524d46067397b0d5e961d..04d0774be2aaab00d954ea54a85b284c32c07dc5 100755 (executable)
@@ -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,