[Libvirt-cim] [PATCH 2 of 2] [TEST] Adding new tc to verify the template RASDs for parent NetPoolRASD
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Tue May 19 23:12:45 UTC 2009
> +
> +def get_rec(netpool_rasd, inst_id='Default'):
> + recs = []
> + for np_rasd in netpool_rasd:
> + if np_rasd['InstanceID'] == inst_id and \
> + 'NetworkPool/0' == np_rasd['PoolID']:
libvirt-cim will only generate NetPoolRASDs for the parent pool (which
is NetworkPool/0").
So there's no need to verify the PoolID here. You have PoolID in the
n_rec_val list anyway, so it'll get verified in verify_rec()
> + recs.append(np_rasd)
> + return recs
> +
> +def verify_rec(netpool_rasd, inst_type='Default'):
> + logger.info("Verifying '%s' records", inst_type)
> + try:
> + n_rec_val = { 'ResourceType' : 10,
> + 'PoolID' : "NetworkPool/0",
> + 'Address' : "192.168.122.1",
> + 'Netmask' : "255.255.255.0",
> + 'IPRangeStart' : "192.168.122.2",
> + 'IPRangeEnd' : "192.168.122.254"
> + }
> +
> + n_rec = get_rec(netpool_rasd, inst_id=inst_type)
> + if len(n_rec) != 5:
> + raise Exception("Got %s recs instead of 5" %(len(n_rec)))
> + return FAIL
> +
> + exp_mode_device = [('None', 0L), ('None', 1L), ('eth0', 1L),
> + ('None', 2L), ('eth0', 2L)]
> +
> + res_mode_device = []
> + for rec in n_rec:
> + l = (str(rec['ForwardDevice']), rec['ForwardMode'])
> + res_mode_device.append(l)
> +
> + if len(Set(exp_mode_device) & Set(res_mode_device)) != 5 :
> + raise Exception("Mismatching Mode and device values, " \
> + "Got %s, Expected %s" %(exp_mode_device, \
> + res_mode_device))
> +
> + for key in n_rec_val.keys():
> + for rec in n_rec:
> + if n_rec_val[key] != rec[key]:
> + raise Exception("'%s' Mismatch, Got %s, Expected %s" \
> + % (key, rec[key], n_rec_val[key]))
> +
> + except Exception, details:
> + logger.error("Exception details: %s", details)
> + return FAIL
> +
> + return PASS
> +
> +
> + 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, filter_default=False)
> + inst_list = [ 'Default', 'Minimum', 'Maximum', 'Increment' ]
> + for inst_type in inst_list:
> + status = verify_rec(netpool_rasd, inst_type)
> + if status != PASS:
> + return FAIL
The bulk of the test is happening in a different function.. since
there's not much going on in the test, you can just put the body of
verify_rec() in main.
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list