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.
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"
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)