def _distill_storage(conn, do_create, nomanaged, path, vol_object, vol_install, clone_path, *args): """ Validates and updates params when the backing storage is changed """ pool = None path_is_pool = False storage_capable = conn.check_conn_support(conn.SUPPORT_CONN_STORAGE) if vol_object: pass elif not storage_capable: pass elif path and not nomanaged: path = os.path.abspath(path) vol_object, pool, path_is_pool = diskbackend.check_if_path_managed( conn, path) creator = None backend = diskbackend.StorageBackend(conn, path, vol_object, path_is_pool and pool or None) if not do_create: return backend, None if backend.exists() and path is not None: if vol_install: raise ValueError("vol_install specified but %s exists." % backend.path) elif not clone_path: return backend, None if path or vol_install or pool or clone_path: creator = diskbackend.StorageCreator(conn, path, pool, vol_install, clone_path, *args) return backend, creator
def path_exists(conn, path): """ Check if path exists. If we can't determine, return False """ if path is None: return False try: (vol, pool, path_is_pool) = diskbackend.check_if_path_managed( conn, path) ignore = pool if vol or path_is_pool: return True if not conn.is_remote(): return os.path.exists(path) except: pass return False