[PATCH] check the existing file in virt-install

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx>

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

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux