[et-mgmt-tools] [PATCH] check the existing file in virt-install
Masayuki Sunou
fj1826dm at aa.jp.fujitsu.com
Mon Jul 23 23:42:18 UTC 2007
Hi
When the existing file is specified with virt-install, the file is
compulsorily overwrited.
Therefore the important file may be overwrited when a user makes a typo.
This patch fixes so that virt-install displays warning message when
the existing file is specified.
Signed-off-by: Masayuki Sunou <fj1826dm at aa.jp.fujitsu.com>
Thanks,
Masayuki Sunou.
----------------------------------------------------------------------
diff -r 645217bda13b virt-install
--- a/virt-install Sat Jul 21 13:03:07 2007 -0400
+++ b/virt-install Tue Jul 24 16:23:30 2007 +0900
@@ -48,6 +48,23 @@ def get_disk(disk, size, sparse, guest,
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,)
disk = cli.prompt_for_input(msg, disk)
+ if os.path.exists(disk) and os.path.isfile(disk):
+ while 1:
+ retryFlg = False
+ warnmsg = _("You are going to overwrite file '%s'!") % disk
+ res = cli.prompt_for_input(warnmsg + _(" Do you really want to use the disk (yes or no)? "))
+ try:
+ if cli.yes_or_no(res) is True:
+ break
+ else:
+ retryFlg = True
+ break
+ except ValueError, e:
+ print _("ERROR: "), e
+ continue
+ if retryFlg is True:
+ disk = None
+ continue
while 1:
if os.path.exists(disk):
break
----------------------------------------------------------------------
More information about the et-mgmt-tools
mailing list