libvirt-cim-bounces@redhat.com wrote on 2008-10-08
01:24:54:
> > status = FAIL
> > for items in pool:
> > cname = items.classname
> > if cname.find("MemoryPool") >=0 and items['InstanceID']
== "MemoryPool/0":
> > status = PASS
> > if cname.find("ProcessorPool") >=0 and items['InstanceID']
==
> > "ProcessorPool/0":
> > status = PASS
> > if cname.find("NetworkPool") >=0 and \
> > items['InstanceID'] == "NetworkPool/%s" %default_network_name:
> > status = PASS
> > if cname.find("DiskPool") >=0 and \
> > items['InstanceID'] == "DiskPool/%s" % default_pool_name:
> > status = PASS
> > if status != PASS:
> > logger.error("HostedResourcePool information error")
> > return status
> >
>
> If you hit an error condition, the test should return - no point in
> checking the other conditions when we already know we've failed. Plus,
> the error log message is really vague.
>
> Instead, you could do something like:
>
> try:
> for items in pool:
> cname = items.classname
> if cname.find("MemoryPool") >=0
and items['InstanceID'] !=
> "MemoryPool/0":
> raise Exception("%s
does not match MemoryPool/0",
> items['InstanceID'])
>
> elif cname.find("ProcessorPool")
>=0 and items['InstanceID'] !=
> "ProcessorPool/0":
> raise Exception("%s
does not match ProcessorPool/0",
> items['InstanceID'])
>
> elif cname.find("NetworkPool")
>= 0 and \
> items['InstanceID'] != "NetworkPool/%s"
%default_network_name:
> raise Exception("%s
does not match NetworkPool/%s",
> items['InstanceID'], default_network_name)
>
> elif cname.find("DiskPool") >= 0
and \
> items['InstanceID'] != "DiskPool/%s"
% default_pool_name:
> raise Exception("%s does not
match DiskPool/%s",
> items['InstanceID'], default_pool_name)
>
> except Exception, details:
> logger.error(details)
> return FAIL
>
> return PASS
>
> Kaitlin - That sounds good to me.
Thanks!
>
>
> --
> Kaitlin Rupert
> IBM Linux Technology Center
> kaitlin@linux.vnet.ibm.com
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim