devicedisk: Rename path_exists -> path_definitely_exists

Since it's a best effort attempt, try to make it more clear that
we aren't certain if paths exist in some cases.
This commit is contained in:
Cole Robinson 2014-12-04 20:00:34 -05:00
parent ba05e1cd43
commit 6489df83ca
7 changed files with 19 additions and 9 deletions

View File

@ -267,7 +267,7 @@ class vmmAddStorage(vmmGObjectUI):
do_exist = False
ret = True
try:
do_exist = virtinst.VirtualDisk.path_exists(conn, ideal)
do_exist = virtinst.VirtualDisk.path_definitely_exists(conn, ideal)
ret = virtinst.VirtualDisk.path_in_use_by(conn, ideal)
except:
logging.exception("Error checking default path usage")

View File

@ -701,8 +701,8 @@ class vmmCloneVM(vmmGObjectUI):
new_path = self.widget("change-storage-new").get_text()
if virtinst.VirtualDisk.path_exists(self.clone_design.conn,
new_path):
if virtinst.VirtualDisk.path_definitely_exists(self.clone_design.conn,
new_path):
res = self.err.yes_no(_("Cloning will overwrite the existing "
"file"),
_("Using an existing image will overwrite "

View File

@ -554,7 +554,8 @@ class vmmConnection(vmmGObject):
def get_vol_by_path(self, path):
# path_exists will handle stuff like refreshing a busted pool
if not virtinst.VirtualDisk.path_exists(self.get_backend(), path):
if not virtinst.VirtualDisk.path_definitely_exists(self.get_backend(),
path):
return None
for pool in self._pools.values():

View File

@ -2621,7 +2621,8 @@ class vmmDetails(vmmGObjectUI):
iotune_wis = (disk.iotune_wis or 0)
show_format = (not self.is_customize_dialog or
disk.path_exists(disk.conn, disk.path))
virtinst.VirtualDisk.path_definitely_exists(
disk.conn, disk.path))
size = _("Unknown")
if not path:

View File

@ -329,7 +329,7 @@ def validate_disk(dev, warn_overwrite=False):
"""
if not warn_overwrite:
return
if VirtualDisk.path_exists(dev.conn, dev.path):
if VirtualDisk.path_definitely_exists(dev.conn, dev.path):
_optional_fail(
_("This will overwrite the existing path '%s'" % dev.path))

View File

@ -476,7 +476,7 @@ class Cloner(object):
clonebase = os.path.join(dirname, clonebase)
return util.generate_name(
clonebase,
lambda p: VirtualDisk.path_exists(self.conn, p),
lambda p: VirtualDisk.path_definitely_exists(self.conn, p),
suffix,
lib_collision=False)

View File

@ -212,9 +212,17 @@ class VirtualDisk(VirtualDevice):
return bus
@staticmethod
def path_exists(conn, path):
def path_definitely_exists(conn, path):
"""
Check if path exists. If we can't determine, return False
Check if path exists.
return True if we are certain, False otherwise. Path may in fact
exist if we return False, but we can't exhaustively know in all
cases.
(In fact if cached storage volume data is out of date, the volume
may have disappeared behind out back, but that shouldn't have bad
effects in practice.)
"""
if path is None:
return False