mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Keep a list of used install ISO paths.
Store these in gconf on a per hostname basis, since a local path likely isn't relevant for a connection on another host.
This commit is contained in:
parent
b619961f29
commit
3ad177128c
@ -457,29 +457,27 @@ class vmmConfig:
|
||||
def set_url_list_length(self, length):
|
||||
self.conf.set_int(self.conf_dir + "/urls/url-list-length", length)
|
||||
|
||||
def add_media_url(self, url):
|
||||
urls = self.conf.get_list(self.conf_dir + "/urls/media", gconf.VALUE_STRING)
|
||||
def _url_add_helper(self, gconf_path, url):
|
||||
urls = self.conf.get_list(gconf_path, gconf.VALUE_STRING)
|
||||
if urls == None:
|
||||
urls = []
|
||||
if urls.count(url) == 0 and len(url)>0 and not url.isspace():
|
||||
#the url isn't already in the list, so add it
|
||||
|
||||
if urls.count(url) == 0 and len(url) > 0 and not url.isspace():
|
||||
# The url isn't already in the list, so add it
|
||||
urls.insert(0,url)
|
||||
length = self.get_url_list_length()
|
||||
if len(urls) > length:
|
||||
del urls[len(urls) -1]
|
||||
self.conf.set_list(self.conf_dir + "/urls/media", gconf.VALUE_STRING, urls)
|
||||
self.conf.set_list(gconf_path, gconf.VALUE_STRING, urls)
|
||||
|
||||
def add_media_url(self, url):
|
||||
self._url_add_helper(self.conf_dir + "/urls/media", url)
|
||||
|
||||
def add_kickstart_url(self, url):
|
||||
urls = self.conf.get_list(self.conf_dir + "/urls/kickstart", gconf.VALUE_STRING)
|
||||
if urls == None:
|
||||
urls = []
|
||||
if urls.count(url) == 0:
|
||||
# the url isn't already in the list, so add it
|
||||
urls.insert(0,url)
|
||||
length = self.get_url_list_length()
|
||||
if len(urls) > length:
|
||||
del urls[len(urls) -1]
|
||||
self.conf.set_list(self.conf_dir + "/urls/kickstart", gconf.VALUE_STRING, urls)
|
||||
self._url_add_helper(self.conf_dir + "/urls/kickstart", url)
|
||||
|
||||
def add_iso_path(self, path):
|
||||
self._url_add_helper(self.conf_dir + "/urls/local_media", path)
|
||||
|
||||
def add_connection(self, uri):
|
||||
uris = self.conf.get_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING)
|
||||
@ -524,10 +522,15 @@ class vmmConfig:
|
||||
gconf.VALUE_STRING, uris)
|
||||
|
||||
def get_media_urls(self):
|
||||
return self.conf.get_list(self.conf_dir + "/urls/media", gconf.VALUE_STRING)
|
||||
|
||||
return self.conf.get_list(self.conf_dir + "/urls/media",
|
||||
gconf.VALUE_STRING)
|
||||
def get_kickstart_urls(self):
|
||||
return self.conf.get_list(self.conf_dir + "/urls/kickstart", gconf.VALUE_STRING)
|
||||
return self.conf.get_list(self.conf_dir + "/urls/kickstart",
|
||||
gconf.VALUE_STRING)
|
||||
def get_iso_paths(self):
|
||||
return self.conf.get_list(self.conf_dir + "/urls/local_media",
|
||||
gconf.VALUE_STRING)
|
||||
|
||||
def get_connections(self):
|
||||
return self.conf.get_list(self.conf_dir + "/connections/uris", gconf.VALUE_STRING)
|
||||
|
||||
|
@ -1263,5 +1263,12 @@ class vmmConnection(gobject.GObject):
|
||||
return True
|
||||
return False
|
||||
|
||||
# Per-Connection preferences
|
||||
def config_add_iso_path(self, path):
|
||||
self.config.set_perhost(self.get_uri(), self.config.add_iso_path, path)
|
||||
def config_get_iso_paths(self):
|
||||
return self.config.get_perhost(self.get_uri(),
|
||||
self.config.get_iso_paths)
|
||||
|
||||
gobject.type_register(vmmConnection)
|
||||
|
||||
|
@ -108,7 +108,7 @@ class vmmCreate(gobject.GObject):
|
||||
"on_install_url_box_changed": self.url_box_changed,
|
||||
"on_install_local_cdrom_toggled": self.local_cdrom_toggled,
|
||||
"on_install_local_cdrom_combo_changed": self.detect_media_os,
|
||||
"on_install_local_entry_activate": self.detect_media_os,
|
||||
"on_install_local_box_changed": self.detect_media_os,
|
||||
"on_install_local_browse_clicked": self.browse_iso,
|
||||
|
||||
"on_install_detect_os_toggled": self.toggle_detect_os,
|
||||
@ -183,6 +183,13 @@ class vmmCreate(gobject.GObject):
|
||||
conn_list.pack_start(text, True)
|
||||
conn_list.add_attribute(text, 'text', 1)
|
||||
|
||||
# ISO media list
|
||||
iso_list = self.window.get_widget("install-local-box")
|
||||
iso_model = gtk.ListStore(str)
|
||||
iso_list.set_model(iso_model)
|
||||
iso_list.set_text_column(0)
|
||||
self.window.get_widget("install-local-box").child.connect("activate", self.detect_media_os)
|
||||
|
||||
# Lists for the install urls
|
||||
media_url_list = self.window.get_widget("install-url-box")
|
||||
media_url_model = gtk.ListStore(str)
|
||||
@ -287,7 +294,9 @@ class vmmCreate(gobject.GObject):
|
||||
self.window.get_widget("install-os-type").set_active(0)
|
||||
|
||||
# Install local/iso
|
||||
self.window.get_widget("install-local-entry").set_text("")
|
||||
self.window.get_widget("install-local-box").child.set_text("")
|
||||
iso_model = self.window.get_widget("install-local-box").get_model()
|
||||
self.populate_media_model(iso_model, self.conn.config_get_iso_paths())
|
||||
|
||||
# Install URL
|
||||
self.window.get_widget("install-urlopts-entry").set_text("")
|
||||
@ -295,8 +304,8 @@ class vmmCreate(gobject.GObject):
|
||||
self.window.get_widget("install-url-box").child.set_text("")
|
||||
urlmodel = self.window.get_widget("install-url-box").get_model()
|
||||
ksmodel = self.window.get_widget("install-ks-box").get_model()
|
||||
self.populate_url_model(urlmodel, self.config.get_media_urls())
|
||||
self.populate_url_model(ksmodel, self.config.get_kickstart_urls())
|
||||
self.populate_media_model(urlmodel, self.config.get_media_urls())
|
||||
self.populate_media_model(ksmodel, self.config.get_kickstart_urls())
|
||||
|
||||
# Mem / CPUs
|
||||
self.window.get_widget("config-mem").set_value(512)
|
||||
@ -604,7 +613,7 @@ class vmmCreate(gobject.GObject):
|
||||
model.append([variant,
|
||||
virtinst.FullVirtGuest.get_os_variant_label(_type,
|
||||
variant)])
|
||||
def populate_url_model(self, model, urls):
|
||||
def populate_media_model(self, model, urls):
|
||||
model.clear()
|
||||
for url in urls:
|
||||
model.append([url])
|
||||
@ -789,11 +798,14 @@ class vmmCreate(gobject.GObject):
|
||||
|
||||
return (distro, variant, dlabel, vlabel)
|
||||
|
||||
def get_config_local_media(self):
|
||||
def get_config_local_media(self, store_media=False):
|
||||
if self.window.get_widget("install-local-cdrom").get_active():
|
||||
return self.window.get_widget("install-local-cdrom-combo").get_active_text()
|
||||
else:
|
||||
return self.window.get_widget("install-local-entry").get_text()
|
||||
ret = self.window.get_widget("install-local-box").child.get_text()
|
||||
if ret and store_media:
|
||||
self.conn.config_add_iso_path(ret)
|
||||
return ret
|
||||
|
||||
def get_config_detectable_media(self):
|
||||
instpage = self.get_config_install_page()
|
||||
@ -806,14 +818,14 @@ class vmmCreate(gobject.GObject):
|
||||
|
||||
return media
|
||||
|
||||
def get_config_url_info(self):
|
||||
def get_config_url_info(self, store_media=False):
|
||||
media = self.window.get_widget("install-url-box").get_active_text().strip()
|
||||
extra = self.window.get_widget("install-urlopts-entry").get_text().strip()
|
||||
ks = self.window.get_widget("install-ks-box").get_active_text().strip()
|
||||
|
||||
if media:
|
||||
if media and store_media:
|
||||
self.config.add_media_url(media)
|
||||
if ks:
|
||||
if ks and store_media:
|
||||
self.config.add_kickstart_url(ks)
|
||||
|
||||
return (media.strip(), extra.strip(), ks.strip())
|
||||
@ -974,7 +986,7 @@ class vmmCreate(gobject.GObject):
|
||||
|
||||
def toggle_local_iso(self, src):
|
||||
uselocal = src.get_active()
|
||||
self.window.get_widget("install-local-entry").set_sensitive(uselocal)
|
||||
self.window.get_widget("install-local-box").set_sensitive(uselocal)
|
||||
self.window.get_widget("install-local-browse").set_sensitive(uselocal)
|
||||
|
||||
def detect_visibility_changed(self, src, ignore=None):
|
||||
@ -993,8 +1005,8 @@ class vmmCreate(gobject.GObject):
|
||||
def browse_iso(self, ignore1=None, ignore2=None):
|
||||
f = self._browse_file(_("Locate ISO Image"), is_media=True)
|
||||
if f != None:
|
||||
self.window.get_widget("install-local-entry").set_text(f)
|
||||
self.window.get_widget("install-local-entry").activate()
|
||||
self.window.get_widget("install-local-box").child.set_text(f)
|
||||
self.window.get_widget("install-local-box").activate()
|
||||
|
||||
def toggle_enable_storage(self, src):
|
||||
self.window.get_widget("config-storage-box").set_sensitive(src.get_active())
|
||||
@ -1015,7 +1027,7 @@ class vmmCreate(gobject.GObject):
|
||||
notebook = self.window.get_widget("create-pages")
|
||||
curpage = notebook.get_current_page()
|
||||
if curpage == PAGE_INSTALL:
|
||||
self.window.get_widget("install-local-entry").set_text(path)
|
||||
self.window.get_widget("install-local-box").child.set_text(path)
|
||||
elif curpage == PAGE_STORAGE:
|
||||
self.window.get_widget("config-storage-entry").set_text(path)
|
||||
|
||||
@ -1225,6 +1237,11 @@ class vmmCreate(gobject.GObject):
|
||||
except ValueError, e:
|
||||
return self.err.val_err(_("Error setting OS information."),
|
||||
str(e))
|
||||
|
||||
# Validation passed, store the install path (if there is one) in
|
||||
# gconf
|
||||
self.get_config_local_media(store_media=True)
|
||||
self.get_config_url_info(store_media=True)
|
||||
return True
|
||||
|
||||
def validate_mem_page(self):
|
||||
|
@ -410,11 +410,9 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">20</property>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="install-local-entry">
|
||||
<widget class="GtkComboBoxEntry" id="install-local-box">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<signal name="activate" handler="on_install_local_entry_activate"/>
|
||||
<signal name="changed" handler="on_install_local_box_changed"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user