From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Then kimchi can choose the divice mode depend on these info.
Note, the info is the initial OS when install OS on a blank guest.
OS may change after the install.
So other device should still keep their model info in the vm metadata.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/model/vms.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 652725a..5919032 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -221,6 +221,8 @@ class VMsModel(object):
raise OperationFailed("KCHVM0007E", {'name': name,
'err': e.get_error_message()})
+ VMModel.vm_updata_os_metadata(VMModel.get_vm(name, self.conn), t.info)
+
return name
def get_list(self):
@@ -276,6 +278,22 @@ class VMModel(object):
xml = self._get_metadata_node(users, groups)
set_vm_metadata_element(dom, ET.tostring(xml), "all")
+ @staticmethod
+ def vm_get_os_metadata(dom):
+ os_xml = (get_vm_metadata_element(dom, "OS") or
+ """<OS></OS>""")
+ OS = ET.fromstring(os_xml)
+ return (OS.attrib.get("version"), OS.attrib.get("distro"))
+
+ @staticmethod
+ def vm_updata_os_metadata(dom, params):
+ distro = params.get("os_distro")
+ version = params.get("os_version")
+ if distro is None:
+ return
+ OS = E.os({"distro": distro, "version": version})
+ set_vm_metadata_element(dom, ET.tostring(OS))
+
def _static_vm_update(self, dom, params):
state = DOM_STATE_MAP[dom.info()[0]]
--
1.9.0