+ def get_vm_public_ip_by_nova(self, vm):
+ """
+ This method uses openstack nova api to retrieve vm public ip
+ :param vm: vm name
+ :return vm public ip
+ """
+ subnet = IPNetwork('{0}/{1}'.format(self.external_net_addr, self.external_net_prefix_len))
+ nova = openstackclient.Client(2, self.cloud['--os-username'], self.cloud['--os-password'], self.cloud['--os-tenant-id'], self.cloud['--os-auth-url'])
+ for i in nova.servers.list():
+ if i.name == vm:
+ for k, v in i.networks.items():
+ for ip in v:
+ if IPAddress(ip) in subnet:
+ return ip
+ return None
+