summaryrefslogtreecommitdiff
path: root/virtManager/createvm.py
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2020-08-23 14:05:24 -0400
committerCole Robinson <crobinso@redhat.com>2020-08-26 15:20:05 -0400
commitbe2b308ae45e821382fabc9674a7f955eb53220d (patch)
tree1b25685f4c54c7b8474e4ee96eb354569a44a4e3 /virtManager/createvm.py
parentd111df4e62f847fbedf85612f1b7cdc729f97c4a (diff)
downloadvirt-manager-be2b308ae45e821382fabc9674a7f955eb53220d.tar.gz
createvm: Break out _validate_oscontainer_bootstrap
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtManager/createvm.py')
-rw-r--r--virtManager/createvm.py64
1 files changed, 35 insertions, 29 deletions
diff --git a/virtManager/createvm.py b/virtManager/createvm.py
index 40e42db7..813a5037 100644
--- a/virtManager/createvm.py
+++ b/virtManager/createvm.py
@@ -1481,6 +1481,37 @@ class vmmCreateVM(vmmGObjectUI):
self._gdata.machine = self._get_config_machine()
return bool(self._gdata.build_guest())
+ def _validate_oscontainer_bootstrap(self, fs, src_url, user, passwd):
+ # Check if the source path was provided
+ if not src_url:
+ return self.err.val_err(_("Source URL is required"))
+
+ # Require username and password when authenticate
+ # to source registry.
+ if user and not passwd:
+ return self.err.val_err(_("Please specify password "
+ "for accessing source registry"))
+
+ # Validate destination path
+ if not os.path.exists(fs):
+ return
+
+ if not os.path.isdir(fs):
+ return self.err.val_err(_("Destination path "
+ "is not directory: %s") % fs)
+ if not os.access(fs, os.W_OK):
+ return self.err.val_err(_("No write permissions for "
+ "directory path: %s") % fs)
+ if os.listdir(fs) == []:
+ return
+
+ # Show Yes/No dialog if the destination is not empty
+ return self.err.yes_no(
+ _("OS root directory is not empty"),
+ _("Creating root file system in a non-empty "
+ "directory might fail due to file conflicts.\n"
+ "Would you like to continue?"))
+
def _validate_install_page(self):
instmethod = self._get_config_install_page()
installer = None
@@ -1539,35 +1570,10 @@ class vmmCreateVM(vmmGObjectUI):
src_url = self._get_config_oscontainer_source_url()
user = self._get_config_oscontainer_source_username()
passwd = self._get_config_oscontainer_source_password()
-
- # Check if the source path was provided
- if not src_url:
- return self.err.val_err(_("Source URL is required"))
-
- # Require username and password when authenticate
- # to source registry.
- if user and not passwd:
- return self.err.val_err(_("Please specify password "
- "for accessing source registry"))
-
- # Validate destination path
- if os.path.exists(fs):
- if not os.path.isdir(fs):
- return self.err.val_err(_("Destination path "
- "is not directory: %s") % fs)
- if not os.access(fs, os.W_OK):
- return self.err.val_err(_("No write permissions for "
- "directory path: %s") % fs)
- if os.listdir(fs) != []:
- # Show Yes/No dialog if the destination is not empty
- res = self.err.yes_no(
- _("OS root directory is not empty"),
- _("Creating root file system in a non-empty "
- "directory might fail due to file conflicts.\n"
- "Would you like to continue?"))
- if not res:
- return False
-
+ ret = self._validate_oscontainer_bootstrap(
+ fs, src_url, user, passwd)
+ if ret is False:
+ return False
elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
template = self.widget("install-container-template").get_text()