From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
attach a network interface to vm in mockmodel
detach a network interface for vm in mockmodel
Signed-off-by: ShaoHe Feng <shaohef(a)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