From: Justin Pettit Date: Thu, 25 Jun 2009 04:52:34 +0000 (-0700) Subject: xenserver: Validate controller IP address in xsconsole X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dc6fca88bf43eceda6fe62c2f70eb5ec92ddd46;p=openvswitch xenserver: Validate controller IP address in xsconsole When a switch is using in-band control, the controller must be specified in dotted quad format, since DNS names cannot be resolved until a connection to the controller has been established. This commit validates the user input in the xsconsole plugin. --- diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 95020ad4..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" @@ -162,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)