[virt-tools-list] [virt-manager] [PATCH 2/4] details: Add VM genid support
Lin Ma
lma at suse.com
Tue Mar 26 09:42:33 UTC 2019
Currently, It doesn't support manually specify the genid value in the
details window, Only supports auto value.
Signed-off-by: Lin Ma <lma at suse.com>
---
ui/details.ui | 38 ++++++++++++++++++++++++++++++++------
virtManager/details.py | 17 ++++++++++++++++-
virtManager/domain.py | 7 ++++++-
3 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/ui/details.ui b/ui/details.ui
index 8b3f939e..1ec5ac45 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -683,7 +683,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -737,6 +737,32 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="genid-checkbox">
+ <property name="label" translatable="yes">GENID</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <signal name="toggled" handler="on_genid_checkbox_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="overview-genid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label">91b5023f-614f-4a9c-b5e0-d79f949e0279</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
<child>
<object class="GtkLabel" id="title-label">
<property name="visible">True</property>
@@ -748,7 +774,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -759,7 +785,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -795,7 +821,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -810,7 +836,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
@@ -832,7 +858,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
</object>
diff --git a/virtManager/details.py b/virtManager/details.py
index 10398b56..a1428857 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -34,6 +34,7 @@ from .vsockdetails import vmmVsockDetails
# Parameters that can be edited in the details window
(EDIT_NAME,
+ EDIT_GENID,
EDIT_TITLE,
EDIT_MACHTYPE,
EDIT_FIRMWARE,
@@ -105,7 +106,7 @@ from .vsockdetails import vmmVsockDetails
EDIT_FS,
- EDIT_HOSTDEV_ROMBAR) = range(1, 58)
+ EDIT_HOSTDEV_ROMBAR) = range(1, 59)
# Columns in hw list model
@@ -521,6 +522,7 @@ class vmmDetails(vmmGObjectUI):
"on_details_pages_switch_page": self.switch_page,
"on_overview_name_changed": lambda *x: self.enable_apply(x, EDIT_NAME),
+ "on_genid_checkbox_toggled": self.on_genid_checkbox_toggled,
"on_overview_title_changed": lambda *x: self.enable_apply(x, EDIT_TITLE),
"on_machine_type_changed": lambda *x: self.enable_apply(x, EDIT_MACHTYPE),
"on_overview_firmware_changed": lambda *x: self.enable_apply(x, EDIT_FIRMWARE),
@@ -1663,6 +1665,11 @@ class vmmDetails(vmmGObjectUI):
if edittype not in self.active_edits:
self.active_edits.append(edittype)
+ # GENID
+ def on_genid_checkbox_toggled(self, src):
+ self.widget("overview-genid").set_sensitive(src.get_active())
+ self.enable_apply(EDIT_GENID)
+
# Idmap
def config_idmap_enable(self, src):
do_enable = src.get_active()
@@ -1961,6 +1968,10 @@ class vmmDetails(vmmGObjectUI):
kwargs = {}
hotplug_args = {}
+ if self.edited(EDIT_GENID):
+ kwargs["genid"] = self.widget("genid-checkbox").get_active()
+ hotplug_args["genid"] = kwargs["genid"]
+
if self.edited(EDIT_TITLE):
kwargs["title"] = self.widget("overview-title").get_text()
hotplug_args["title"] = kwargs["title"]
@@ -2444,6 +2455,10 @@ class vmmDetails(vmmGObjectUI):
# Basic details
self.widget("overview-name").set_text(self.vm.get_name())
self.widget("overview-uuid").set_text(self.vm.get_uuid())
+ genid = self.vm.get_genid() or False
+ if not self.is_customize_dialog:
+ self.widget("genid-checkbox").set_active(genid)
+ self.widget("overview-genid").set_text(self.vm.get_genid() or "")
desc = self.vm.get_description() or ""
desc_widget = self.widget("overview-description")
desc_widget.get_buffer().set_text(desc)
diff --git a/virtManager/domain.py b/virtManager/domain.py
index 2134bfbc..0e38868b 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -474,7 +474,7 @@ class vmmDomain(vmmLibvirtObject):
def define_overview(self, machine=_SENTINEL, description=_SENTINEL,
title=_SENTINEL, idmap_list=_SENTINEL, loader=_SENTINEL,
- nvram=_SENTINEL):
+ nvram=_SENTINEL, genid=_SENTINEL):
guest = self._make_xmlobj_to_define()
if machine != _SENTINEL:
guest.os.machine = machine
@@ -483,6 +483,8 @@ class vmmDomain(vmmLibvirtObject):
guest.description = description or None
if title != _SENTINEL:
guest.title = title or None
+ if genid != _SENTINEL:
+ guest.genid = genid or None
if loader != _SENTINEL:
if loader is None:
@@ -1180,6 +1182,9 @@ class vmmDomain(vmmLibvirtObject):
def get_description(self):
return self.get_xmlobj().description
+ def get_genid(self):
+ return self.get_xmlobj().genid
+
def get_memory(self):
return int(self.get_xmlobj().memory)
def maximum_memory(self):
--
2.21.0
More information about the virt-tools-list
mailing list