[Libvirt-cim] [PATCH] [Test](#4)Testcase to check for duplicate UUID
Deepti B Kalakeri
deeptik at linux.vnet.ibm.com
Wed Aug 26 11:04:46 UTC 2009
Sorry for making you rework so much..I think I have very minor comments
here..
Yogananth Subramanian wrote:
> # HG changeset patch
> # User anantyog at linux.vnet.ibm.com
> # Date 1251280598 25200
> # Node ID 311bad73905dfdb1299bb0eab902a54b332fc094
> # Parent 3c09a49a30f4bc1e6544736612508d3f99308083
> [Test](#4)Testcase to check for duplicate UUID
> Hello everyone,
> I have rewirtten the testcase to handle provider version less then 915.
> For provider version less then 915, the testcase just exits and rewrote the
> exception handling to handle exceptions of variable length.
>
> Thx
> Yogi
>
> diff -r 3c09a49a30f4 -r 311bad73905d suites/libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
> +++ b/suites/libvirt-cim/cimtest/VSSD/06_duplicate_uuid.py Wed Aug 26 02:56:38 2009 -0700
> @@ -0,0 +1,127 @@
> +#!/usr/bin/python
> +#
> +# Copyright 2009 IBM Corp.
> +#
> +# Authors:
> +# Yogananth Subramanian <anantyog at 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
> +#
> +
> +import sys
> +import time
> +from XenKvmLib import vsms
> +from XenKvmLib import vxml
> +from CimTest.Globals import logger
> +from CimTest.ReturnCodes import PASS, FAIL, SKIP
> +from XenKvmLib.const import do_main
> +from XenKvmLib.classes import get_typed_class, inst_to_mof
> +from XenKvmLib.enumclass import GetInstance
> +from XenKvmLib.const import get_provider_version
> +
> +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
> +default_dom = 'uuid_domain'
> +test_dom = 'test_domain'
> +nmac = '99:aa:bb:cc:ee:ff'
> +duplicate_uuid_support = 915
> +err_desc = "'uuid_domain' is already defined"
> +
> +def get_vssd(ip, virt, 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, True)
> +
> + except Exception, details:
> + logger.error(details)
> + return FAIL, inst
> +
> + if inst is None:
> + return FAIL, inst
> +
> + return PASS, inst
> +
> + at do_main(sup_types)
> +def main():
> + options = main.options
> + virt = options.virt
> + server = options.ip
> +
> + curr_cim_rev, changeset = get_provider_version(virt, server)
> + if curr_cim_rev < duplicate_uuid_support:
> + logger.info("Need provider version 915 or greater to run testcase")
>
Instead of hardcoding 915 in the error message can you pass
duplicate_uuid_support instead.
> + return SKIP
> +
> + service = vsms.get_vsms_class(options.virt)(options.ip)
> +
> + sxml = None
> + 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
> +
> + try:
> + status, inst = get_vssd(options.ip, options.virt, default_dom)
> + if status != PASS:
> + raise Exception("Failed to get the VSSD instance for %s" %
> + default_dom)
> +
> + uuid_defaultdom = inst['UUID']
> +
> + sxml = vxml.get_class(options.virt)(test_dom, mac=nmac)
> + ret = sxml.cim_define(options.ip)
> + if not ret:
> + raise Exception("Failed to define the dom: %s" % test_dom)
> +
> + status, inst = get_vssd(options.ip, options.virt, test_dom)
> + if status != PASS:
> + raise Exception("Failed to get the VSSD instance for %s" %
> + test_dom)
> +
> + inst['UUID'] = uuid_defaultdom
> + vssd = inst_to_mof(inst)
> + ret = service.ModifySystemSettings(SystemSettings=vssd)
> + if ret[0] == 0:
> + raise Exception("Was able to assign duplicate UUID to domain %s"
> + % test_dom)
> +
> + except Exception, details:
> + if details[-1].find(err_desc) >= 0:
> + logger.info('Got expected error desc %s', details[-1])
> + status = PASS
> + else:
> + logger.error(details)
> + status = FAIL
>
The else part has 5 spaces instead of 4.
Can you change the exception block to something like the one below after
importing from pywbem import CIMError:
except CIMError, (err_no, err_desc):
if err_desc.find("'uuid_domain' is already defined") >= 0:
logger.info('Got expected error desc')
status = PASS
except Exception, details:
logger.error("Exception %s", details)
status = FAIL
> +
> + if sxml != None:
> + sxml.undefine(options.ip)
> + cxml.undefine(options.ip)
> + return status
> +
> +if __name__ == "__main__":
> + sys.exit(main())
> +
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list