device: disk: Move last host touching to diskbackend
This just conceptually makes more sense to keep it all in one file, and DeviceDisk is the API for the rest of the code to deal with any host storage state
This commit is contained in:
parent
425f599c84
commit
d36aa7fbaf
|
@ -8,7 +8,6 @@
|
|||
# See the COPYING file in the top-level directory.
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from .. import diskbackend
|
||||
from .. import util
|
||||
|
@ -149,22 +148,7 @@ class DeviceDisk(Device):
|
|||
may have disappeared behind our back, but that shouldn't have bad
|
||||
effects in practice.)
|
||||
"""
|
||||
if path is None:
|
||||
return False
|
||||
|
||||
try:
|
||||
(vol, pool) = diskbackend.check_if_path_managed(conn, path)
|
||||
ignore = pool
|
||||
|
||||
if vol:
|
||||
return True
|
||||
|
||||
if not conn.is_remote():
|
||||
return os.path.exists(path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return False
|
||||
return diskbackend.path_definitely_exists(conn, path)
|
||||
|
||||
@staticmethod
|
||||
def check_path_search(conn, path):
|
||||
|
|
|
@ -86,7 +86,7 @@ def _stat_disk(path):
|
|||
return True, 0
|
||||
|
||||
|
||||
def check_if_path_managed(conn, path):
|
||||
def _check_if_path_managed(conn, path):
|
||||
"""
|
||||
Try to lookup storage objects for the passed path.
|
||||
|
||||
|
@ -147,7 +147,7 @@ def manage_path(conn, path):
|
|||
|
||||
if not path_is_url(path):
|
||||
path = os.path.abspath(path)
|
||||
vol, pool = check_if_path_managed(conn, path)
|
||||
vol, pool = _check_if_path_managed(conn, path)
|
||||
if vol or pool or not _can_auto_manage(path):
|
||||
return vol, pool
|
||||
|
||||
|
@ -223,6 +223,28 @@ def _get_dev_type(path, vol_xml, vol_object, pool_xml, remote):
|
|||
return "file"
|
||||
|
||||
|
||||
def path_definitely_exists(conn, path):
|
||||
"""
|
||||
Return True if the path certainly exists, False if we are unsure.
|
||||
See DeviceDisk entry point for more details
|
||||
"""
|
||||
if path is None:
|
||||
return False
|
||||
|
||||
try:
|
||||
(vol, pool) = _check_if_path_managed(conn, path)
|
||||
ignore = pool
|
||||
if vol:
|
||||
return True
|
||||
|
||||
if not conn.is_remote():
|
||||
return os.path.exists(path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
|
||||
#########################
|
||||
# ACL/path perm helpers #
|
||||
#########################
|
||||
|
|
Loading…
Reference in New Issue