[Kimchi-devel] [PATCH V2 2/4] support create/delete VMIface: update mockmodel
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Wed Jan 22 17:09:32 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
attach a network interface to vm in mockmodel
detach a network interface from vm in mockmodel
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index e037366..bc63139 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -488,6 +488,20 @@ class MockModel(object):
def networks_get_list(self):
return sorted(self._mock_networks.keys())
+ def vmifaces_create(self, vm, params):
+ if (params["type"] == "network" and
+ params["network"] not in self.networks_get_list()):
+ raise InvalidParameter("%s is not an available network" %
+ params["network"])
+ dom = self._get_vm(vm)
+ iface = MockVMIface(params["network"])
+ ("model" in params.keys() and
+ iface.info.update({"model": params["model"]}))
+
+ mac = iface.info['mac']
+ dom.ifaces[mac] = iface
+ return mac
+
def vmifaces_get_list(self, vm):
dom = self._get_vm(vm)
macs = dom.ifaces.keys()
@@ -501,6 +515,13 @@ class MockModel(object):
raise NotFoundError('iface: "%s"' % mac)
return info
+ def vmiface_delete(self, vm, mac):
+ dom = self._get_vm(vm)
+ try:
+ del dom.ifaces[mac]
+ except KeyError:
+ raise NotFoundError('iface: "%s"' % mac)
+
def tasks_get_list(self):
with self.objstore as session:
return session.get_list('task')
--
1.8.4.2
More information about the Kimchi-devel
mailing list