Add drop-down lists for PV media and kickstart URLs
This commit is contained in:
parent
ac42f26320
commit
ef769036d5
|
@ -2836,7 +2836,7 @@ Jeremy Katz <katzj@redhat.com>
|
|||
<widget class="GtkTable" id="table3">
|
||||
<property name="border_width">3</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_rows">2</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">3</property>
|
||||
|
@ -2872,7 +2872,6 @@ Jeremy Katz <katzj@redhat.com>
|
|||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label37">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Maintain history of</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
|
@ -6862,16 +6861,12 @@ TB</property>
|
|||
<property name="right_padding">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="pv-ks-url">
|
||||
<widget class="GtkComboBoxEntry" id="pv-ks-url">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="activates_default">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_pv_ks_url_changed" last_modification_time="Wed, 11 Oct 2006 10:31:19 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -6898,17 +6893,12 @@ TB</property>
|
|||
<property name="right_padding">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="pv-media-url">
|
||||
<widget class="GtkComboBoxEntry" id="pv-media-url">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="has_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="activates_default">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="changed" handler="on_pv_media_url_changed" last_modification_time="Wed, 11 Oct 2006 10:31:09 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
|
|
@ -117,5 +117,18 @@
|
|||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/::PACKAGE::/urls/url-list-length</key>
|
||||
<applyto>/apps/::PACKAGE::/urls/url-list-length</applyto>
|
||||
<owner>::PACKAGE::</owner>
|
||||
<type>int</type>
|
||||
<default>10</default>
|
||||
|
||||
<locale name="C">
|
||||
<short>The length of the list of URLs</short>
|
||||
<long>The number of urls to keep in the history for the install media address page.</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
</schemalist>
|
||||
</gconfschemafile>
|
||||
|
|
|
@ -166,7 +166,6 @@ class vmmConfig:
|
|||
|
||||
def get_secret_name(self, vm):
|
||||
return "vm-console-" + vm.get_uuid()
|
||||
|
||||
def has_keyring(self):
|
||||
if self.keyring == None:
|
||||
self.keyring = vmmKeyring()
|
||||
|
@ -216,3 +215,44 @@ class vmmConfig:
|
|||
id = self.keyring.add_secret(secret)
|
||||
if id != None:
|
||||
self.conf.set_int(self.conf_dir + "/console/passwords/" + vm.get_uuid(), id)
|
||||
|
||||
def get_url_list_length(self):
|
||||
length = self.conf.get_int(self.conf_dir + "/urls/url-list-length")
|
||||
if length < 5:
|
||||
return 5
|
||||
return length
|
||||
|
||||
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)
|
||||
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
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
def get_media_urls(self):
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import gobject
|
|||
import gtk
|
||||
import gtk.gdk
|
||||
import gtk.glade
|
||||
import pango
|
||||
import xeninst
|
||||
import os, sys
|
||||
import subprocess
|
||||
|
@ -79,6 +80,8 @@ class vmmCreate(gobject.GObject):
|
|||
"on_storage_file_address_changed": self.toggle_storage_size,
|
||||
"on_storage_toggled" : self.change_storage_type,
|
||||
"on_media_toggled" : self.change_media_type,
|
||||
"on_pv_media_url_changed" : self.change_combo_box,
|
||||
"on_pv_ks_url_changed" : self.change_combo_box,
|
||||
})
|
||||
self.set_initial_state()
|
||||
|
||||
|
@ -115,6 +118,25 @@ class vmmCreate(gobject.GObject):
|
|||
cd_list.add_attribute(text, 'sensitive', 2)
|
||||
self.populate_opt_media(cd_model)
|
||||
|
||||
# set up the lists for the url widgets
|
||||
media_url_list = self.window.get_widget("pv-media-url")
|
||||
media_url_model = gtk.ListStore(str)
|
||||
media_url_list.set_model(media_url_model)
|
||||
text = gtk.CellRendererText()
|
||||
text.set_property("alignment", pango.ALIGN_LEFT)
|
||||
text.set_property("xalign", 0.0)
|
||||
media_url_list.pack_start(text, True)
|
||||
media_url_list.add_attribute(text, 'text', 0)
|
||||
|
||||
ks_url_list = self.window.get_widget("pv-ks-url")
|
||||
ks_url_model = gtk.ListStore(str)
|
||||
ks_url_list.set_model(ks_url_model)
|
||||
text = gtk.CellRendererText()
|
||||
text.set_property("alignment", pango.ALIGN_LEFT)
|
||||
text.set_property("xalign", 0.0)
|
||||
ks_url_list.pack_start(text, True)
|
||||
ks_url_list.add_attribute(text, 'text', 0)
|
||||
|
||||
self.window.get_widget("create-cpus-physical").set_text(str(self.connection.host_maximum_processor_count()))
|
||||
|
||||
def reset_state(self):
|
||||
|
@ -132,8 +154,6 @@ class vmmCreate(gobject.GObject):
|
|||
self.window.get_widget("virt-method-pv").set_active(True)
|
||||
self.window.get_widget("media-iso-image").set_active(True)
|
||||
self.window.get_widget("fv-iso-location").set_text("")
|
||||
self.window.get_widget("pv-media-url").set_text("")
|
||||
self.window.get_widget("pv-ks-url").set_text("")
|
||||
self.window.get_widget("storage-partition").set_active(True)
|
||||
self.window.get_widget("storage-partition-address").set_text("")
|
||||
self.window.get_widget("storage-file-address").set_text("")
|
||||
|
@ -141,6 +161,10 @@ class vmmCreate(gobject.GObject):
|
|||
self.window.get_widget("create-memory-max").set_value(500)
|
||||
self.window.get_widget("create-memory-startup").set_value(500)
|
||||
self.window.get_widget("create-vcpus").set_value(1)
|
||||
model = self.window.get_widget("pv-media-url").get_model()
|
||||
self.populate_url_model(model, self.config.get_media_urls())
|
||||
model = self.window.get_widget("pv-ks-url").get_model()
|
||||
self.populate_url_model(model, self.config.get_kickstart_urls())
|
||||
|
||||
self.install_error = None
|
||||
|
||||
|
@ -187,7 +211,12 @@ class vmmCreate(gobject.GObject):
|
|||
|
||||
def get_config_install_source(self):
|
||||
if self.get_config_method() == VM_PARA_VIRT:
|
||||
return self.window.get_widget("pv-media-url").get_text()
|
||||
widget = self.window.get_widget("pv-media-url")
|
||||
url= widget.child.get_text()
|
||||
# Add the URL to the list, if it's different
|
||||
self.config.add_media_url(url)
|
||||
self.populate_url_model(widget.get_model(), self.config.get_media_urls())
|
||||
return url
|
||||
else:
|
||||
if self.window.get_widget("media-iso-image").get_active():
|
||||
return self.window.get_widget("fv-iso-location").get_text()
|
||||
|
@ -198,7 +227,11 @@ class vmmCreate(gobject.GObject):
|
|||
|
||||
def get_config_kickstart_source(self):
|
||||
if self.get_config_method() == VM_PARA_VIRT:
|
||||
return self.window.get_widget("pv-ks-url").get_text()
|
||||
widget = self.window.get_widget("pv-ks-url")
|
||||
url = widget.child.get_text()
|
||||
self.config.add_kickstart_url(url)
|
||||
self.populate_url_model(widget.get_model(), self.config.get_kickstart_urls())
|
||||
return url
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
@ -595,3 +628,18 @@ class vmmCreate(gobject.GObject):
|
|||
if idx == active:
|
||||
cdlist.set_active(-1)
|
||||
idx = idx + 1
|
||||
|
||||
def populate_url_model(self, model, urls):
|
||||
model.clear()
|
||||
for url in urls:
|
||||
model.append([url])
|
||||
|
||||
def change_combo_box(self, box):
|
||||
model = box.get_model()
|
||||
try:
|
||||
box.child.set_text(model.get_value(box.get_active_iter(), 0))
|
||||
except TypeError, e:
|
||||
# pygtk throws a bogus type error here, ignore it
|
||||
return
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue