[Libvirt-cim] [PATCH] #2 [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService

Chip Vincent cvincent at linux.vnet.ibm.com
Wed Oct 12 14:45:43 UTC 2011


Using tog-pegasus-2.11.0-1, I see the following:

--------------------------------------------------------------------
VirtualSystemManagementService - 31_unset_netrasd.py: FAIL
ERROR 	- Current 'virtio' and expected '' ResourceSubType differ
--------------------------------------------------------------------

Does this mean my pegasus version has the bug? If so, should we check 
the CIMOM version as part of this test?

On 09/28/2011 09:41 AM, Eduardo Lima (Etrunko) wrote:
>   suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py |  193 ++++++++++
>   1 files changed, 193 insertions(+), 0 deletions(-)
>
>
> # HG changeset patch
> # User Eduardo Lima (Etrunko)<eblima at br.ibm.com>
> # Date 1317153134 10800
> # Node ID eac4909ac68adc28cad9cb6389ea93a053b23aec
> # Parent  83921669cae17a4f0a18bb440ebec01de1a3e691
> [TEST] 31_unset_netrasd.py: new test for VirtualSystemManagementService
>
> This test case covers a recent bug found in Pegasus which makes impossible for
> libvirt-cim to set a property values if the value is an empty string via a
> ModifyResourceSettings call.
>
> Link to Pegasus bug follows:
>    http://bugzilla.openpegasus.org/show_bug.cgi?id=9053
>
> Signed-off-by: Eduardo Lima (Etrunko)<eblima at br.ibm.com>
>
> diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py
> new file mode 100755
> --- /dev/null
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/31_unset_netrasd.py
> @@ -0,0 +1,193 @@
> +#!/usr/bin/env python
> +
> +#
> +# Copyright 2011 IBM Corp.
> +#
> +# Authors:
> +#   Eduardo Lima (Etrunko)<eblima at br.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
> +#
> +
> +#
> +# ModifyResourceSettings call to set/unset NetRASD ResourceType property
> +#
> +
> +import sys
> +import pywbem
> +
> +from CimTest.ReturnCodes import PASS, FAIL
> +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS
> +from XenKvmLib.const import do_main
> +from XenKvmLib.classes import get_typed_class
> +from XenKvmLib.vxml import get_class
> +
> +supported = ['Xen', 'KVM', 'XenFV', 'LXC']
> +domain = None
> +
> +class CIMDomain(object):
> +
> +    def __init__(self, name, virt, server):
> +        self.name = name
> +        self.server = server
> +        self._domain = get_class(virt)(name)
> +    #__init__
> +
> +    def define(self):
> +        return self._domain.cim_define(self.server)
> +    # define
> +
> +    def undefine(self):
> +        return self._domain.undefine(self.server)
> +    # undefine
> +
> +    def destroy(self):
> +        return self._domain.cim_destroy(self.server)
> +    #destroy
> +# CIMDomain
> +
> +
> +def resource_settings(inst, virt, resource_subtype):
> +    return """
> +instance of %s {
> +    InstanceID="%s";
> +    ResourceType=%d;
> +    Address="%s";
> +    VirtualQuantityUnits="%s";
> +    NetworkType="%s";
> +    NetworkName="%s";
> +    ResourceSubType="%s";
> +};""" % (get_typed_class(virt, "NetResourceAllocationSettingData"),
> +        inst["InstanceID"],
> +        inst["ResourceType"],
> +        inst["Address"],
> +        inst["VirtualQuantityUnits"],
> +        inst["NetworkType"],
> +        inst["NetworkName"],
> +        resource_subtype)
> +# resource_settings()
> +
> +
> + at do_main(supported)
> +def main():
> +    # init
> +    options = main.options
> +    server = options.ip
> +    virt = options.virt
> +
> +    server_url = "http://%s" % server
> +    cim = pywbem.WBEMConnection(server_url, (CIM_USER, CIM_PASS), CIM_NS)
> +
> +    _class = get_typed_class(virt, "VirtualSystemManagementService")
> +    sys_mgmt_service = cim.EnumerateInstanceNames(_class)[0]
> +
> +    # Create new domain
> +    global domain
> +    domain = CIMDomain("cimtest_unset_netrasd", virt, server)
> +    if not domain.define():
> +        logger.error("Error defining test domain")
> +        return FAIL
> +
> +    # ein KVM_ComputerSystem
> +    _class = get_typed_class(virt, "ComputerSystem")
> +    computer_system_names = [i for i in cim.EnumerateInstanceNames(_class) if i["Name"] == domain.name]
> +
> +    logger.info("ComputerSystem Names\n%s", computer_system_names)
> +
> +    if not computer_system_names:
> +        logger.info("Host has no domains defined")
> +        return SKIP
> +
> +    # ain -ac KVM_SystemDevice -arc KVM_NetworkPort<KVM_ComputerSytem Name>
> +    a_class = get_typed_class(virt, "SystemDevice")
> +    r_class = get_typed_class(virt, "NetworkPort")
> +    network_port_names = []
> +
> +    for inst_name in computer_system_names:
> +        assoc_names = cim.AssociatorNames(inst_name, AssocClass=a_class, ResultClass=r_class)
> +        network_port_names.extend(assoc_names)
> +
> +    logger.info("NetworkPort Names\n%s", network_port_names)
> +
> +    if not network_port_names:
> +        logger.info("No NetworkPort instances returned")
> +        return XFAIL
> +
> +    # ai -arc KVM_NetResourceAllocationSettingData<KVM_NetworkPort Name>
> +    r_class = get_typed_class(virt, "NetResourceAllocationSettingData")
> +    net_rasd_names = []
> +
> +    for inst_name in network_port_names:
> +        assoc_names = cim.AssociatorNames(inst_name, ResultClass=r_class)
> +        net_rasd_names.extend(assoc_names)
> +
> +    logger.info("NetRASD names\n%s", net_rasd_names)
> +
> +    if not net_rasd_names:
> +        logger.info("No NetRASD instances returned")
> +        return XFAIL
> +
> +    for subtype in ["virtio", "",]:
> +        logger.info("Setting ResourceSubType to '%s'", subtype)
> +
> +        modified_net_rasd_names = []
> +
> +        for inst_name in net_rasd_names:
> +            # Get current instance data
> +            inst = cim.GetInstance(inst_name)
> +            cur_id = inst["InstanceID"]
> +            cur_subtype = inst["ResourceSubType"]
> +            logger.info("Current ResourceSubType of %s: '%s'", cur_id, cur_subtype)
> +
> +            # Invoke ModifyResourceSettings
> +            val = resource_settings(inst, virt, subtype)
> +            ret = cim.InvokeMethod("ModifyResourceSettings", sys_mgmt_service, **{"ResourceSettings": [val,],})
> +
> +            if ret[0]:
> +                logger.error("ERROR Setting ResourceSubtype to '%s': %s", subtype, ret)
> +                return FAIL
> +
> +            modified_net_rasd_names.extend(ret[1]["ResultingResourceSettings"])
> +
> +            # Get modified instance data
> +            inst = cim.GetInstance(ret[1]["ResultingResourceSettings"][0])
> +            new_id = inst["InstanceID"]
> +            new_subtype = inst["ResourceSubType"]
> +
> +            logger.info("Modified ResourceSubType of %s: '%s'", new_id, new_subtype)
> +
> +            if cur_id != new_id:
> +                logger.error("Current '%s' and new '%s' InstanceID differ", cur_id, new_id)
> +                return FAIL
> +
> +            if new_subtype != subtype:
> +                logger.error("Current '%s' and expected '%s' ResourceSubType differ", new_subtype, subtype)
> +                return FAIL
> +        # for inst_name...
> +
> +        net_rasd_names = modified_net_rasd_names
> +    #for subtype...
> +
> +    return PASS
> +#main()
> +
> +if __name__ == "__main__":
> +    ret = main()
> +
> +    if domain:
> +        domain.destroy()
> +        domain.undefine()
> +
> +    sys.exit(ret)
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>

-- 
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list