def check_prompt_vm_name():
if cfg.opts.vmname:
# If specified on cmdline, use it
pass
else:
# Otherwise generate a guess
_default_name = re.sub('[.]', '', cfg.opts.templateName)
if stdout.isatty():
# If have tty, prompt with default guess
cfg.opts.vmname = raw_input(c.CYAN("Enter VMNAME ") + c.BOLD("[{}]".format(_default_name)) + c.CYAN(" : "))
if not cfg.opts.vmname:
cfg.opts.vmname = _default_name
else:
# If no tty, use default guess
print(c.yellow("VMNAME not specified; using '{}'".format(_default_name)))
cfg.opts.vmname = _default_name
# Validate selected guest name
while True:
match = re.search(r'^{}$'.format(cfg.opts.vmname), cfg.guestList, re.M)
if match:
print(c.YELLOW("Already have a VM with the name '{}'".format(cfg.opts.vmname)))
print(c.BOLD("\nExisting VMs:"))
print(c.cyan(cfg.guestList.strip()))
if not stdout.isatty():
exit(1)
cfg.opts.vmname = raw_input(c.CYAN("Enter a unique VM name : "))
else:
break
评论列表
文章目录