X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=xenserver%2Fusr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py;h=45231395df1e0cf5b9368789da663de35f6f1cc7;hb=3c303e5fe1061b8715be018ae8e535cbc24303c9;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..45231395 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" @@ -90,7 +91,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 +163,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) @@ -253,7 +266,13 @@ class XSFeatureVSwitch: inPane.AddStatusField(Lang("Version", 20), versionStr) 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)