socket-util: Move get_mtime() here from stream-ssl.
[openvswitch] / xenserver / etc_xapi.d_plugins_openvswitch-cfg-update
index b573b035d00a717a7a7575cb275bb3450b0302b8..42bd09a195772a06c3c524d46067397b0d5e961d 100755 (executable)
@@ -25,6 +25,7 @@ import XenAPIPlugin
 import XenAPI
 import os
 import subprocess
+import syslog
 
 vsctl="/usr/bin/ovs-vsctl"
 cacert_filename="/etc/openvswitch/vswitchd.cacert"
@@ -46,7 +47,12 @@ def update(session, args):
         raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", [])
     pool = session.xenapi.pool.get_record(pools[0])
     try:
-        controller = pool["other_config"]["vSwitchController"]
+        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 = ""
     currentController = vswitchCurrentController()
@@ -76,6 +82,8 @@ def removeControllerCfg():
                    "--", "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",
                    "--", "del-ssl",
                    "--", "--bootstrap", "set-ssl",
@@ -100,6 +108,13 @@ def vswitchCfgMod(action_args):
     if exitcode != 0:
         raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE",
                                    [ 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"
     
 if __name__ == "__main__":
-    XenAPIPlugin.dispatch({"update": update})
+    XenAPIPlugin.dispatch({"update": update,
+                           "emergency_reset": emergency_reset})