X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=xenserver%2Fusr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py;h=93532c8477110bfcb045d7517f649b97b8afc2c5;hb=4f256587f1ea96781b75e6e48fcb4a631cf77699;hp=8adb93609d4c88507a600ca0db32f9da7a6e228d;hpb=378a58b90ceef380e03a0e5863b4f2c3aa0fe32a;p=sliver-openvswitch.git diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 8adb93609..93532c847 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -1,11 +1,18 @@ -# Copyright (c) Citrix Systems 2008. All rights reserved. -# xsconsole is proprietary software. +# Copyright (c) 2007-2011 Citrix Systems Inc. +# Copyright (c) 2009,2010,2011 Nicira Networks. # -# Xen, the Xen logo, XenCenter, XenMotion are trademarks or registered -# trademarks of Citrix Systems, Inc., in the United States and other -# countries. - -# Copyright (c) 2009, 2010 Nicira Networks. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from XSConsoleLog import * @@ -79,7 +86,7 @@ class VSwitchConfig: @staticmethod def Get(action): try: - arg = [vsctl, "-vANY:console:emer"] + action.split() + arg = [vsctl, "--timeout=30", "-vANY:console:off"] + action.split() output = ShellPipe(arg).Stdout() except StandardError, e: XSLogError("config retrieval error: " + str(e)) @@ -99,9 +106,10 @@ 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", "") + self.controller = pool.get("vswitch_controller", "") else: self.controller = "" @@ -114,8 +122,6 @@ class VSwitchControllerDialogue(Dialogue): lambda: self.syncController()), # ChoiceDef(Lang("Restart ovs-vswitchd"), # lambda: self.restartService("vswitch")), -# ChoiceDef(Lang("Restart ovs-brcompatd"), -# lambda: self.restartService("vswitch-brcompatd")) ] self.menu = Menu(self, None, Lang("Configure Open vSwitch"), choiceDefs) @@ -222,25 +228,24 @@ 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 + session.xenapi.pool.set_vswitch_controller(value) Data.Inst().Update() def _updateActiveServers(self, session): @@ -265,6 +270,7 @@ class XSFeatureVSwitch: @classmethod def StatusUpdateHandler(cls, inPane): data = Data.Inst() + xs_version = data.host.software_version.product_version('') inPane.AddTitleField(Lang("Open vSwitch")) @@ -277,15 +283,14 @@ class XSFeatureVSwitch: pool = data.GetPoolForThisHost() if pool is not None: - dbController = pool.get("other_config", {}).get("vSwitchController", "") + dbController = pool.get("vswitch_controller", "") else: dbController = "" if dbController == "": dbController = Lang("") inPane.AddStatusField(Lang("Controller (config)", 20), dbController) - controller = VSwitchConfig.Get("get Open_vSwitch . managers") - controller = controller.strip('[]"') + controller = VSwitchConfig.Get("get-manager") if controller == "": controller = Lang("") @@ -299,12 +304,6 @@ class XSFeatureVSwitch: inPane.AddStatusField(Lang("ovsdb-server status", 20), VSwitchService.Inst("openvswitch", "ovsdb-server").status()) - # Only XenServer 5.5.0 runs ovs-brcompatd - xs_version = data.host.software_version.product_version('') - if (xs_version == "5.5.0"): - inPane.AddStatusField(Lang("ovs-brcompatd status", 20), - VSwitchService.Inst("openvswitch", "ovs-brcompatd").status()) - inPane.AddKeyHelpField( { Lang("") : Lang("Reconfigure"), Lang("") : Lang("Refresh") @@ -327,5 +326,6 @@ class XSFeatureVSwitch: } ) -# 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()