[virt-tools-list] [virt-manager] [PATCH v2 4/8] gschema: Populate/Store previous container URLs

Radostin Stoyanov rstoyanov1 at gmail.com
Wed Jul 5 16:51:21 UTC 2017


---
 data/org.virt-manager.virt-manager.gschema.xml |  6 ++++
 virtManager/config.py                          |  4 +++
 virtManager/create.py                          | 38 ++++++++++++++++++--------
 3 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/data/org.virt-manager.virt-manager.gschema.xml b/data/org.virt-manager.virt-manager.gschema.xml
index 411c812..d88450f 100644
--- a/data/org.virt-manager.virt-manager.gschema.xml
+++ b/data/org.virt-manager.virt-manager.gschema.xml
@@ -153,6 +153,12 @@
   <schema id="org.virt-manager.virt-manager.urls"
       path="/org/virt-manager/virt-manager/urls/">
 
+    <key name="containers" type="as">
+      <default>[]</default>
+      <summary>Saved list of source URLs</summary>
+      <description>Saved list of source URLs used to bootstrap OS containers</description>
+    </key>
+
     <key name="urls" type="as">
       <default>[]</default>
       <summary>Saved list of install URLs</summary>
diff --git a/virtManager/config.py b/virtManager/config.py
index 5b04013..6fd6530 100644
--- a/virtManager/config.py
+++ b/virtManager/config.py
@@ -549,11 +549,15 @@ class vmmConfig(object):
                 del urls[len(urls) - 1]
             self.conf.set(gsettings_path, urls)
 
+    def add_container_url(self, url):
+        self._url_add_helper("/urls/containers", url)
     def add_media_url(self, url):
         self._url_add_helper("/urls/urls", url)
     def add_iso_path(self, path):
         self._url_add_helper("/urls/isos", path)
 
+    def get_container_urls(self):
+        return self.conf.get("/urls/containers")
     def get_media_urls(self):
         return self.conf.get("/urls/urls")
     def get_iso_paths(self):
diff --git a/virtManager/create.py b/virtManager/create.py
index 1559a34..5007d77 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -288,17 +288,22 @@ class vmmCreate(vmmGObjectUI):
         text = uiutil.init_combo_text_column(conn_list, 1)
         text.set_property("ellipsize", Pango.EllipsizeMode.MIDDLE)
 
+        def set_model_list(widget_id):
+            lst = self.widget(widget_id)
+            model = Gtk.ListStore(str)
+            lst.set_model(model)
+            lst.set_entry_text_column(0)
+
         # ISO media list
-        iso_list = self.widget("install-iso-combo")
-        iso_model = Gtk.ListStore(str)
-        iso_list.set_model(iso_model)
-        iso_list.set_entry_text_column(0)
+        set_model_list("install-iso-combo")
 
         # Lists for the install urls
-        media_url_list = self.widget("install-url-combo")
-        media_url_model = Gtk.ListStore(str)
-        media_url_list.set_model(media_url_model)
-        media_url_list.set_entry_text_column(0)
+        set_model_list("install-url-combo")
+
+        # Lists for OS container bootstrap
+        set_model_list("install-oscontainer-source-url-combo")
+
+
 
         def sep_func(model, it, combo):
             ignore = combo
@@ -440,6 +445,11 @@ 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)
+        src_model = (self.widget("install-oscontainer-source-url-combo")
+                         .get_model())
+        _populate_media_model(src_model, self.config.get_container_urls())
+
+
 
         # Install VZ container from template
         self.widget("install-container-template").set_text("centos-7-x86_64")
@@ -1278,9 +1288,14 @@ class vmmCreate(vmmGObjectUI):
         return self.widget("install-oscontainer-bootstrap").get_active()
 
 
-    def _get_config_oscontainer_source_url(self):
-        return (self.widget("install-oscontainer-source-url-entry")
-                    .get_text().strip())
+    def _get_config_oscontainer_source_url(self, store_media=False):
+        src_url = (self.widget("install-oscontainer-source-url-entry")
+                       .get_text().strip())
+
+        if src_url and store_media:
+            self.config.add_container_url(src_url)
+
+        return src_url
 
 
     def _get_config_oscontainer_source_username(self):
@@ -2134,6 +2149,7 @@ class vmmCreate(vmmGObjectUI):
 
         # Validation passed, store the install path (if there is one) in
         # gsettings
+        self._get_config_oscontainer_source_url(store_media=True)
         self._get_config_local_media(store_media=True)
         self._get_config_url_info(store_media=True)
         return True
-- 
2.9.4




More information about the virt-tools-list mailing list