From 3dc6fca88bf43eceda6fe62c2f70eb5ec92ddd46 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Wed, 24 Jun 2009 21:52:34 -0700 Subject: [PATCH] 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. --- .../usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py b/xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py index 95020ad49..45231395d 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) -- 2.43.0