Digitalocean public private ip (#27269)

* When using private networking the ip_address key contains the private ip.
Add the following info to module output when available:
  - private_ipv4_address
  - public_ipv4_address
  - private_ipv6_address
  - public_ipv6_address
pull/35694/head
Rob Nieuwenhuizen 7 years ago committed by Abhijeet Kasurde
parent c6f397b160
commit 4094ba7682

@ -232,6 +232,12 @@ class Droplet(JsonfyMixIn):
if attrs: if attrs:
for k, v in attrs.items(): for k, v in attrs.items():
setattr(self, k, v) setattr(self, k, v)
networks = attrs.get('networks', {})
for network in networks.get('v6', []):
if network['type'] == 'public':
setattr(self, 'public_ipv6_address', network['ip_address'])
else:
setattr(self, 'private_ipv6_address', network['ip_address'])
else: else:
json = self.manager.show_droplet(self.id) json = self.manager.show_droplet(self.id)
if json['ip_address']: if json['ip_address']:

Loading…
Cancel
Save