[Kimchi-devel] [PATCH V10 7/7] write the template OS info to vm metadata

Sheldon shaohef at linux.vnet.ibm.com
Mon Apr 28 15:36:26 UTC 2014


On 04/28/2014 08:57 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at 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 at linux.vnet.ibm.com>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vms.py | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index be720f3..da913db 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -223,6 +223,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):
> @@ -287,6 +289,21 @@ class VMModel(object):
>           node = self._build_access_elem(users, groups)
>           set_metadata_node(dom, ET.tostring(node))
>
> +    @staticmethod
> +    def vm_get_os_metadata(dom):
> +        os_xml = get_metadata_node(dom, "os") or """<os></os>"""
> +        os_elem = ET.fromstring(os_xml)
> +        return (os_elem.attrib.get("version"), os_elem.attrib.get("distro"))
> +
> +    @staticmethod
> +    def vm_updata_os_metadata(dom, params):
s/updata/update
please use this command to fix all typo.
Thanks.
$ git ls-files |grep -v README |xargs sed -i -e "s/updata/update/g"
> +        distro = params.get("os_distro")
> +        version = params.get("os_version")
> +        if distro is None:
> +            return
> +        os_elem = E.os({"distro": distro, "version": version})
> +        set_metadata_node(dom, ET.tostring(os_elem))
> +
>       def _static_vm_update(self, dom, params):
>           state = DOM_STATE_MAP[dom.info()[0]]
>           old_xml = new_xml = dom.XMLDesc(0)


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list