[virt-tools-list] [PATCH 3/4] oscontainer: ask root password in the wizard

Cédric Bosdonnat cbosdonnat at suse.com
Thu Dec 14 09:03:57 UTC 2017


When creating a new root file system out of an downloaded image,
the root password is likely to be changed. Add a field for this
in the new guest wizard.
---
 ui/create.ui          | 36 ++++++++++++++++++++++++++++++++++++
 virtManager/create.py | 14 ++++++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/ui/create.ui b/ui/create.ui
index ae9d47d3..ea92756d 100644
--- a/ui/create.ui
+++ b/ui/create.ui
@@ -1901,6 +1901,42 @@ connections is not yet supported.</small></property>
                                         <property name="position">3</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkBox" id="install-oscontainer-rootpw-box">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkLabel">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label" translatable="yes">Root password:</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkEntry" id="install-oscontainer-rootpw">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="visibility">False</property>
+                                            <property name="invisible_char">●</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">4</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                   <packing>
                                     <property name="expand">True</property>
diff --git a/virtManager/create.py b/virtManager/create.py
index 56293966..88f0885a 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -444,6 +444,7 @@ class vmmCreate(vmmGObjectUI):
         self.widget("install-oscontainer-source-insecure").set_active(False)
         self.widget("install-oscontainer-bootstrap").set_active(False)
         self.widget("install-oscontainer-auth-options").set_expanded(False)
+        self.widget("install-oscontainer-rootpw").set_text("")
         src_model = (self.widget("install-oscontainer-source-url-combo")
                          .get_model())
         _populate_media_model(src_model, self.config.get_container_urls())
@@ -680,7 +681,8 @@ class vmmCreate(vmmGObjectUI):
             "install-oscontainer-notsupport-conn": not is_local,
             "install-oscontainer-notsupport": not vb_installed,
             "install-oscontainer-bootstrap": vb_enabled,
-            "install-oscontainer-source": vb_enabled
+            "install-oscontainer-source": vb_enabled,
+            "install-oscontainer-rootpw-box": vb_enabled
             }
         for w in oscontainer_widget_conf:
             self.widget(w).set_visible(oscontainer_widget_conf[w])
@@ -1308,6 +1310,10 @@ class vmmCreate(vmmGObjectUI):
         return self.widget("install-oscontainer-source-insecure").get_active()
 
 
+    def _get_config_oscontainer_root_password(self):
+        return self.widget("install-oscontainer-rootpw").get_text()
+
+
     def _should_skip_disk_page(self):
         return self._get_config_install_page() in [INSTALL_PAGE_IMPORT,
                                                    INSTALL_PAGE_CONTAINER_APP,
@@ -1652,6 +1658,7 @@ class vmmCreate(vmmGObjectUI):
     def _container_source_toggle(self, ignore):
         enable_src = self.widget("install-oscontainer-bootstrap").get_active()
         self.widget("install-oscontainer-source").set_sensitive(enable_src)
+        self.widget("install-oscontainer-rootpw-box").set_sensitive(enable_src)
 
         # Auto-generate a path if not specified
         if enable_src and not self.widget("install-oscontainer-fs").get_text():
@@ -2497,7 +2504,8 @@ class vmmCreate(vmmGObjectUI):
                 'dest': self.widget("install-oscontainer-fs").get_text,
                 'user': self._get_config_oscontainer_source_username,
                 'passwd': self._get_config_oscontainer_source_password,
-                'insecure': self._get_config_oscontainer_isecure
+                'insecure': self._get_config_oscontainer_isecure,
+                'root_password': self._get_config_oscontainer_root_password,
             }
             for key, getter in bootstrap_arg_keys.items():
                 bootstrap_args[key] = getter()
@@ -2653,6 +2661,8 @@ class vmmCreate(vmmGObjectUI):
         if bootstrap_args['user'] and bootstrap_args['passwd']:
             kwargs['username'] = bootstrap_args['user']
             kwargs['password'] = bootstrap_args['passwd']
+        if bootstrap_args['root_password']:
+            kwargs['root_password'] = bootstrap_args['root_password']
         logging.debug('Start container bootstrap')
         try:
             virtBootstrap.bootstrap(**kwargs)
-- 
2.15.1




More information about the virt-tools-list mailing list