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

View File

@ -113,14 +113,6 @@ class Cloner(object):
doc="Name to use for the new guest clone.") doc="Name to use for the new guest clone.")
def set_clone_uuid(self, uuid): 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 self._clone_uuid = uuid
def get_clone_uuid(self): def get_clone_uuid(self):
return self._clone_uuid return self._clone_uuid

View File

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

View File

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

View File

@ -409,9 +409,7 @@ class StoragePool(_StorageObject):
type = XMLProperty("./@type", type = XMLProperty("./@type",
doc=_("Storage device type the pool will represent.")) doc=_("Storage device type the pool will represent."))
uuid = XMLProperty("./uuid", uuid = XMLProperty("./uuid", default_cb=_get_default_uuid)
validate_cb=lambda s, v: util.validate_uuid(v),
default_cb=_get_default_uuid)
capacity = XMLProperty("./capacity", is_int=True) capacity = XMLProperty("./capacity", is_int=True)
allocation = XMLProperty("./allocation", 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 import datetime
from .xmlbuilder import XMLBuilder, XMLProperty from .xmlbuilder import XMLBuilder, XMLProperty
from . import util
class SYSInfo(XMLBuilder): class SYSInfo(XMLBuilder):
@ -59,20 +58,7 @@ class SYSInfo(XMLBuilder):
bios_version = XMLProperty("./bios/entry[@name='version']") bios_version = XMLProperty("./bios/entry[@name='version']")
bios_release = XMLProperty("./bios/entry[@name='release']") bios_release = XMLProperty("./bios/entry[@name='release']")
system_uuid = XMLProperty("./system/entry[@name='uuid']")
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_manufacturer = XMLProperty("./system/entry[@name='manufacturer']") system_manufacturer = XMLProperty("./system/entry[@name='manufacturer']")
system_product = XMLProperty("./system/entry[@name='product']") system_product = XMLProperty("./system/entry[@name='product']")
system_version = XMLProperty("./system/entry[@name='version']") system_version = XMLProperty("./system/entry[@name='version']")