<br><font size=2 face="sans-serif">+1 for me.</font>
<br>
<br><font size=2 face="sans-serif">Best,<br>
Regards<br>
<br>
Daisy (Ô˹úÁ«)<br>
VSM Team, China Systems & Technology Labs (CSTL)<br>
E-mail: yunguol@cn.ibm.com<br>
TEL: (86)-21-60922403<br>
Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203<br>
</font>
<br>
<br><tt><font size=2>libvirt-cim-bounces@redhat.com wrote on 2008-08-09
00:25:22:<br>
<br>
> # HG changeset patch<br>
> # User Kaitlin Rupert <karupert@us.ibm.com><br>
> # Date 1216686405 25200<br>
> # Node ID adf7be19f36383916980d55d138761244cb3e389<br>
> # Parent  76bf5dc66e914b68807882983a827116909338b4<br>
> [TEST] #2 Add VSMS 10_referenced_config.py.<br>
> <br>
> This test creates a guest using default RASDS.  Then another
guest <br>
> is defined using a reference of the first guest an the value for the<br>
> ReferencedConfiguration parameter.  This second guest is created
<br>
> with an additional network interface.<br>
> <br>
> The test verifies that the second guest is defined properly.  It
<br>
> also verifies that the second guest has 2 network interfaces: one
<br>
> with a mac address that matches that of the first guest and one with<br>
> a different mac address.<br>
> <br>
> This test current fails on LXC because the test suite doesn't pass
a<br>
> console device to the DefineSystem().  Will fix this in a follow
up patch.<br>
> <br>
> Updates:<br>
>   -Create a network pool and then destroy the pool when test
is complete.<br>
>   -Use VSSD ref instead of CS ref<br>
> <br>
> Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com><br>
> <br>
> diff -r 76bf5dc66e91 -r adf7be19f363 suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/12_referenced_config.py<br>
> --- /dev/null   Thu Jan 01 00:00:00 1970 +0000<br>
> +++ b/suites/libvirt-<br>
> cim/cimtest/VirtualSystemManagementService/12_referenced_config.py
 <br>
> Mon Jul 21 17:26:45 2008 -0700<br>
> @@ -0,0 +1,175 @@<br>
> +#!/usr/bin/python<br>
> +#<br>
> +# Copyright 2008 IBM Corp.<br>
> +#<br>
> +# Authors:<br>
> +#    Kaitlin Rupert <karupert@us.ibm.com><br>
> +#<br>
> +# This library is free software; you can redistribute it and/or<br>
> +# modify it under the terms of the GNU General Public<br>
> +# License as published by the Free Software Foundation; either<br>
> +# version 2.1 of the License, or (at your option) any later version.<br>
> +#<br>
> +# This library is distributed in the hope that it will be useful,<br>
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
the GNU<br>
> +# General Public License for more details.<br>
> +#<br>
> +# You should have received a copy of the GNU General Public<br>
> +# License along with this library; if not, write to the Free Software<br>
> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 USA<br>
> +#<br>
> +<br>
> +import sys<br>
> +import pywbem<br>
> +from XenKvmLib.common_util import create_using_definesystem, \<br>
> +                    
             call_request_state_change,
\<br>
> +                    
             poll_for_state_change,
get_cs_instance, \<br>
> +                    
             create_netpool_conf, destroy_netpool<br>
> +from XenKvmLib import vsms<br>
> +from VirtLib import utils <br>
> +from CimTest.Globals import logger, do_main<br>
> +from CimTest.ReturnCodes import FAIL, PASS<br>
> +from XenKvmLib.test_doms import destroy_and_undefine_domain <br>
> +from XenKvmLib.classes import get_typed_class<br>
> +from XenKvmLib.assoc import AssociatorNames<br>
> +from XenKvmLib.test_xml import dumpxml<br>
> +<br>
> +sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']<br>
> +test_dom = 'rstest_domain'<br>
> +test_dom2 = 'rstest_domain2'<br>
> +<br>
> +mac = "aa:aa:aa:00:00:00"<br>
> +<br>
> +REQUESTED_STATE = 2<br>
> +TIME = "00000000000000.000000:000"<br>
> +<br>
> +def setup_first_guest(ip, virt):<br>
> +    status = create_using_definesystem(test_dom, ip, virt=virt)<br>
> +    if status != PASS:<br>
> +        logger.error("Unable to define %s
using DefineSystem()" % test_dom)<br>
> +        return FAIL<br>
> +<br>
> +    rc = call_request_state_change(test_dom, ip, REQUESTED_STATE,
TIME, virt)<br>
> +    if rc != 0:<br>
> +        logger.error("Unable to start %s"
% test_dom)<br>
> +        return FAIL<br>
> +<br>
> +    status, cs = poll_for_state_change(ip, virt, test_dom,
REQUESTED_STATE)<br>
> +    if status != PASS:<br>
> +        logger.error("Unable to start %s"
% test_dom)<br>
> +        return FAIL<br>
> +<br>
> +    return PASS<br>
> +<br>
> +def get_vssd_ref(ip, virt):<br>
> +    rc, cs = get_cs_instance(test_dom, ip, virt)<br>
> +    if rc != 0:<br>
> +        return None<br>
> +<br>
> +    cn = "ComputerSystem"<br>
> +    ccn = get_typed_class(virt, cn)<br>
> +    vssd = AssociatorNames(ip, 'SettingsDefineState', cn,
virt=virt,<br>
> +                    
      Name = test_dom, CreationClassName = ccn)<br>
> +<br>
> +    if len(vssd) != 1:<br>
> +        logger.error("Returned %i vssd insts
for '%s'", len(vssd), test_dom)<br>
> +        return None<br>
> +<br>
> +    return vssd[0]<br>
> +<br>
> +def get_vssd_rasd(virt):<br>
> +    vssd, def_rasd = vsms.default_vssd_rasd_str(dom_name=test_dom2,<br>
> +                    
                     
     net_type='network',<br>
> +                    
                     
     net_mac=mac, virt=virt)<br>
> +<br>
> +    rasd = []<br>
> +    for inst in def_rasd:<br>
> +        cn = get_typed_class(virt, "NetResourceAllocationSettingData")<br>
> +        if cn in inst:<br>
> +            rasd.append(inst)<br>
> +<br>
> +    params = {} <br>
> +<br>
> +    if len(rasd) != 1:<br>
> +        return params <br>
> +<br>
> +    params['vssd'] = vssd<br>
> +    params['rasd'] = rasd<br>
> +<br>
> +    return params <br>
> +<br>
> +def get_dom_macs(server, dom, virt):<br>
> +    mac_list = []<br>
> +<br>
> +    myxml = dumpxml(dom, server, virt=virt)<br>
> +<br>
> +    lines = myxml.splitlines()<br>
> +    for l in lines:<br>
> +        if l.find("mac address=") !=
-1:<br>
> +            mac = l.split('=')[1]<br>
> +            mac = mac.lstrip('\'')<br>
> +            mac = mac.rstrip('\'/>')<br>
> +            mac_list.append(mac)<br>
> +   <br>
> +    return mac_list <br>
> +<br>
> +@do_main(sup_types)<br>
> +def main():<br>
> +    options = main.options<br>
> +<br>
> +    try:<br>
> +        status, net_name = create_netpool_conf(options.ip,
options.<br>
> virt, False)<br>
> +        if status != PASS:<br>
> +            logger.error('Unable to
find a network pool')<br>
> +            return FAIL<br>
> +<br>
> +        status = setup_first_guest(options.ip,
options.virt)<br>
> +        if status != PASS:<br>
> +            raise Exception("Unable
to start %s" % test_dom)<br>
> +<br>
> +        ref = get_vssd_ref(options.ip, options.virt)<br>
> +        if ref is None:<br>
> +            raise Exception("Unable
to get %s reference" % test_dom)<br>
> +<br>
> +        define_params = get_vssd_rasd(options.virt)<br>
> +        if len(define_params) != 2:<br>
> +            raise Exception("Unable
to build VSSD and RASD <br>
> instances for %s" % \<br>
> +                    
       test_dom2)<br>
> +<br>
> +        status = create_using_definesystem(test_dom2,
options.ip, <br>
> +                    
                     
params=define_params, <br>
> ref_config=ref,<br>
> +                    
                     
virt=options.virt)<br>
> +        if status != PASS:<br>
> +            raise Exception("Unable
to define %s" % test_dom2)<br>
> +<br>
> +        dom1_mac_list = get_dom_macs(options.ip,
test_dom, options.virt)<br>
> +        if len(dom1_mac_list) != 1:<br>
> +            raise Exception("%s
has %d macs, expected 1" % (test_dom, <br>
> +                    
       len(dom1_mac_list)))<br>
> +<br>
> +        dom2_mac_list = get_dom_macs(options.ip,
test_dom2, options.virt)<br>
> +        if len(dom2_mac_list) != 2:<br>
> +            raise Exception("%s
has %d macs, expected 2" % (test_dom2, <br>
> +                    
       len(dom2_mac_list)))<br>
> +<br>
> +        for item in dom2_mac_list:<br>
> +            if item != mac and item
!= dom1_mac_list[0]:<br>
> +                raise Exception("%s
has unexpected mac value, exp: %s %s" % \<br>
> +                    
           (item, mac, dom1_mac_list[0]))<br>
> +<br>
> +        status = PASS<br>
> +      <br>
> +    except Exception, details:<br>
> +        logger.error(details)<br>
> +        status = FAIL<br>
> +<br>
> +    destroy_netpool(options.ip, options.virt, net_name)<br>
> +    destroy_and_undefine_domain(test_dom, options.ip, options.virt)<br>
> +    destroy_and_undefine_domain(test_dom2, options.ip,
options.virt)<br>
> +<br>
> +    return status <br>
> +<br>
> +if __name__ == "__main__":<br>
> +    sys.exit(main())<br>
> +    <br>
> <br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> https://www.redhat.com/mailman/listinfo/libvirt-cim<br>
</font></tt>