[Libvirt-cim] [PATCH] [TEST] Adding new tc to verify the template RASDs for parent DiskPoolRASD
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Thu May 21 20:12:30 UTC 2009
> +
> +def get_rec(netpool_rasd, inst_id='Default'):
This should be diskpool_rasd
> + recs = []
> + for np_rasd in netpool_rasd:
Same here. Also, np_rasd should be dp_rasd
> + if np_rasd['InstanceID'] == inst_id :
> + recs.append(np_rasd)
Same here.
> + return recs
> +
> + at do_main(sup_types)
> +def main():
> + options = main.options
> + virt = options.virt
> + server = options.ip
> + status = FAIL
> + netpool_rasd = get_pool_rasds(server, virt, pool_type="DiskPool",
> + filter_default=False)
This should be diskpool_rasd
> + inst_list = [ 'Default', 'Minimum', 'Maximum', 'Increment' ]
> + n_rec_val = { 'ResourceType' : 17,
> + 'PoolID' : "DiskPool/0",
> + 'Path' : "/dev/null",
> + }
> + exp_type_path_host_dir = [('1', 'None', 'None', 'None'),
> + ('2', '/dev/sda100', 'None', 'None'),
> + ('3', 'None', 'host_sys.domain.com',
> + '/var/lib/images')]
> +
> +
> + for inst_type in inst_list:
> + logger.info("Verifying '%s' records", inst_type)
> +
> + try:
> + n_rec = get_rec(netpool_rasd, inst_id=inst_type)
Same here.
> + if len(n_rec) != 3:
Instead of using a hard coded number here, could you use a variable?
I'll be adding template RASDs for netfs and iscsi pools soon.
You could define the variable right before/after you define
exp_type_path_host_dir.
> + raise Exception("Got %s recs instead of 3" %(len(n_rec)))
Use the variable instead of the hard coded value here.
> +
> + res_type_path_host_dir = []
> + for rec in n_rec:
> + l = (str(rec['Type']), str(rec['DevicePath']),
> + str(rec['Host']), str(rec['SourceDirectory']))
> + res_type_path_host_dir.append(l)
> +
> + if len(Set(exp_type_path_host_dir) & Set(res_type_path_host_dir)) != 3 :
This is longer than 80 characters. Also, use variable instead of hard
coded value.
> + raise Exception("Mismatching values, " \
> + "\nGot %s, \nExpected %s" \
> + %(exp_type_path_host_dir, \
> + res_type_path_host_dir))
This is a little hard to read. Would something like the following be
easier?
raise Exception("Mismatching values, \nGot %s, \nExpected %s" \
%(exp_type_path_host_dir,
res_type_path_host_dir))
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list