def test_get_server_public_address_none(self): """ No public IP when none has been assigned yet """ server_class = namedtuple('Server', 'addresses') server = server_class(addresses=[]) self.assertEqual(openstack.get_server_public_address(server), None)
def public_ip(self): """ Return one of the public address(es) """ if not self.openstack_id: return None public_addr = openstack.get_server_public_address(self.os_server) if not public_addr: return None return public_addr['addr']
def public_ip(self): """ Return one of the public address(es) """ if not self.openstack_id: return None try: public_addr = openstack.get_server_public_address(self.os_server) except (requests.RequestException, novaclient.exceptions.ClientException): return None # Could not determine an IP based on the OS API if not public_addr: return None return public_addr["addr"]