From 0ebd7377c771ade4f929d0a4306b83e85853bfc4 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 30 Sep 2009 12:32:17 -0700 Subject: [PATCH] xenserver: Update xsconsole plugin to use first class datamodel field. Part of a patch from Ian Campbell . --- ...xsconsole_plugins-base_XSFeatureVSwitch.py | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 31a48c37d..ed3e033f1 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -102,7 +102,7 @@ class VSwitchControllerDialogue(Dialogue): self.hostsUpdated = 0 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 = "" @@ -223,25 +223,21 @@ 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)) # 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 == None 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", []) 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) + session.xenapi.pool.set_vswitch_controller(value) Data.Inst().Update() def _updateActiveServers(self, session): @@ -278,7 +274,7 @@ class XSFeatureVSwitch: pool = data.GetPoolForThisHost() if pool is not None: - dbController = pool.get("other_config", {}).get("vSwitchController", "") + dbController = pool.get("vswitch_controller", "") else: dbController = "" @@ -320,5 +316,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/ovs-vswitchd.pid'): + XSFeatureVSwitch().Register() -- 2.47.0