Yogananth Subramanian wrote:
# HG changeset patch
# User anantyog(a)in.ibm.com
# Date 1249986809 25200
# Node ID 87e175898a31e7866d67349e349fad34f8d0bb01
# Parent 12fd8bac01f25251dbfb64dd5e764f533108964b
[Test]Testcase to check for duplicate UUID
Steps:
1) Define 2 domains,'default' and 'test', both with random UUID
2) Reset the uuid of the second domain, 'test', to the uuid of the
first domain, using ModifySystemSettings
3) The verify the assigned uuid
The test does not behave as expected, either at step 2 when ModifySystemSetting
is called, an error should be returned for the duplicate UUID or at step 3
when we check for the assigned UUID, it should be different from the UUID of
the first domain, neither of this happens. I have filed the bug 00016
regarding this issue.
Signed-off-by: Yogananth Subramanian <anantyog(a)linux.vnet.ibm.com>
diff -r 12fd8bac01f2 -r 87e175898a31 suites/libvirt-cim/cimtest/VSSD/06_dupicate_uuid.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/suites/libvirt-cim/cimtest/VSSD/06_dupicate_uuid.py Tue Aug 11 03:33:29 2009 -0700
@@ -0,0 +1,115 @@
+#!/usr/bin/python
+#
+# Copyright 2009 IBM Corp.
+#
+# Authors:
+# Yogananth Subramanian <anantyog(a)linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#Steps:
+#1) Define 2 domains,'default' and 'test', both with random UUID
+#2) Reset the uuid of the second domain, 'test', to the uuid of the
+# first domain, using ModifySystemSettings
+#3) The verify the assigned uuid
+#
+
+import sys
+import time
+from XenKvmLib import vsms
+from XenKvmLib import vxml
+from CimTest.Globals import logger
+from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.const import do_main
+from XenKvmLib.classes import get_typed_class, inst_to_mof
+from XenKvmLib.enumclass import GetInstance
+
+sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
+default_dom = 'uuid_domain'
+test_dom = 'test_domain'
+nmac = '99:aa:bb:cc:ee:ff'
+bug_libvirt = "00016"
+
+def get_vssd(ip, virt, get_cim_inst, default_dom):
+ cn = get_typed_class(virt, "VirtualSystemSettingData")
+ inst = None
+
+ try:
+ if virt == "XenFV":
+ virt = "Xen"
+
+ key_list = {"InstanceID" : "%s:%s" % (virt, default_dom) }
+ inst = GetInstance(ip, cn, key_list, get_cim_inst)
+
+ except Exception, details:
+ logger.error(details)
+ return FAIL, inst
+
+ if inst is None:
+ return FAIL, inst
+
+ return PASS, inst
+
+@do_main(sup_types)
+def main():
+ options = main.options
+
+ service = vsms.get_vsms_class(options.virt)(options.ip)
+
+ cxml = vxml.get_class(options.virt)(default_dom)
+ ret = cxml.cim_define(options.ip)
+ if not ret:
+ logger.error("Failed to define the dom: %s", default_dom)
+ return FAIL
you could move the cim_define() inside the try block.
+
+ try:
+ status, inst = get_vssd(options.ip, options.virt, True,default_dom)
+ if status != PASS:
+ raise Exception("Failed to get the VSSD instance for %s"%
+ default_dom)
+
+ uuid = inst['UUID']
+
+ sxml = vxml.get_class(options.virt)(test_dom, uuid=uuid, mac=nmac)
+ ret = sxml.cim_define(options.ip)
Since you are using the UUID of the first domain while defining the
second domain the test fails here with the following error:
ERROR - (1, u"CIM_ERR_FAILED: Failed to define domain: operation failed:
domain 'uuid_domain' is already defined with uuid
700ef91b-4eb9-4290-8c46-da67d860bb46")
InvokeMethod(ModifySystemSettings): CIM_ERR_FAILED: Failed to define
domain: operation failed: domain 'uuid_domain' is already defined with
uuid 700ef91b-4eb9-4290-8c46-da67d860bb46
You, dont need to assign the uuid here while defining the domain,lets
allow the providers to assign the fresh uuid to the second domain first.
+ if not ret:
+ raise Exception("Failed to define the dom: %s"% test_dom)
need a space before %
+
+ status, inst = get_vssd(options.ip, options.virt, True,test_dom)
+ if status != PASS:
+ raise Exception("Failed to get the VSSD instance for %s"%
need a space before %
+ test_dom)
+
+ inst['UUID'] = uuid
+ vssd = inst_to_mof(inst)
+ ret = service.ModifySystemSettings(SystemSettings=vssd)
The ModifySystemSettings() was able to give me the following appropriate
error when I tried modifying the second domains UUID with the first ones
UUID.
Heres the exception I got which needs to be verified:
"InvokeMethod(ModifySystemSettings): CIM_ERR_FAILED: Failed to define
domain: operation failed: domain 'uuid_domain' is already defined with
uuid e9db9af2-3281-4905-b81d-35144daaefb9"
I did not see any problem with provider not being able to report the
duplicate UUID.
+
+ if inst['UUID'] == uuid and ret[0]== 0 :
+ sxml.undefine(options.ip)
+ logger.error("The domains %s and %s have the same UUID",
+ default_dom,test_dom)
+ status = XFAIL_RC(bug_libvirt)
+
+ except Exception, details:
+ logger.error(details)
+ status = FAIL
You need to capture the exception "InvokeMethod(ModifySystemSettings):
CIM_ERR_FAILED: Failed to define domain: operation failed: domain
'uuid_domain' is already defined with uuid
e9db9af2-3281-4905-b81d-35144daaefb9" and validate it here in the except
block.
You could do something like:
except Exception, (rc, desc):
exp_desc = "Failed to define domain: operation failed: domain
'uuid_domain' is already defined with uuid"
status = FAIL
if rc == pywbem.CIM_ERR_FAILED and exp_desc in desc:
status = PASS
logger.error("Got the expected exception from ModifySystemSettings")
+
+ sxml.undefine(options.ip)
+ cxml.undefine(options.ip)
+ return status
+
+if __name__ == "__main__":
+ sys.exit(main())
+
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik(a)linux.vnet.ibm.com