[Kimchi-devel] [PATCH V3 2/4] support create/delete VMIface: update mockmodel
Aline Manera
alinefm at linux.vnet.ibm.com
Fri Jan 24 02:57:43 UTC 2014
Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>
On 01/24/2014 12:24 AM, shaohef at linux.vnet.ibm.com wrote:
> 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 b546434..916020a 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -518,6 +518,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()
> @@ -531,6 +545,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')
More information about the Kimchi-devel
mailing list