From: ShaoHe Feng <shaohef(a)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(a)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..5b8845f 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, "iface") or
+ """<iface></iface>""")
+ 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_update_iface_metadata(dom, params):
+ model = params.get("model")
+ if model is None:
+ return
+ iface = E.iface({"model": model})
+ set_vm_metadata_element(dom, etree.tostring(iface))
+
def lookup(self, vm, mac):
info = {}
--
1.9.0