[Libvirt-cim] [PATCH 1 of 4] [TEST] Adding functions to verify the EAFP fields

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Jul 11 21:04:13 UTC 2008


> +def verify_common_pool_values(assoc_info, list_values):
> +    if assoc_info['InstanceID'] != list_values['InstanceID']:
> +        field_err(assoc_info, list_values, fieldname = 'InstanceID')
> +        return FAIL
> +    if assoc_info['PoolID'] != list_values['PoolID']:
> +        field_err(assoc_info, list_values, fieldname = 'PoolID')
> +        return FAIL
> +    if assoc_info['ResourceType'] != list_values['ResourceType']:
> +        field_err(assoc_info, list_values, fieldname = 'ResourceType')
> +        return FAIL
> +    return PASS
> +
> +def verify_specific_fields(assoc_info, list_values):

I'd suggest combining this functionality into the function above.

The only case where you need to ignore these properties is in the 
NetworkPool case, so I'd have verify_common_pool_values() take the class 
name.

After checking the common values, check to see if the class name is 
"NetworkPool" and return from the function if is.

> +    if assoc_info['Capacity'] != list_values['Capacity']:
> +        field_err(assoc_info, list_values, fieldname = 'Capacity')
> +        return FAIL
> +    if assoc_info['Reserved'] != list_values['Reserved']:
> +        field_err(assoc_info, list_values, fieldname = 'Reserved')
> +        return FAIL
> +    if assoc_info['AllocationUnits'] != list_values['AllocationUnits']:
> +        field_err(assoc_info, list_values, fieldname = 'AllocationUnits')
> +        return FAIL
> +    return PASS
> +
> +def verify_disk_mem_proc_pool_values(assoc_info, list_values):

I don't think this function is needed.  This function only calls two 
other function - it doesn't do any other tasks.

Plus, if you make the changes suggested above, then this function 
becomes obsolete.

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list