virt-manager: Don't allow an empty string for a network name

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@suse.com>

Message-Id: <551D664702000091000F42E8@prv-mh.provo.novell.com>
This commit is contained in:
Charles Arnold 2015-04-02 15:54:47 -06:00 committed by Cole Robinson
parent ce74cd7726
commit 20fe287341
3 changed files with 7 additions and 3 deletions

View File

@ -1743,7 +1743,10 @@ class vmmCreate(vmmGObjectUI):
# HV + Arch selection
name = self.get_config_name()
if name != self.guest.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.")

View File

@ -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:

View File

@ -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