Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 01/07/2014 04:50 AM, shaohef(a)linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
get all vms attach to a network
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 9488078..e928afc 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -473,8 +473,16 @@ class MockModel(object):
except KeyError:
raise NotFoundError("Network '%s'" % name)
+ def _get_vms_attach_to_a_network(self, network):
+ vms = []
+ for name, dom in self._mock_vms.iteritems():
+ if network in dom.networks:
+ vms.append(name)
+ return vms
+
def network_lookup(self, name):
network = self._get_network(name)
+ network.info['vms'] = self._get_vms_attach_to_a_network(name)
return network.info
def network_activate(self, name):
@@ -634,6 +642,7 @@ class MockVM(object):
self.uuid = uuid
self.name = name
self.disk_paths = []
+ self.networks = template_info['networks']
self.info = {'state': 'shutoff',
'stats': "{'cpu_utilization': 20,
'net_throughput' : 35, \
'net_throughput_peak': 100,
'io_throughput': 45, \