本文整理汇总了Python中virtinst.VirtualDisk.path_exists方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualDisk.path_exists方法的具体用法?Python VirtualDisk.path_exists怎么用?Python VirtualDisk.path_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virtinst.VirtualDisk
的用法示例。
在下文中一共展示了VirtualDisk.path_exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disk_prompt
# 需要导入模块: from virtinst import VirtualDisk [as 别名]
# 或者: from virtinst.VirtualDisk import path_exists [as 别名]
def disk_prompt(prompt_txt, arg_dict, warn_overwrite=False, prompt_size=True,
path_to_clone=None):
retry_path = True
conn = arg_dict.get("conn")
passed_path = arg_dict.get("path")
size = arg_dict.get("size")
no_path_needed = (bool(arg_dict.get("volInstall")) or
bool(arg_dict.get("volName")))
while 1:
if not retry_path:
passed_path = None
size = None
retry_path = False
msg = None
patherr = _("A disk path must be specified.")
if path_to_clone:
patherr = (_("A disk path must be specified to clone '%s'.") %
path_to_clone)
if not prompt_txt:
msg = _("What would you like to use as the disk (file path)?")
if not size is None:
msg = _("Please enter the path to the file you would like to "
"use for storage. It will have size %sGB.") %(size,)
if not no_path_needed:
path = prompt_for_input(patherr, prompt_txt or msg, passed_path)
else:
path = None
arg_dict["path"] = path
sizeerr = _("A size must be specified for non-existent disks.")
if path and not size and prompt_size:
size_prompt = _("How large would you like the disk (%s) to "
"be (in gigabytes)?") % path
try:
if not VirtualDisk.path_exists(conn, path):
size = prompt_loop(size_prompt, sizeerr, size, None, None,
func=float)
except Exception, e:
# Path is probably bogus, raise the error
logging.error(str(e))
continue
arg_dict["size"] = size
# Build disk object for validation
try:
dev = VirtualDisk(**arg_dict)
except ValueError, e:
if is_prompt():
logging.error(e)
continue
else:
fail(_("Error with storage parameters: %s" % str(e)))