diff --git a/virt-xml b/virt-xml index 750498b6c..b7d78fe2f 100755 --- a/virt-xml +++ b/virt-xml @@ -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: diff --git a/virtinst/cloner.py b/virtinst/cloner.py index 9be5485c4..c4030ddfd 100644 --- a/virtinst/cloner.py +++ b/virtinst/cloner.py @@ -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 diff --git a/virtinst/guest.py b/virtinst/guest.py index 44554d437..a787b499f 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -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) diff --git a/virtinst/network.py b/virtinst/network.py index 1cc71118c..271762b54 100644 --- a/virtinst/network.py +++ b/virtinst/network.py @@ -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") diff --git a/virtinst/storage.py b/virtinst/storage.py index 254e7ff60..1b3d2de6a 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -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) diff --git a/virtinst/sysinfo.py b/virtinst/sysinfo.py index c42aa4edd..de4ddfaa9 100644 --- a/virtinst/sysinfo.py +++ b/virtinst/sysinfo.py @@ -23,7 +23,6 @@ Classes for building and installing with libvirt 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']")