def test_add_ips_to_server_rackspace_local_ipv4( self, mock_add_auto_ip, mock_get_floating_ip, mock_has_service): self.cloud._floating_ip_source = None self.cloud.force_ipv4 = False self.cloud._local_ipv6 = False mock_has_service.return_value = False server = fakes.make_fake_server( server_id='server-id', name='test-server', status="ACTIVE", addresses={ 'private': [{ 'addr': "10.223.160.141", 'version': 4 }], 'public': [{ 'addr': "104.130.246.91", 'version': 4 }, { 'addr': "2001:4800:7819:103:be76:4eff:fe05:8525", 'version': 6 }] } ) server_dict = meta.add_server_interfaces(self.cloud, server) new_server = self.cloud.add_ips_to_server(server=server_dict) mock_get_floating_ip.assert_not_called() mock_add_auto_ip.assert_not_called() self.assertEqual(new_server['interface_ip'], '104.130.246.91')
def test_add_ips_to_server_ipv6_only( self, mock_add_auto_ip, mock_get_floating_ip, mock_has_service): self.cloud._floating_ip_source = None self.cloud.force_ipv4 = False self.cloud._local_ipv6 = True mock_has_service.return_value = False server = fakes.make_fake_server( server_id='server-id', name='test-server', status="ACTIVE", addresses={ 'private': [{ 'addr': "10.223.160.141", 'version': 4 }], 'public': [{ u'OS-EXT-IPS-MAC:mac_addr': u'fa:16:3e:ae:7d:42', u'OS-EXT-IPS:type': u'fixed', 'addr': "2001:4800:7819:103:be76:4eff:fe05:8525", 'version': 6 }] } ) server_dict = meta.add_server_interfaces(self.cloud, server) new_server = self.cloud.add_ips_to_server(server=server_dict) mock_get_floating_ip.assert_not_called() mock_add_auto_ip.assert_not_called() self.assertEqual( new_server['interface_ip'], '2001:4800:7819:103:be76:4eff:fe05:8525') self.assertEqual(new_server['private_v4'], '10.223.160.141') self.assertEqual(new_server['public_v4'], '') self.assertEqual( new_server['public_v6'], '2001:4800:7819:103:be76:4eff:fe05:8525')
def test_add_ips_to_server_ipv6_only(self, mock_add_auto_ip, mock_get_floating_ip, mock_has_service): self.cloud._floating_ip_source = None self.cloud.force_ipv4 = False self.cloud._local_ipv6 = True mock_has_service.return_value = False server = fakes.make_fake_server( server_id='server-id', name='test-server', status="ACTIVE", addresses={ 'private': [{ 'addr': "10.223.160.141", 'version': 4 }], 'public': [{ u'OS-EXT-IPS-MAC:mac_addr': u'fa:16:3e:ae:7d:42', u'OS-EXT-IPS:type': u'fixed', 'addr': "2001:4800:7819:103:be76:4eff:fe05:8525", 'version': 6 }] }) server_dict = meta.add_server_interfaces(self.cloud, server) new_server = self.cloud.add_ips_to_server(server=server_dict) mock_get_floating_ip.assert_not_called() mock_add_auto_ip.assert_not_called() self.assertEqual(new_server['interface_ip'], '2001:4800:7819:103:be76:4eff:fe05:8525') self.assertEqual(new_server['private_v4'], '10.223.160.141') self.assertEqual(new_server['public_v4'], '') self.assertEqual(new_server['public_v6'], '2001:4800:7819:103:be76:4eff:fe05:8525')
def test_add_ips_to_server_rackspace_local_ipv4(self, mock_add_auto_ip, mock_get_floating_ip, mock_has_service): self.cloud._floating_ip_source = None self.cloud.force_ipv4 = False self.cloud._local_ipv6 = False mock_has_service.return_value = False server = fakes.make_fake_server( server_id='server-id', name='test-server', status="ACTIVE", addresses={ 'private': [{ 'addr': "10.223.160.141", 'version': 4 }], 'public': [{ 'addr': "104.130.246.91", 'version': 4 }, { 'addr': "2001:4800:7819:103:be76:4eff:fe05:8525", 'version': 6 }] }) server_dict = meta.add_server_interfaces(self.cloud, server) new_server = self.cloud.add_ips_to_server(server=server_dict) mock_get_floating_ip.assert_not_called() mock_add_auto_ip.assert_not_called() self.assertEqual(new_server['interface_ip'], '104.130.246.91')
def list_hosts(self, expand=True): hostvars = [] for cloud in self.clouds: # Cycle on servers for server in cloud.list_servers(): if expand: server_vars = cloud.get_openstack_vars(server) else: server_vars = meta.add_server_interfaces(cloud, server) hostvars.append(server_vars) return hostvars
def list_hosts(self, expand=True): hostvars = [] for cloud in self.clouds: # Cycle on servers for server in cloud.list_servers(): if expand: server_vars = cloud.get_openstack_vars(server) else: server_vars = meta.add_server_interfaces(cloud, server) hostvars.append(server_vars) return hostvars
def list_hosts(self, expand=True, fail_on_cloud_config=True): hostvars = [] for cloud in self.clouds: try: # Cycle on servers for server in cloud.list_servers(): if expand: server_vars = cloud.get_openstack_vars(server) else: server_vars = meta.add_server_interfaces(cloud, server) hostvars.append(server_vars) except shade.OpenStackCloudException: # Don't fail on one particular cloud as others may work if fail_on_cloud_config: raise return hostvars
def list_hosts(self, expand=True, fail_on_cloud_config=True): hostvars = [] for cloud in self.clouds: try: # Cycle on servers for server in cloud.list_servers(): if expand: server_vars = cloud.get_openstack_vars(server) else: server_vars = meta.add_server_interfaces(cloud, server) hostvars.append(server_vars) except shade.OpenStackCloudException: # Don't fail on one particular cloud as others may work if fail_on_cloud_config: raise return hostvars