X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fusr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py;h=d2f6a6a3c7afa6760df33698a5cfa4ed847e3ef7;hb=aed133bf9bce8f35b666c3052907f525c803c83b;hp=6ecf4784f9d9cda8f5f279a638b318266a38a46d;hpb=a0bc29a541fc7dc6e20137d5558e2094d614e6ab;p=openvswitch diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 6ecf4784..d2f6a6a3 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -5,7 +5,7 @@ # trademarks of Citrix Systems, Inc., in the United States and other # countries. -# Copyright (c) 2009 Nicira Networks. +# Copyright (c) 2009, 2010 Nicira Networks. from XSConsoleLog import * @@ -79,7 +79,7 @@ class VSwitchConfig: @staticmethod def Get(action): try: - arg = [vsctl, "-vANY:console:emer"] + action.split() + arg = [vsctl, "--timeout=30", "-vANY:console:emer"] + action.split() output = ShellPipe(arg).Stdout() except StandardError, e: XSLogError("config retrieval error: " + str(e)) @@ -99,9 +99,13 @@ class VSwitchControllerDialogue(Dialogue): self.hostsInPool = 0 self.hostsUpdated = 0 + self.xs_version = data.host.software_version.product_version('') pool = data.GetPoolForThisHost() if pool is not None: - self.controller = pool.get("other_config", {}).get("vSwitchController", "") + if self.xs_version == "5.5.0": + self.controller = pool.get("other_config", {}).get("vSwitchController", "") + else: + self.controller = pool.get("vswitch_controller", "") else: self.controller = "" @@ -117,13 +121,13 @@ class VSwitchControllerDialogue(Dialogue): # ChoiceDef(Lang("Restart ovs-brcompatd"), # lambda: self.restartService("vswitch-brcompatd")) ] - self.menu = Menu(self, None, Lang("Configure vSwitch"), choiceDefs) + self.menu = Menu(self, None, Lang("Configure Open vSwitch"), choiceDefs) self.ChangeState("INITIAL") def BuildPane(self): pane = self.NewPane(DialoguePane(self.parent)) - pane.TitleSet(Lang("Configure vSwitch")) + pane.TitleSet(Lang("Configure Open vSwitch")) pane.AddBox() def ChangeState(self, inState): @@ -222,25 +226,30 @@ class VSwitchControllerDialogue(Dialogue): def SetController(self, ip): self.hostsInPool = 0 self.hostsUpdated = 0 - Task.Sync(lambda s: self._modifyPoolConfig(s, "vSwitchController", ip)) + Task.Sync(lambda s: self._modifyPoolConfig(s, ip or "")) # Should be done asynchronously, maybe with an external script? Task.Sync(lambda s: self._updateActiveServers(s)) - def _modifyPoolConfig(self, session, key, value): + def _modifyPoolConfig(self, session, value): """Modify pool configuration. - If value == None then delete key, otherwise set key to value.""" + If value == "" then delete configuration, otherwise set to value. + """ pools = session.xenapi.pool.get_all() # We assume there is only ever one pool... if len(pools) == 0: - log.error("No pool for host.") - raise XenAPIPlugin.Failure("NO_POOL_FOR_HOST", []) + XSLogFatal(Lang("No pool found for host.")) + return if len(pools) > 1: - log.error("More than one pool for host.") - raise XenAPIPlugin.Failure("MORE_THAN_ONE_POOL_FOR_HOST", []) - session.xenapi.pool.remove_from_other_config(pools[0], key) - if value != None: - session.xenapi.pool.add_to_other_config(pools[0], key, value) + XSLogFatal(Lang("More than one pool for host.")) + return + if self.xs_version == "5.5.0": + key = "vSwitchController" + session.xenapi.pool.remove_from_other_config(pools[0], key) + if value != None: + session.xenapi.pool.add_to_other_config(pools[0], key, value) + else: + session.xenapi.pool.set_vswitch_controller(value) Data.Inst().Update() def _updateActiveServers(self, session): @@ -251,13 +260,13 @@ class VSwitchControllerDialogue(Dialogue): for host in hosts: Layout.Inst().TransientBanner("Updating host %d out of %d" % (self.hostsUpdated + 1, self.hostsInPool)) - session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {}) + session.xenapi.host.call_plugin(host, "openvswitch-cfg-update", "update", {}) self.hostsUpdated = self.hostsUpdated + 1 def _updateThisServer(self, session): data = Data.Inst() host = data.host.opaqueref() - session.xenapi.host.call_plugin(host, "vswitch-cfg-update", "update", {}) + session.xenapi.host.call_plugin(host, "openvswitch-cfg-update", "update", {}) class XSFeatureVSwitch: @@ -265,19 +274,23 @@ class XSFeatureVSwitch: @classmethod def StatusUpdateHandler(cls, inPane): data = Data.Inst() + xs_version = data.host.software_version.product_version('') - inPane.AddTitleField(Lang("vSwitch")) + inPane.AddTitleField(Lang("Open vSwitch")) inPane.NewLine() inPane.AddStatusField(Lang("Version", 20), - VSwitchService.Inst("vswitch", "ovs-vswitchd").version()) + VSwitchService.Inst("openvswitch", "ovs-vswitchd").version()) inPane.NewLine() pool = data.GetPoolForThisHost() if pool is not None: - dbController = pool.get("other_config", {}).get("vSwitchController", "") + if (xs_version == "5.5.0"): + dbController = pool.get("other_config", {}).get("vSwitchController", "") + else: + dbController = pool.get("vswitch_controller", "") else: dbController = "" @@ -295,9 +308,14 @@ class XSFeatureVSwitch: inPane.NewLine() inPane.AddStatusField(Lang("ovs-vswitchd status", 20), - VSwitchService.Inst("vswitch", "ovs-vswitchd").status()) - inPane.AddStatusField(Lang("ovs-brcompatd status", 20), - VSwitchService.Inst("vswitch", "ovs-brcompatd").status()) + VSwitchService.Inst("openvswitch", "ovs-vswitchd").status()) + inPane.AddStatusField(Lang("ovsdb-server status", 20), + VSwitchService.Inst("openvswitch", "ovsdb-server").status()) + + # Only XenServer 5.5.0 runs ovs-brcompatd + if (xs_version == "5.5.0"): + inPane.AddStatusField(Lang("ovs-brcompatd status", 20), + VSwitchService.Inst("openvswitch", "ovs-brcompatd").status()) inPane.AddKeyHelpField( { Lang("") : Lang("Reconfigure"), @@ -315,11 +333,12 @@ class XSFeatureVSwitch: { 'menuname' : 'MENU_NETWORK', 'menupriority' : 800, - 'menutext' : Lang('vSwitch') , + 'menutext' : Lang('Open vSwitch') , 'statusupdatehandler' : self.StatusUpdateHandler, 'activatehandler' : self.ActivateHandler } ) -# Register this plugin when module is imported -XSFeatureVSwitch().Register() +# Register this plugin when module is imported, IFF vswitchd is running +if os.path.exists('/var/run/openvswitch/ovs-vswitchd.pid'): + XSFeatureVSwitch().Register()