X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fusr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py;h=dbd00a455f96a854d6562cb455cfa6e7a6895648;hb=eeb569bf8ccb5760154205d0ccdef56ff0e9c5a7;hp=8f4be3139b2a1d2b258f477b8f6b27152baf1db5;hpb=064af42167bf4fc9aaea2702d80ce08074b889c0;p=openvswitch diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 8f4be313..dbd00a45 100644 --- a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py +++ b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py @@ -12,6 +12,7 @@ log = logging.getLogger("vswitch-cfg-update") logging.basicConfig(filename="/var/log/vswitch-xsplugin.log", level=logging.DEBUG) import os +import socket import subprocess cfg_mod="/root/vswitch/bin/ovs-cfg-mod" @@ -31,6 +32,17 @@ class VSwitchService: if self.processname == None: self.processname = name + def version(self): + try: + output = ShellPipe(["service", self.name, "version"]).Stdout() + except StandardError, e: + log.error("version retrieval error: " + str(e)) + return "" + for line in output: + if self.processname in line: + return line.split()[-1] + return "" + def status(self): try: output = ShellPipe(["service", self.name, "status"]).Stdout() @@ -39,12 +51,12 @@ class VSwitchService: return "" if len(output) == 0: return "" - for l in output: - if self.processname not in l: + for line in output: + if self.processname not in line: continue - elif "running" in l: + elif "running" in line: return "Running" - elif "stop" in l: + elif "stop" in line: return "Stopped" else: return "" @@ -90,7 +102,11 @@ class VSwitchControllerDialogue(Dialogue): self.hostsInPool = 0 self.hostsUpdated = 0 - self.controller = data.GetPoolForThisHost().get("other_config", {}).get("vSwitchController", "") + pool = data.GetPoolForThisHost() + if pool is not None: + self.controller = pool.get("other_config", {}).get("vSwitchController", "") + else: + self.controller = "" choiceDefs = [ ChoiceDef(Lang("Set pool-wide controller"), @@ -158,6 +174,14 @@ class VSwitchControllerDialogue(Dialogue): inputValues = pane.GetFieldValues() self.controller = inputValues['address'] Layout.Inst().PopDialogue() + + # Make sure the controller is specified as a valid dotted quad + try: + socket.inet_aton(self.controller) + except socket.error: + Layout.Inst().PushDialogue(InfoDialogue(Lang("Please enter in dotted quad format"))) + return True + Layout.Inst().TransientBanner(Lang("Setting controller...")) try: self.SetController(self.controller) @@ -249,11 +273,17 @@ class XSFeatureVSwitch: inPane.NewLine() - versionStr = data.host.other_config({}).get("vSwitchVersion", "") - inPane.AddStatusField(Lang("Version", 20), versionStr) + inPane.AddStatusField(Lang("Version", 20), + VSwitchService.Inst("vswitch", "ovs-vswitchd").version()) inPane.NewLine() - dbController = data.GetPoolForThisHost().get("other_config", {}).get("vSwitchController", "") + + pool = data.GetPoolForThisHost() + if pool is not None: + dbController = pool.get("other_config", {}).get("vSwitchController", "") + else: + dbController = "" + if dbController == "": dbController = Lang("") inPane.AddStatusField(Lang("Controller (config)", 20), dbController)