[Kimchi-devel] [PATCH V8 0/7] bug fix: get user and group when VM is running

Aline Manera alinefm at linux.vnet.ibm.com
Thu Apr 24 20:58:21 UTC 2014


Let me make a diagram about what this patch should cover:

1) Identify system has support for virDomain.metadata and 
virDomain.setMetadata
    FeatureTests.has_metadata_support() returns True or False
    It should not raise any exception
    Insert it in CapabilitiesModel (src/kimchi/model/config.py) that way 
we have all feature tests in one place

2) Use FeatureTests.has_metadata_support() result to SET metadata element
    KIMCHI_META_URL = "https://github.com/kimchi-project/kimchi/"
    KIMCHI_NAMESPACE = "kimchi"

    if FeatureTests.has_metadata_support():
       dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, <meta_xml>, 
KIMCHI_NAMESPACE, KIMCHI_META_URL)

The <meta_xml> should be something like, built in _get_metadata_node()
<kimchi>
     <access>
         <user>...</user>
         ...
         <group>...</group>
         ...
     </access>
     <os>
        ....
     </os>
</kimchi>

     # FeatureTests.has_metadata_support() is False
     else:
         # use ElementMaker (instead of original lxml.builder.E) to 
generate metadata xml
         E = lxml.builder.ElementMaker(namespace=KIMCHI_META_URL, 
nsmap={KIMCHI_NAMESPACE: KIMCHI_META_URL})
         # follow the same build process made on _get_metadata_node()

That way both xmls will be generated in same way

<kimchi:kimchi xmlns:kimchi="http://github.com/kimchi-project/kimchi">
     <kimchi:access>
         <kimchi:user>...</kimchi:user>
         ...
         <kimchi:group>...</kimchi:group>
         ...
     </kimchi:access>
     <kimchi:os>
        ....
     </kimchi:os>
</kimchi>

3) Use FeatureTests.has_metadata_support() result to GET metadata element
     if FeatureTests.has_metadata_support():
         return dom.metadata()
     else:
         # use lxml to return the metadata element

IMPORTANT: While using setMetadata() you need to ALWAYS provide the 
whole metadata XML otherwise the metadata info will be override.


On 04/24/2014 02:19 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> V7 -> V8
> add a feature test to probe libvirt support metadata.
> add namespace for manully metadata.
>
> V6 -> V7:
> After V6 rebase, still find one error code "KCHVM0029E" does not change.
>
> V5 -> V6:
> rebase
>
> V4 -> V5:
> it is wrong to call dom.isPersistent in V4, fix it.
>
> V3 -> V4:
> work around if libvirt do not support metadata API well.
>
> V2 -> V3:
> move the virDomain.metadata and virDomain.setMetadata to model/utils.py
> add testcase
>
> V1 -> V2:
> libvirt also support virDomain.metadata and virDomain.setMetadata two api.
> use virDomain.metadata to get the user and group.
> use virDomain.setMetadata to set the user and group.
>
> ShaoHe Feng (7):
>    Add two function to set and get domain xml metadata
>    bug fix: get user and group when vm is living.
>    update test case to set/get user and group when VM is running
>    write the template OS info to vm metadata
>    bug fix: call a method should be followed by "()"
>    add method to test libvirt api are available
>    manually manage the metadata element
>
>   src/kimchi/config.py.in    |  14 ++++++-
>   src/kimchi/featuretests.py |  44 ++++++++++++++++++-
>   src/kimchi/i18n.py         |   1 +
>   src/kimchi/model/utils.py  |  97 ++++++++++++++++++++++++++++++++++++++++++
>   src/kimchi/model/vms.py    | 102 ++++++++++++++++++++++++++++-----------------
>   tests/test_model.py        |  13 ++++++
>   6 files changed, 229 insertions(+), 42 deletions(-)
>




More information about the Kimchi-devel mailing list