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 = ""
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):
pool = data.GetPoolForThisHost()
if pool is not None:
- dbController = pool.get("other_config", {}).get("vSwitchController", "")
+ dbController = pool.get("vswitch_controller", "")
else:
dbController = ""
}
)
-# 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()