Skip to content

Commit

Permalink
Merge pull request #400 from mykaul/multiple_ips
Browse files Browse the repository at this point in the history
Add a function to get all the IPs of a VM
  • Loading branch information
lago-bot committed Dec 26, 2016
2 parents d62571f + dbb538e commit bfd635d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lago/plugins/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ def iscsi_name(self):
def ip(self):
return str(self.virt_env.get_net().resolve(self.name()))

def all_ips(self):
nets = {}
ips = []
nets = self.virt_env.get_nets()
for net in nets.values():
mapping = net.mapping()
for hostname, ip in mapping.items():
if hostname.startswith(self.name()):
ips.append(str(ip))
return ips

def ssh(
self,
command,
Expand Down
3 changes: 3 additions & 0 deletions lago/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ def add_mapping(self, name, ip, save=True):
def resolve(self, name):
return self._spec['mapping'][name]

def mapping(self):
return self._spec['mapping']

def _libvirt_name(self):
return self._env.prefixed_name(self.name(), max_length=15)

Expand Down

0 comments on commit bfd635d

Please sign in to comment.