From b96c0a5566c5ba3073777c87a3b2d4a1c594726a Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Sat, 18 Nov 2017 10:36:56 +0200 Subject: [PATCH] Add ips_in_net() function - retrieve all IPs in a net Add a helper function to get all IPs a VM has in a specific network. Will be used to ensure in oVirt System Test that NFS goes over the storage network, and not the management network. --- lago/plugins/vm.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lago/plugins/vm.py b/lago/plugins/vm.py index 6a27a0a0..be498308 100644 --- a/lago/plugins/vm.py +++ b/lago/plugins/vm.py @@ -479,10 +479,21 @@ def all_ips(self): for net in nets.values(): mapping = net.mapping() for hostname, ip in mapping.items(): - if hostname.startswith(self.name()): + # hostname is - + if hostname.startswith(self.name() + "-"): ips.append(str(ip)) return ips + def ips_in_net(self, net_name): + ips = [] + net = self.virt_env.get_net(name=net_name) + mapping = net.mapping() + for hostname, ip in mapping.items(): + # hostname is - + if hostname.startswith(self.name() + "-"): + ips.append(str(ip)) + return ips + def ssh( self, command,