[Kimchi-devel] [PATCH 1/2] add two moethod to get/set vm iface model in metadata

Sheldon shaohef at linux.vnet.ibm.com
Wed Apr 23 01:26:40 UTC 2014


On 04/23/2014 01:56 AM, Aline Manera wrote:
> On 04/22/2014 09:48 AM, shaohef at linux.vnet.ibm.com wrote:
>> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>>
>> We store the model in metadata.
>> We can get it from metadata when we create a vm iface.
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> ---
>> src/kimchi/model/vmifaces.py | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/src/kimchi/model/vmifaces.py b/src/kimchi/model/vmifaces.py
>> index 9bf110e..30e5373 100644
>> --- a/src/kimchi/model/vmifaces.py
>> +++ b/src/kimchi/model/vmifaces.py
>> @@ -24,6 +24,8 @@ from lxml import etree, objectify
>> from lxml.builder import E
>>
>> from kimchi.exception import InvalidOperation, InvalidParameter, 
>> NotFoundError
>> +from kimchi.model.utils import get_vm_metadata_element
>> +from kimchi.model.utils import set_vm_metadata_element
>> from kimchi.model.vms import DOM_STATE_MAP, VMModel
>>
>>
>> @@ -37,6 +39,12 @@ class VMIfacesModel(object):
>> macs.append(iface.mac.get('address'))
>> return macs
>>
>> + def _vm_get_iface_metadata(self, dom):
>> + iface_xml = (get_vm_metadata_element(dom, "vmiface") or
>> + """<vmiface></vmiface>""")
>
> As it is stored in the VM xml, you can only use "iface"
ACK
>
>> + vmiface = objectify.fromstring(iface_xml)
>> + return vmiface.attrib.get("model")
>> +
>> def create(self, vm, params):
>> def randomMAC():
>> mac = [0x52, 0x54, 0x00,
>> @@ -99,6 +107,14 @@ class VMIfaceModel(object):
>> return iface
>> return None
>>
>> + @staticmethod
>> + def vm_updata_iface_metadata(dom, params):
>
> typo: updata
>
>> + model = params.get("model")
>> + if model is None:
>> + return
>> + iface = E.vmiface({"model": model})
>> + set_vm_metadata_element(dom, etree.tostring(iface))
>> +
>> def lookup(self, vm, mac):
>> info = {}
>>
>
>
>


-- 
Thanks and best regards!

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




More information about the Kimchi-devel mailing list