Re-factored config changing UI to deal with inactive domains & better handle Dom0

This commit is contained in:
Daniel P. Berrange
2006-11-13 15:31:17 -05:00
parent 4b77b24532
commit c832682211
3 changed files with 346 additions and 279 deletions

View File

@@ -1529,34 +1529,6 @@ Jeremy Katz <katzj@redhat.com>
<property name="row_spacing">3</property>
<property name="column_spacing">3</property>
<child>
<widget class="GtkLabel" id="label333">
<property name="visible">True</property>
<property name="label" translatable="yes">Change allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label334">
<property name="visible">True</property>
@@ -1613,34 +1585,6 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</packing>
</child>
<child>
<widget class="GtkLabel" id="label336">
<property name="visible">True</property>
<property name="label" translatable="yes">Current allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="state-host-cpus">
<property name="visible">True</property>
@@ -1670,9 +1614,9 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</child>
<child>
<widget class="GtkLabel" id="state-vm-max-vcpus">
<widget class="GtkLabel" id="label333">
<property name="visible">True</property>
<property name="label" translatable="yes">2</property>
<property name="label" translatable="yes">Change allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1688,10 +1632,10 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -1718,8 +1662,8 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -1735,18 +1679,74 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">2 1 32 1 2 2</property>
<property name="adjustment">1 1 32 1 2 2</property>
<signal name="changed" handler="on_config_vcpus_changed" last_modification_time="Fri, 22 Sep 2006 15:41:27 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label347">
<property name="visible">True</property>
<property name="label" translatable="yes">Current allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="state-vm-maxvcpus">
<property name="visible">True</property>
<property name="label" translatable="yes">8</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
@@ -1873,36 +1873,22 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</child>
<child>
<widget class="GtkAlignment" id="alignment25">
<widget class="GtkHButtonBox" id="hbuttonbox5">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">5</property>
<property name="left_padding">0</property>
<property name="right_padding">5</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">5</property>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox5">
<widget class="GtkButton" id="config-vcpus-apply">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">5</property>
<child>
<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>
<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_vcpus_apply_clicked" last_modification_time="Mon, 13 Nov 2006 16:56:56 GMT"/>
</widget>
</child>
</widget>
@@ -2009,34 +1995,6 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="row_spacing">3</property>
<property name="column_spacing">3</property>
<child>
<widget class="GtkLabel" id="label60">
<property name="visible">True</property>
<property name="label" translatable="yes">Change allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label61">
<property name="visible">True</property>
@@ -2093,34 +2051,6 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</packing>
</child>
<child>
<widget class="GtkLabel" id="label309">
<property name="visible">True</property>
<property name="label" translatable="yes">Current allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="state-host-memory">
<property name="visible">True</property>
@@ -2150,9 +2080,70 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</child>
<child>
<widget class="GtkLabel" id="state-vm-maxmem">
<widget class="GtkHBox" id="hbox47">
<property name="visible">True</property>
<property name="label" translatable="yes">200 MB</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkSpinButton" id="config-maxmem">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">50 50 32000 5 10 10</property>
<signal name="changed" handler="on_config_maxmem_changed" last_modification_time="Mon, 13 Nov 2006 17:34:48 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label346">
<property name="visible">True</property>
<property name="label" translatable="yes">MB</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label309">
<property name="visible">True</property>
<property name="label" translatable="yes">Current allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -2168,10 +2159,38 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label60">
<property name="visible">True</property>
<property name="label" translatable="yes">Change allocation:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -2198,8 +2217,8 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -2259,8 +2278,8 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
@@ -2377,16 +2396,16 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment28">
<widget class="GtkAlignment" id="alignment132">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow7">
@@ -2439,7 +2458,7 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="padding">15</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
@@ -2585,98 +2604,84 @@ Jeremy Katz &lt;katzj@redhat.com&gt;
</child>
<child>
<widget class="GtkFrame" id="frame7">
<widget class="GtkVBox" id="vbox52">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkAlignment" id="alignment37">
<widget class="GtkFrame" id="frame7">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkVBox" id="vbox18">
<widget class="GtkAlignment" id="alignment133">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">3</property>
<property name="bottom_padding">3</property>
<property name="left_padding">12</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkAlignment" id="alignment38">
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">0</property>
<property name="right_padding">5</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<widget class="GtkTreeView" id="network-view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="network-view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label114">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Network&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<child>
<widget class="GtkLabel" id="label114">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Network&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="type">label_item</property>
<property name="padding">15</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>

View File

@@ -102,9 +102,10 @@ class vmmDetails(gobject.GObject):
"on_details_menu_serial_activate": self.control_vm_terminal,
"on_details_menu_view_toolbar_activate": self.toggle_toolbar,
"on_config_cpus_apply_clicked": self.config_cpus_apply,
"on_config_vcpus_changed": self.config_vm_cpus,
"on_config_memory_changed": self.config_memory_value,
"on_config_vcpus_apply_clicked": self.config_vcpus_apply,
"on_config_vcpus_changed": self.config_vcpus_changed,
"on_config_memory_changed": self.config_memory_changed,
"on_config_maxmem_changed": self.config_maxmem_changed,
"on_config_memory_apply_clicked": self.config_memory_apply
})
@@ -116,10 +117,7 @@ class vmmDetails(gobject.GObject):
self.refresh_resources(vm)
self.prepare_disk_list()
self.populate_disk_list()
self.prepare_network_list()
self.populate_network_list()
def toggle_toolbar(self, src):
if src.get_active():
@@ -161,18 +159,19 @@ class vmmDetails(gobject.GObject):
pagenum = active[0].get_value(active[1], 0)
self.window.get_widget("hw-panel").set_sensitive(True)
self.window.get_widget("hw-panel").set_current_page(pagenum)
if self.vm.is_read_only():
self.window.get_widget("hw-panel").get_nth_page(pagenum).set_sensitive(False)
else:
self.window.get_widget("hw-panel").get_nth_page(pagenum).set_sensitive(True)
if pagenum == 0:
self.window.get_widget("config-vcpus-apply").set_sensitive(False)
self.refresh_config_cpu()
elif pagenum == 1:
self.window.get_widget("config-memory-apply").set_sensitive(False)
self.refresh_config_memory()
elif pagenum == 2:
self.refresh_config_disk()
elif pagenum == 3:
self.refresh_config_network()
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):
status = self.vm.status()
@@ -225,10 +224,15 @@ class vmmDetails(gobject.GObject):
if status in [ libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
self.window.get_widget("control-run").set_sensitive(True)
self.window.get_widget("details-menu-run").set_sensitive(True)
self.window.get_widget("config-vcpus").set_sensitive(True)
self.window.get_widget("config-memory").set_sensitive(True)
self.window.get_widget("config-maxmem").set_sensitive(True)
else:
self.window.get_widget("control-run").set_sensitive(False)
self.window.get_widget("details-menu-run").set_sensitive(False)
self.window.get_widget("config-vcpus").set_sensitive(self.vm.is_vcpu_hotplug_capable())
self.window.get_widget("config-memory").set_sensitive(self.vm.is_memory_hotplug_capable())
self.window.get_widget("config-maxmem").set_sensitive(False)
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ] or vm.is_read_only():
self.window.get_widget("control-pause").set_sensitive(False)
@@ -261,9 +265,22 @@ class vmmDetails(gobject.GObject):
else:
self.window.get_widget("details-menu-serial").set_sensitive(False)
def refresh_resources(self, vm):
def refresh_resources(self, ignore):
self.refresh_summary()
hw = self.window.get_widget("hw-panel")
pagenum = hw.get_current_page()
if pagenum == 0:
self.refresh_config_cpu()
elif pagenum == 1:
self.refresh_config_memory()
#elif pagenum == 2:
# self.refresh_config_disk()
#elif pagenum == 3:
# self.refresh_config_network()
def refresh_summary(self):
self.window.get_widget("overview-cpu-usage-text").set_text("%d %%" % self.vm.cpu_time_percentage())
vm_maxmem = self.vm.maximum_memory()
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))
@@ -281,47 +298,81 @@ 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-maxmem").set_text("%d MB" % (vm_maxmem/1024))
self.window.get_widget("state-vm-memory").set_text("%d MB" % (vm_memory/1024))
def refresh_config_cpu(self):
self.window.get_widget("state-host-cpus").set_text("%d" % self.vm.get_connection().host_active_processor_count())
self.window.get_widget("config-vcpus").get_adjustment().upper = vm.vcpu_max_count()
self.window.get_widget("state-vm-vcpus").set_text("%d" % (vm.vcpu_count()))
self.window.get_widget("state-vm-max-vcpus").set_text("%d" % (vm.vcpu_max_count()))
status = self.vm.status()
if status in [ libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
self.window.get_widget("config-vcpus").get_adjustment().upper = 32
self.window.get_widget("state-vm-maxvcpus").set_text("32")
else:
self.window.get_widget("config-vcpus").get_adjustment().upper = self.vm.vcpu_max_count()
self.window.get_widget("state-vm-maxvcpus").set_text("%d" % (self.vm.vcpu_max_count()))
def update_config_memory(self):
self.window.get_widget("config-memory").get_adjustment().value = self.vm.current_memory()/1024
if not(self.window.get_widget("config-vcpus-apply").get_property("sensitive")):
self.window.get_widget("config-vcpus").get_adjustment().value = self.vm.vcpu_count()
# XXX hack - changing the value above will have just re-triggered
# the callback making apply button sensitive again. So we have to
# turn it off again....
self.window.get_widget("config-vcpus-apply").set_sensitive(False)
self.window.get_widget("state-vm-vcpus").set_text("%d" % (self.vm.vcpu_count()))
def update_config_cpus(self):
self.window.get_widget("config-vcpus").get_adjustment().value = self.vm.vcpu_count()
def refresh_config_memory(self):
self.window.get_widget("state-host-memory").set_text("%d MB" % (self.vm.get_connection().host_memory_size()/1024))
if self.window.get_widget("config-memory-apply").get_property("sensitive"):
self.window.get_widget("config-memory").get_adjustment().upper = self.window.get_widget("config-maxmem").get_adjustment().value
else:
self.window.get_widget("config-memory").get_adjustment().value = self.vm.current_memory()/1024
self.window.get_widget("config-maxmem").get_adjustment().value = self.vm.maximum_memory()/1024
# XXX hack - changing the value above will have just re-triggered
# the callback making apply button sensitive again. So we have to
# turn it off again....
self.window.get_widget("config-memory-apply").set_sensitive(False)
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
self.window.get_widget("state-vm-memory").set_text("%d MB" % (self.vm.current_memory()/1024))
def refresh_config_disk(self):
self.populate_disk_list()
def refresh_config_network(self):
self.populate_network_list()
def config_vcpus_changed(self, src):
self.window.get_widget("config-vcpus-apply").set_sensitive(True)
def config_vcpus_apply(self, src):
vcpus = self.window.get_widget("config-vcpus").get_adjustment().value
# if requested # of CPUS > host CPUS, pop up warning dialog (not implemented yet)
logging.info("Setting vcpus for " + self.vm.get_uuid() + " to " + str(vcpus))
self.vm.set_vcpu_count(vcpus)
self.window.get_widget("config-cpus-apply").set_sensitive(False)
self.window.get_widget("config-vcpus-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):
def config_memory_changed(self, src):
self.window.get_widget("config-memory-apply").set_sensitive(True)
def config_maxmem_changed(self, src):
self.window.get_widget("config-memory-apply").set_sensitive(True)
memory = self.window.get_widget("config-maxmem").get_adjustment().value
memadj = self.window.get_widget("config-memory").get_adjustment()
memadj.upper = memory
if memadj.value > memory:
memadj.value = memory
def config_memory_apply(self, src):
status = self.vm.status()
if status in [ libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
memory = self.window.get_widget("config-maxmem").get_adjustment().value
logging.info("Setting max memory for " + self.vm.get_uuid() + " to " + str(memory))
self.vm.set_max_memory(memory*1024)
memory = self.window.get_widget("config-memory").get_adjustment().value
newmem = self.vm.set_memory(memory*1024)
logging.info("Setting memory for " + self.vm.get_uuid() + " to " + str(memory))
self.vm.set_memory(memory*1024)
self.window.get_widget("config-memory-apply").set_sensitive(False)
self.window.get_widget("state-vm-memory").set_text("%d MB" % (newmem/1024))
def prepare_disk_list(self):
disks = self.window.get_widget("storage-view")
@@ -358,9 +409,10 @@ class vmmDetails(gobject.GObject):
disks = self.window.get_widget("storage-view")
disksModel = disks.get_model()
disksModel.clear()
for d in diskList:
disksModel.append(None, d)
def prepare_network_list(self):
nets = self.window.get_widget("network-view")
netsModel = gtk.TreeStore(str,str,str,str)
@@ -396,8 +448,8 @@ class vmmDetails(gobject.GObject):
nets = self.window.get_widget("network-view")
netsModel = nets.get_model()
netsModel.clear()
for d in netList:
netsModel.append(None, d)
gobject.type_register(vmmDetails)

View File

@@ -82,6 +82,16 @@ class vmmDomain(gobject.GObject):
return True
return False
def is_vcpu_hotplug_capable(self):
if self.connection.is_read_only():
return False
return True
def is_memory_hotplug_capable(self):
if self.connection.is_read_only():
return False
return True
def _normalize_status(self, status):
if status == libvirt.VIR_DOMAIN_NOSTATE:
return libvirt.VIR_DOMAIN_RUNNING