[Libvirt-cim] [PATCH] [TEST] Adding create_diskpool() function

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue May 13 18:35:27 UTC 2008


> +def create_diskpool(server, virt='KVM'):
> +    dpool_list = diskpool_list(server, virt='KVM')
> +    if len(dpool_list) > 0:
> +        dpoolname=dpool_list[0]
> +    else:
> +        global dpoolname 

Don't use a global here.  Globals should be avoided, especially in this 
case where this function is modifying a value that is used by multiple 
test cases.

Instead, have this function return the name of the diskpool it uses.

> +        diskxml = PoolXML(server, virt=virt)
> +        ret = diskxml.create_vpool()
> +        if not ret:
> +            logger.error('Failed to create the disk pool "%s"',
> +                         dpoolname)
> +            return FAIL
> +    logger.info("Disk Pool on machine is: %s ", dpoolname)
> +    return PASS 
-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list