def file_exists(params, filename_path): """ Check if image_filename exists. :param params: Dictionary containing the test parameters. :param filename_path: path to file :type filename_path: str :param root_dir: Base directory for relative filenames. :type root_dir: str :return: True if image file exists else False """ gluster_image = params.get("gluster_brick") if gluster_image: return gluster.file_exists(params, filename_path) if params.get("enable_ceph") == "yes": image_name = params.get("image_name") 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.rbd_image_exist(ceph_monitor, rbd_pool_name, rbd_image_name) return os.path.exists(filename_path)
def file_exists(params, filename_path): """ Check if image_filename exists. :param params: Dictionary containing the test parameters. :param filename_path: path to file :type filename_path: str :param root_dir: Base directory for relative filenames. :type root_dir: str :return: True if image file exists else False """ if params.get("enable_gluster") == "yes": return gluster.file_exists(params, filename_path) if params.get("enable_ceph") == "yes": image_name = params.get("image_name") image_format = params.get("image_format", "qcow2") ceph_monitor = params.get("ceph_monitor") rbd_pool_name = params["rbd_pool_name"] rbd_namespace_name = params.get("rbd_namespace_name") rbd_image_name = "%s.%s" % (image_name.split("/")[-1], image_format) ceph_conf = params.get("ceph_conf") keyring_conf = params.get("image_ceph_keyring_conf") return ceph.rbd_image_exist(ceph_monitor, rbd_pool_name, rbd_image_name, ceph_conf, keyring_conf, rbd_namespace_name) if params.get('enable_nvme') == 'yes': return nvme.file_exists(params, filename_path) if params.get('enable_ssh') == 'yes': return storage_ssh.file_exists(params, filename_path) if params.get('enable_curl') == 'yes': return curl.file_exists(params, filename_path) return os.path.exists(filename_path)