[Libvirt-cim] [PATCH 2 of 2] [TEST] Adding new test RPCS/10_create_storagevolume.py
Kaitlin Rupert
kaitlin at linux.vnet.ibm.com
Mon Aug 24 21:32:28 UTC 2009
> +def verify_vol(server, virt, pool_name, exp_vol_path, found):
> + vols = vol_list(server, virt, pool_name)
> + if vols == None:
> + raise Exception("Failed to get the volume information")
> +
> + for vol in vols.split('\n'):
> + res_vol_name, res_vol_path = vol.split()
> + if res_vol_name != vol_name and res_vol_path != exp_vol_path:
> + continue
> + else:
> + found += 1
> +
> + if found != 1:
> + logger.error("Failed to get the vol information")
You'll also want to verify that a template DiskRASD is created.
> +
> + return found
> +
> +
> + at do_main(platform_sup)
> +def main():
> + options = main.options
> + server = options.ip
> + virt = options.virt
> +
> + libvirt_version = virsh_version(server, virt)
> + cim_rev, changeset = get_provider_version(virt, server)
> + if libvirt_version < "0.4.1" and cim_rev < libvirt_rasd_storagepool_changes:
> + logger.info("Storage Volume creation support is available with Libvirt"
> + "version >= 0.4.1 and Libvirt-CIM rev '%s'",
> + libvirt_rasd_storagepool_changes)
> + return SKIP
> +
> + dp_cn = "DiskPool"
> + exp_vol_path = "%s/%s" % (pool_attr['Path'], vol_name)
> +
> + # For now the test case support only the creation of dir type based
> + # vol creation, we can extend dp_types to include netfs etc
> + dp_types = { "DISK_POOL_DIR" : DIR_POOL }
> +
> + for pool_name, pool_type in dp_types.iteritems():
> + status = FAIL PoolXML
> + res = [FAIL]
> + found = 0
> + try:
> + status = create_pool(server, virt, pool_name, pool_attr,
> + mode_type=pool_type, pool_type="DiskPool")
You shouldn't need to create a storage pool, since main.py sets up a
default diskpool. That pool is a dir type pool for the /tmp directory.
So you should be able to create your storage volume there.
> +
> + if status != PASS:
> + logger.error("Failed to create pool '%s'", pool_name)
> + return status
> +
> + dp_inst_id = "%s/%s" % (dp_cn, pool_name)
> + stovol_settings = get_stovol_settings(server, virt,
> + dp_inst_id, pool_name)
> + if stovol_settings == None:
> + raise Exception("Failed to get the defualt StorageVolRASD info")
> +
> + disk_pool_inst = get_diskpool(server, virt, dp_cn, dp_inst_id)
> + if disk_pool_inst == None:
> + raise Exception("DiskPool instance for '%s' not found!" \
> + % pool_name)
> +
> + rpcs = get_typed_class(virt, "ResourcePoolConfigurationService")
> + rpcs_conn = eval("rpcs_service." + rpcs)(server)
> + res = rpcs_conn.CreateResourceInPool(Settings=stovol_settings,
> + Pool=disk_pool_inst)
If this fails, no need to verify the vol. Raise an exception and fail
the test.
> + found = verify_vol(server, virt, pool_name, exp_vol_path, found)
> +
> + except Exception, details:
> + logger.error("Exception details: %s", details)
> + status = FAIL
> +
> + ret = cleanup_pool_vol(server, virt, pool_name, exp_vol_path)
> + if res[0] == PASS and found == 1 and ret == PASS:
> + status = PASS
> + else:
> + return FAIL
> +
> + return status
> +if __name__ == "__main__":
> + sys.exit(main())
--
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list