@@ -463,14 +463,15 @@ def disk_prompt(prompt_txt, arg_dict, warn_overwrite=False, prompt_size=True,
463463 else :
464464 path = None
465465 arg_dict ["path" ] = path
466+ path_exists = VirtualDisk .path_exists (conn , path )
466467
467468 sizeerr = _ ("A size must be specified for non-existent disks." )
468469 if path and not size and prompt_size :
469470 size_prompt = _ ("How large would you like the disk (%s) to "
470471 "be (in gigabytes)?" ) % path
471472
472473 try :
473- if not VirtualDisk . path_exists ( conn , path ) :
474+ if not path_exists :
474475 size = prompt_loop (size_prompt , sizeerr , size , None , None ,
475476 func = float )
476477 except Exception , e :
@@ -492,15 +493,15 @@ def disk_prompt(prompt_txt, arg_dict, warn_overwrite=False, prompt_size=True,
492493 askmsg = _ ("Do you really want to use this disk (yes or no)" )
493494
494495 # Prompt if disk file already exists and preserve mode is not used
495- if warn_overwrite and os . path . exists ( dev . path ) :
496- msg = (_ ("This will overwrite the existing path '%s'! \n " %
496+ if warn_overwrite and path_exists :
497+ msg = (_ ("This will overwrite the existing path '%s'" %
497498 dev .path ))
498499 if not prompt_for_yes_or_no (msg , askmsg ):
499500 continue
500501
501502 # Check disk conflicts
502503 if dev .is_conflict_disk (conn ) is True :
503- msg = (_ ("Disk %s is already in use by another guest! \n " %
504+ msg = (_ ("Disk %s is already in use by another guest" %
504505 dev .path ))
505506 if not prompt_for_yes_or_no (msg , askmsg ):
506507 continue
0 commit comments