[virt-tools-list] [PATCH] virt-manager: Don't allow an empty string for a network name
Charles Arnold
carnold at suse.com
Thu Apr 2 21:54:47 UTC 2015
When starting the 'Create virtual network' wizard, you are allowed to proceed
without specifying a Network Name. An error only occurs after all else is
completed with the wizard. This patch stops the user from proceeding if a
network name has not been specified.
The check for an empty string is done in util.py which also effects storage
pool names and guest names neither of which should have empty strings.
Signed-off-by: Charles Arnold <carnold at suse.com>
diff --git a/virtManager/create.py b/virtManager/create.py
index b67af61..64d6eac 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -1743,7 +1743,10 @@ class vmmCreate(vmmGObjectUI):
# HV + Arch selection
name = self.get_config_name()
if name != self.guest.name:
- self.guest.name = name
+ try:
+ self.guest.name = name
+ except Exception, e:
+ return self.err.val_err(_("Invalid guest name"), str(e))
if self.is_default_storage():
logging.debug("User changed VM name and using default storage,"
"re-validating with new default storage path.")
diff --git a/virtManager/createpool.py b/virtManager/createpool.py
index 6641ce9..5d4558e 100644
--- a/virtManager/createpool.py
+++ b/virtManager/createpool.py
@@ -479,8 +479,6 @@ class vmmCreatePool(vmmGObjectUI):
def _validate_page_name(self, usepool=None):
name = self.get_config_name()
- if not name:
- return self.err.val_err(_("A name must be specified."))
try:
if usepool:
diff --git a/virtinst/util.py b/virtinst/util.py
index baf671c..099b501 100644
--- a/virtinst/util.py
+++ b/virtinst/util.py
@@ -143,6 +143,9 @@ def validate_name(name_type, val):
# Rather than try and match libvirt's regex, just forbid things we
# know don't work
forbid = [" "]
+ if not val:
+ raise ValueError(
+ _("A name must be specified for the %s") % name_type)
for c in forbid:
if c not in val:
continue
More information about the virt-tools-list
mailing list