[ovs-dev] [PATCH 3/5] xenserver: Use ovs-vsctl for controller configuration in xsconsole

Justin Pettit jpettit at nicira.com
Sat Dec 19 02:21:24 UTC 2009


---
 xenserver/etc_xapi.d_plugins_vswitch-cfg-update    |   43 ++++++-------------
 ..._lib_xsconsole_plugins-base_XSFeatureVSwitch.py |   10 ++---
 2 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update b/xenserver/etc_xapi.d_plugins_vswitch-cfg-update
index 7472d1b..1ae767f 100755
--- a/xenserver/etc_xapi.d_plugins_vswitch-cfg-update
+++ b/xenserver/etc_xapi.d_plugins_vswitch-cfg-update
@@ -26,8 +26,7 @@ import XenAPI
 import os
 import subprocess
 
-cfg_mod="/usr/bin/ovs-cfg-mod"
-vswitchd_cfg_filename="/etc/ovs-vswitchd.conf"
+vsctl="/usr/bin/ovs-vsctl"
 cacert_filename="/etc/ovs-vswitchd.cacert"
 
 # Delete the CA certificate, so that we go back to boot-strapping mode
@@ -63,7 +62,7 @@ def update(session, args):
         return "No change to configuration"
         
 def vswitchCurrentController():
-    controller = vswitchCfgQuery("mgmt.controller")
+    controller = vswitchCfgQuery("get-controller")
     if controller == "":
         return controller
     if len(controller) < 4 or controller[0:4] != "ssl:":
@@ -72,26 +71,20 @@ def vswitchCurrentController():
         return controller[4:]
 
 def removeControllerCfg():
-    vswitchCfgMod(["--del-match", "mgmt.controller=*",
-                   "--del-match", "ssl.bootstrap-ca-cert=*",
-                   "--del-match", "ssl.ca-cert=*",
-                   "--del-match", "ssl.private-key=*",
-                   "--del-match", "ssl.certificate=*"])
+    vswitchCfgMod(["--", "del-controller",
+                   "--", "del-ssl"])
                                        
 def setControllerCfg(controller):
-    vswitchCfgMod(["--del-match", "mgmt.controller=*",
-                   "--del-match", "ssl.bootstrap-ca-cert=*",
-                   "--del-match", "ssl.ca-cert=*",
-                   "--del-match", "ssl.private-key=*",
-                   "--del-match", "ssl.certificate=*",
-                   "-a", "mgmt.controller=ssl:" + controller,
-                   "-a", "ssl.bootstrap-ca-cert=true",
-                   "-a", "ssl.ca-cert=/etc/ovs-vswitchd.cacert",
-                   "-a", "ssl.private-key=/etc/xensource/xapi-ssl.pem",
-                   "-a", "ssl.certificate=/etc/xensource/xapi-ssl.pem"])
+    vswitchCfgMod(["--", "del-controller",
+                   "--", "del-ssl",
+                   "--", "--bootstrap", "set-ssl",
+                   "/etc/xensource/xapi-ssl.pem",
+                   "/etc/xensource/xapi-ssl.pem",
+                   "/etc/ovs-vswitchd.cacert",
+                   "--", "set-controller", "ssl:" + controller])
 
-def vswitchCfgQuery(key):
-    cmd = [cfg_mod, "--config-file=" + vswitchd_cfg_filename, "-q", key]
+def vswitchCfgQuery(action):
+    cmd = [vsctl, "-vANY:console:emer", action]
     output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
     if len(output) == 0 or output[0] == None:
         output = ""
@@ -100,19 +93,11 @@ def vswitchCfgQuery(key):
     return output
 
 def vswitchCfgMod(action_args):
-    cmd = [cfg_mod, "-vANY:console:emer",
-           "--config-file=" + vswitchd_cfg_filename] + action_args
+    cmd = [vsctl, "-vANY:console:emer"] + action_args
     exitcode = subprocess.call(cmd)
     if exitcode != 0:
         raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE",
                                    [ str(exitcode) , str(action_args) ])
-    vswitchReload()
     
-def vswitchReload():
-    exitcode = subprocess.call(["/sbin/service", "vswitch", "reload"])
-    if exitcode != 0:
-        raise XenAPIPlugin.Failure("VSWITCH_CFG_RELOAD_FAILURE", [ str(exitcode) ])
-    
-
 if __name__ == "__main__":
     XenAPIPlugin.dispatch({"update": update})
diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py
index 31a48c3..99dd15d 100644
--- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py
+++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py
@@ -13,8 +13,7 @@ import os
 import socket
 import subprocess
 
-cfg_mod="/usr/bin/ovs-cfg-mod"
-vswitchd_cfg_filename="/etc/ovs-vswitchd.conf"
+vsctl="/usr/bin/ovs-vsctl"
 
 if __name__ == "__main__":
     raise Exception("This script is a plugin for xsconsole and cannot run independently")
@@ -78,10 +77,9 @@ class VSwitchService:
 class VSwitchConfig:
 
     @staticmethod
-    def Get(key):
+    def Get(action):
         try:
-            output = ShellPipe([cfg_mod, "-vANY:console:emer", "-F", 
-                    vswitchd_cfg_filename, "-q", key]).Stdout()
+            output = ShellPipe([vsctl, "-vANY:console:emer", action]).Stdout()
         except StandardError, e:
             XSLogError("config retrieval error: " + str(e))
             return "<unknown>"
@@ -285,7 +283,7 @@ class XSFeatureVSwitch:
         if dbController == "":
             dbController = Lang("<None>")
         inPane.AddStatusField(Lang("Controller (config)", 20), dbController)
-        controller = VSwitchConfig.Get("mgmt.controller")
+        controller = VSwitchConfig.Get("get-controller")
         if controller == "":
             controller = Lang("<None>")
         elif controller[0:4] == "ssl:":
-- 
1.6.5.5





More information about the dev mailing list