Add teeth to set-memory page, and almost teeth to set-cpus page

This commit is contained in:
Hugh O. Brock
2006-07-26 18:19:33 -04:00
parent 3df5ce6225
commit fa4075d84e
3 changed files with 71 additions and 33 deletions

View File

@@ -1508,7 +1508,7 @@ Máirín Duffy <duffy@redhat.com>
</child>
<child>
<widget class="GtkSpinButton" id="cpus-desired">
<widget class="GtkSpinButton" id="config-vm-cpus">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
@@ -1518,6 +1518,7 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">1 1 32 1 10 10</property>
<signal name="changed" handler="on_config_vm_cpus_changed" last_modification_time="Wed, 26 Jul 2006 21:40:26 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -1558,7 +1559,7 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
</child>
<child>
<widget class="GtkLabel" id="physical-cpus">
<widget class="GtkLabel" id="state-host-cpus">
<property name="visible">True</property>
<property name="label" translatable="yes">256 </property>
<property name="use_underline">False</property>
@@ -1575,7 +1576,7 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<accessibility>
<atkproperty name="AtkObject::accessible_name" translatable="yes">physical-cpus</atkproperty>
<atkproperty name="AtkObject::accessible_name" translatable="yes">state-host-cpus</atkproperty>
</accessibility>
</widget>
<packing>
@@ -1724,26 +1725,16 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="spacing">5</property>
<child>
<widget class="GtkButton" id="button14">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button15">
<widget class="GtkButton" id="config-cpus-apply">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-apply</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_config_cpus_apply_clicked" last_modification_time="Wed, 26 Jul 2006 21:03:46 GMT"/>
</widget>
</child>
</widget>
@@ -1851,7 +1842,8 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="digits">1</property>
<property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
<property name="inverted">False</property>
<property name="adjustment">10.2 0 100 0 0 0</property>
<property name="adjustment">256 0 1024 0 0 0</property>
<signal name="value_changed" handler="on_config_memory_value_changed" last_modification_time="Wed, 26 Jul 2006 22:00:46 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -2017,6 +2009,9 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<accessibility>
<atkproperty name="AtkObject::accessible_name" translatable="yes">state-host-memory</atkproperty>
</accessibility>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -2056,26 +2051,16 @@ Máirín Duffy &lt;duffy@redhat.com&gt;
<property name="spacing">5</property>
<child>
<widget class="GtkButton" id="button18">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button19">
<widget class="GtkButton" id="config-memory-apply">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-apply</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_config_memory_apply_clicked" last_modification_time="Wed, 26 Jul 2006 22:01:44 GMT"/>
</widget>
</child>
</widget>

View File

@@ -112,13 +112,15 @@ class vmmDetails(gobject.GObject):
"on_control_terminal_clicked": self.control_vm_terminal,
"on_control_save_clicked": self.control_vm_save_domain,
"on_control_console_clicked": self.control_vm_console,
"on_config_cpus_apply_clicked": self.config_cpus_apply,
"on_config_vm_cpus_changed": self.config_vm_cpus,
"on_config_memory_value_changed": self.config_memory_value,
"on_config_memory_apply_clicked": self.config_memory_apply
})
self.hw_selected()
self.vm.connect("status-changed", self.update_widget_states)
self.vm.connect("resources-sampled", self.refresh_resources)
cpus = self.vm.get_connection().host_maximum_processor_count()
self.window.get_widget("physical-cpus").set_text(`cpus`)
self.update_widget_states(vm, vm.status())
self.refresh_resources(vm)
@@ -147,6 +149,12 @@ class vmmDetails(gobject.GObject):
self.window.get_widget("hw-panel").set_current_page(active[0].get_value(active[1], 0))
else:
self.window.get_widget("hw-panel").set_sensitive(False)
# When the user changes tabs on the hw panel, reset to the default state
self.update_config_memory()
self.update_config_cpus()
self.update_state_cpus()
self.window.get_widget("config-memory-apply").set_sensitive(False)
self.window.get_widget("config-cpus-apply").set_sensitive(False)
def control_vm_run(self, src):
return 0
@@ -217,7 +225,9 @@ class vmmDetails(gobject.GObject):
def refresh_resources(self, vm):
self.window.get_widget("overview-cpu-usage-text").set_text("%d %%" % self.vm.cpu_time_percentage())
self.window.get_widget("overview-memory-usage-text").set_text("%d MB of %d MB" % (self.vm.current_memory()/1024, self.vm.get_connection().host_memory_size()/1024))
vm_memory = self.vm.current_memory()
host_memory = self.vm.get_connection().host_memory_size()
self.window.get_widget("overview-memory-usage-text").set_text("%d MB of %d MB" % (vm_memory/1024, host_memory/1024))
history_len = self.config.get_stats_history_length()
cpu_vector = self.vm.cpu_time_vector()
@@ -232,5 +242,40 @@ class vmmDetails(gobject.GObject):
network_vector.reverse()
self.network_traffic_graph.set_property("data_array", network_vector)
# update HW config values
self.window.get_widget("state-host-memory").set_text("%d MB" % (host_memory/1024))
self.window.get_widget("config-memory").get_adjustment().upper = vm.maximum_memory()/1024
self.window.get_widget("state-vm-memory").set_text("%d MB" % (vm_memory/1024))
def update_config_memory(self):
self.window.get_widget("config-memory").get_adjustment().value = self.vm.current_memory()/1024
def update_config_cpus(self):
self.window.get_widget("config-vm-cpus").get_adjustment().value = self.vm.vcpu_count()
def update_state_cpus(self):
self.window.get_widget("state-host-cpus").set_text(`(self.vm.get_connection().host_maximum_processor_count())`)
def config_cpus_apply(self, src):
# Apply the change to the number of CPUs
vcpus = self.window.get_widget("config-vm-cpus").get_adjustment().value
# if requested # of CPUS > host CPUS, pop up warning dialog (not implemented yet)
self.vm.set_vcpu_count(vcpus)
self.window.get_widget("config-cpus-apply").set_sensitive(False)
def config_vm_cpus(self, src):
# cpu spinbox changed, make the apply button available
self.window.get_widget("config-cpus-apply").set_sensitive(True)
def config_memory_value(self, src):
self.window.get_widget("config-memory-apply").set_sensitive(True)
def config_memory_apply(self, src):
memory = self.window.get_widget("config-memory").get_adjustment().value
newmem = self.vm.set_memory(memory)
self.window.get_widget("config-memory-apply").set_sensitive(False)
self.window.get_widget("state-vm-memory").set_text("%d MB" % (newmem/1024))
gobject.type_register(vmmDetails)

View File

@@ -270,5 +270,13 @@ class vmmDomain(gobject.GObject):
# added
return ["vnc", "localhost", 5900 + self.get_id()]
def set_vcpu_count(self, vcpus):
print "If this was implemented, it would set this domain to have " + `vcpus` + " virtual cpus."
def set_memory(self, memory):
if(memory > self.maximum_memory()):
print "XXX add proper error handling here. You may not set vm memory larger than the maximum set for the vm."
self.vm.setMemory(memory)
return self.vm.info()[2]
gobject.type_register(vmmDomain)