virtinst: Drop UUID validation

It's redundant as libvirt will give us these checks already, and we
aren't even testing it
This commit is contained in:
Cole Robinson 2017-12-14 12:02:36 -05:00
parent 5ac933e98a
commit 8b4befae60
6 changed files with 7 additions and 37 deletions

View File

@ -21,6 +21,7 @@
import difflib
import logging
import os
import re
import sys
import libvirt
@ -81,11 +82,8 @@ def get_domain_and_guest(conn, domstr):
except ValueError:
isint = False
try:
virtinst.util.validate_uuid(domstr)
isuuid = True
except ValueError:
isuuid = False
uuidre = "[a-fA-F0-9]{8}[-]([a-fA-F0-9]{4}[-]){3}[a-fA-F0-9]{12}$"
isuuid = bool(re.match(uuidre, domstr))
try:
if isint:

View File

@ -113,14 +113,6 @@ class Cloner(object):
doc="Name to use for the new guest clone.")
def set_clone_uuid(self, uuid):
try:
util.validate_uuid(uuid)
except ValueError as e:
raise ValueError(_("Invalid uuid for new guest: %s") % e)
if util.vm_uuid_collision(self.conn, uuid):
raise ValueError(_("UUID '%s' is in use by another guest.") %
uuid)
self._clone_uuid = uuid
def get_clone_uuid(self):
return self._clone_uuid

View File

@ -190,9 +190,7 @@ class Guest(XMLBuilder):
if self._random_uuid is None:
self._random_uuid = util.generate_uuid(self.conn)
return self._random_uuid
uuid = XMLProperty("./uuid",
validate_cb=lambda s, v: util.validate_uuid(v),
default_cb=_get_default_uuid)
uuid = XMLProperty("./uuid", default_cb=_get_default_uuid)
id = XMLProperty("./@id", is_int=True)

View File

@ -240,9 +240,7 @@ class Network(XMLBuilder):
ipv6 = XMLProperty("./@ipv6", is_yesno=True)
name = XMLProperty("./name", validate_cb=_validate_name)
uuid = XMLProperty("./uuid",
validate_cb=lambda s, v: util.validate_uuid(v),
default_cb=_get_default_uuid)
uuid = XMLProperty("./uuid", default_cb=_get_default_uuid)
virtualport_type = XMLProperty("./virtualport/@type")

View File

@ -409,9 +409,7 @@ class StoragePool(_StorageObject):
type = XMLProperty("./@type",
doc=_("Storage device type the pool will represent."))
uuid = XMLProperty("./uuid",
validate_cb=lambda s, v: util.validate_uuid(v),
default_cb=_get_default_uuid)
uuid = XMLProperty("./uuid", default_cb=_get_default_uuid)
capacity = XMLProperty("./capacity", is_int=True)
allocation = XMLProperty("./allocation", is_int=True)

View File

@ -23,7 +23,6 @@ Classes for building and installing with libvirt <sysinfo> XML
import datetime
from .xmlbuilder import XMLBuilder, XMLProperty
from . import util
class SYSInfo(XMLBuilder):
@ -59,20 +58,7 @@ class SYSInfo(XMLBuilder):
bios_version = XMLProperty("./bios/entry[@name='version']")
bios_release = XMLProperty("./bios/entry[@name='release']")
def _validate_uuid(self, val):
try:
util.validate_uuid(val)
except ValueError:
raise ValueError(_("Invalid uuid for SMBios: %s") % val)
if util.vm_uuid_collision(self.conn, val):
raise ValueError(_("UUID '%s' is in use by another guest.") %
val)
return val
system_uuid = XMLProperty("./system/entry[@name='uuid']",
validate_cb=_validate_uuid)
system_uuid = XMLProperty("./system/entry[@name='uuid']")
system_manufacturer = XMLProperty("./system/entry[@name='manufacturer']")
system_product = XMLProperty("./system/entry[@name='product']")
system_version = XMLProperty("./system/entry[@name='version']")