def get_image_filename(params, root_dir): """ Generate an image path from params and root_dir. :param params: Dictionary containing the test parameters. :param root_dir: Base directory for relative filenames. :param image_name: Force name of image. :param image_format: Format for image. :note: params should contain: image_name -- the name of the image file, without extension image_format -- the format of the image (qcow2, raw etc) :raise VMDeviceError: When no matching disk found (in indirect method). """ enable_gluster = params.get("enable_gluster", "no") == "yes" enable_ceph = params.get("enable_ceph", "no") == "yes" image_name = params.get("image_name") if image_name: if enable_gluster: image_name = params.get("image_name", "image") image_format = params.get("image_format", "qcow2") return gluster.get_image_filename(params, image_name, image_format) if enable_ceph: image_format = params.get("image_format", "qcow2") ceph_monitor = params["ceph_monitor"] rbd_pool_name = params["rbd_pool_name"] rbd_image_name = "%s.%s" % (image_name.split("/")[-1], image_format) return ceph.get_image_filename(ceph_monitor, rbd_pool_name, rbd_image_name) return get_image_filename_filesytem(params, root_dir) else: logging.warn("image_name parameter not set.")
def get_image_filename(params, root_dir, basename=False): """ Generate an image path from params and root_dir. :param params: Dictionary containing the test parameters. :param root_dir: Base directory for relative filenames. :param basename: True to use only basename of image_name :note: params should contain: image_name -- the name of the image file, without extension image_format -- the format of the image (qcow2, raw etc) :raise VMDeviceError: When no matching disk found (in indirect method). """ enable_gluster = params.get("enable_gluster", "no") == "yes" enable_ceph = params.get("enable_ceph", "no") == "yes" image_name = params.get("image_name") if image_name: if enable_gluster: image_name = params.get("image_name", "image") image_format = params.get("image_format", "qcow2") return gluster.get_image_filename(params, image_name, image_format) if enable_ceph: image_format = params.get("image_format", "qcow2") ceph_monitor = params["ceph_monitor"] rbd_pool_name = params["rbd_pool_name"] rbd_image_name = "%s.%s" % (image_name.split("/")[-1], image_format) return ceph.get_image_filename(ceph_monitor, rbd_pool_name, rbd_image_name) return get_image_filename_filesytem(params, root_dir, basename=basename) else: logging.warn("image_name parameter not set.")
def get_image_filename(params, root_dir, basename=False): """ Generate an image path from params and root_dir. :param params: Dictionary containing the test parameters. :param root_dir: Base directory for relative filenames. :param basename: True to use only basename of image_name :note: params should contain: image_name -- the name of the image file, without extension image_format -- the format of the image (qcow2, raw etc) :raise VMDeviceError: When no matching disk found (in indirect method). """ enable_nbd = params.get("enable_nbd") == "yes" enable_gluster = params.get("enable_gluster") == "yes" enable_ceph = params.get("enable_ceph") == "yes" enable_iscsi = params.get("enable_iscsi") == "yes" enable_nvme = params.get("enable_nvme") == "yes" image_name = params.get("image_name") storage_type = params.get("storage_type") if image_name: image_format = params.get("image_format", "qcow2") if enable_nbd: return nbd.get_image_filename(params) if enable_iscsi: if storage_type == 'iscsi-direct': portal = params.get('portal_ip') target = params.get('target') lun = params.get('lun', 0) user = params.get('chap_user') password = params.get('chap_passwd') return iscsi.get_image_filename(portal, target, lun, user, password) if enable_gluster: return gluster.get_image_filename(params, image_name, image_format) if enable_ceph: rbd_pool_name = params["rbd_pool_name"] rbd_image_name = "%s.%s" % (image_name.split("/")[-1], image_format) ceph_conf = params.get('ceph_conf') ceph_monitor = params.get('ceph_monitor') return ceph.get_image_filename(ceph_monitor, rbd_pool_name, rbd_image_name, ceph_conf) if enable_nvme: address = params['nvme_pci_address'] namespace = params.get('nvme_namespace', 1) return nvme.get_image_filename(address, namespace) return get_image_filename_filesytem(params, root_dir, basename=basename) else: logging.warn("image_name parameter not set.")