diskbackend: Try looking up network volumes by path

For gluster volumes, which have unique URLs for volume paths, this
makes selecting network volumes via the storagebrowser UI work.

Sheepdog and RBD volumes don't work yet
This commit is contained in:
Cole Robinson 2014-12-10 09:04:09 -05:00
parent 2890d70a79
commit 12340a3858
2 changed files with 9 additions and 9 deletions

View File

@ -524,13 +524,9 @@ class VirtualDisk(VirtualDevice):
raise ValueError("Can't change disk path if storage creation info "
"has been set.")
parent_pool = None
vol_object = None
if newpath:
# User explicitly changed 'path', so try to lookup its storage
# object since we may need it
(vol_object, parent_pool) = diskbackend.manage_path(
self.conn, newpath)
# User explicitly changed 'path', so try to lookup its storage
# object since we may need it
(vol_object, parent_pool) = diskbackend.manage_path(self.conn, newpath)
self._change_backend(newpath, vol_object, parent_pool)
self._set_xmlpath(self.path)

View File

@ -114,6 +114,9 @@ def _can_auto_manage(path):
path = path or ""
skip_prefixes = ["/dev", "/sys", "/proc"]
if path_is_url(path):
return False
for prefix in skip_prefixes:
if path.startswith(prefix + "/") or path == prefix:
return False
@ -126,10 +129,11 @@ def manage_path(conn, path):
"""
if not conn.check_support(conn.SUPPORT_CONN_STORAGE):
return None, None
if path_is_url(path):
if not path:
return None, None
path = os.path.abspath(path)
if not path_is_url(path):
path = os.path.abspath(path)
vol, pool = check_if_path_managed(conn, path)
if vol or pool or not _can_auto_manage(path):
return vol, pool