]> xenbits.xensource.com Git - xen.git/commitdiff
xend: Fix name/uuid uniqueness checks.
authorKeir Fraser <keir@xensource.com>
Tue, 2 Oct 2007 09:01:10 +0000 (10:01 +0100)
committerKeir Fraser <keir@xensource.com>
Tue, 2 Oct 2007 09:01:10 +0000 (10:01 +0100)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tools/python/xen/xend/XendDomainInfo.py

index 6de4b2ff54a3b9dbd26347fe0631238164a39cf1..d341176899e3484957682a6bf2bec84ad7d1b6e8 100644 (file)
@@ -74,9 +74,15 @@ def create(config):
     @return: An up and running XendDomainInfo instance
     @raise VmError: Invalid configuration or failure to start.
     """
-
+    from xen.xend import XendDomain
+    domconfig = XendConfig.XendConfig(sxp_obj = config)
+    othervm = XendDomain.instance().domain_lookup_nr(domconfig["name_label"])
+    if othervm is None or othervm.domid is None:
+        othervm = XendDomain.instance().domain_lookup_nr(domconfig["uuid"])
+    if othervm is not None and othervm.domid is not None:
+        raise VmError("Domain '%s' already exists with ID '%d'" % (domconfig["name_label"], othervm.domid))
     log.debug("XendDomainInfo.create(%s)", scrub_password(config))
-    vm = XendDomainInfo(XendConfig.XendConfig(sxp_obj = config))
+    vm = XendDomainInfo(domconfig)
     try:
         vm.start()
     except: