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)))