Merge "Split out Neutron ports client"
This commit is contained in:
commit
33580ffddb
@ -61,7 +61,7 @@ class DHCPAgentSchedulersTestJSON(base.BaseAdminNetworkTest):
|
|||||||
@test.idempotent_id('a0856713-6549-470c-a656-e97c8df9a14d')
|
@test.idempotent_id('a0856713-6549-470c-a656-e97c8df9a14d')
|
||||||
def test_add_remove_network_from_dhcp_agent(self):
|
def test_add_remove_network_from_dhcp_agent(self):
|
||||||
# The agent is now bound to the network, we can free the port
|
# The agent is now bound to the network, we can free the port
|
||||||
self.client.delete_port(self.port['id'])
|
self.ports_client.delete_port(self.port['id'])
|
||||||
self.ports.remove(self.port)
|
self.ports.remove(self.port)
|
||||||
agent = dict()
|
agent = dict()
|
||||||
agent['agent_type'] = None
|
agent['agent_type'] = None
|
||||||
|
@ -49,6 +49,6 @@ class ExternalNetworksAdminNegativeTestJSON(base.BaseAdminNetworkTest):
|
|||||||
|
|
||||||
# create a port which will internally create an instance-ip
|
# create a port which will internally create an instance-ip
|
||||||
self.assertRaises(lib_exc.Conflict,
|
self.assertRaises(lib_exc.Conflict,
|
||||||
client.create_port,
|
self.admin_ports_client.create_port,
|
||||||
network_id=CONF.network.public_network_id,
|
network_id=CONF.network.public_network_id,
|
||||||
fixed_ips=fixed_ips)
|
fixed_ips=fixed_ips)
|
||||||
|
@ -75,6 +75,7 @@ class BaseNetworkTest(tempest.test.BaseTestCase):
|
|||||||
cls.client = cls.os.network_client
|
cls.client = cls.os.network_client
|
||||||
cls.networks_client = cls.os.networks_client
|
cls.networks_client = cls.os.networks_client
|
||||||
cls.subnets_client = cls.os.subnets_client
|
cls.subnets_client = cls.os.subnets_client
|
||||||
|
cls.ports_client = cls.os.ports_client
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_setup(cls):
|
def resource_setup(cls):
|
||||||
@ -108,7 +109,7 @@ class BaseNetworkTest(tempest.test.BaseTestCase):
|
|||||||
metering_label['id'])
|
metering_label['id'])
|
||||||
# Clean up ports
|
# Clean up ports
|
||||||
for port in cls.ports:
|
for port in cls.ports:
|
||||||
cls._try_delete_resource(cls.client.delete_port,
|
cls._try_delete_resource(cls.ports_client.delete_port,
|
||||||
port['id'])
|
port['id'])
|
||||||
# Clean up routers
|
# Clean up routers
|
||||||
for router in cls.routers:
|
for router in cls.routers:
|
||||||
@ -201,8 +202,8 @@ class BaseNetworkTest(tempest.test.BaseTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create_port(cls, network, **kwargs):
|
def create_port(cls, network, **kwargs):
|
||||||
"""Wrapper utility that returns a test port."""
|
"""Wrapper utility that returns a test port."""
|
||||||
body = cls.client.create_port(network_id=network['id'],
|
body = cls.ports_client.create_port(network_id=network['id'],
|
||||||
**kwargs)
|
**kwargs)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
cls.ports.append(port)
|
cls.ports.append(port)
|
||||||
return port
|
return port
|
||||||
@ -210,8 +211,8 @@ class BaseNetworkTest(tempest.test.BaseTestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def update_port(cls, port, **kwargs):
|
def update_port(cls, port, **kwargs):
|
||||||
"""Wrapper utility that updates a test port."""
|
"""Wrapper utility that updates a test port."""
|
||||||
body = cls.client.update_port(port['id'],
|
body = cls.ports_client.update_port(port['id'],
|
||||||
**kwargs)
|
**kwargs)
|
||||||
return body['port']
|
return body['port']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -269,6 +270,7 @@ class BaseAdminNetworkTest(BaseNetworkTest):
|
|||||||
cls.admin_client = cls.os_adm.network_client
|
cls.admin_client = cls.os_adm.network_client
|
||||||
cls.admin_networks_client = cls.os_adm.networks_client
|
cls.admin_networks_client = cls.os_adm.networks_client
|
||||||
cls.admin_subnets_client = cls.os_adm.subnets_client
|
cls.admin_subnets_client = cls.os_adm.subnets_client
|
||||||
|
cls.admin_ports_client = cls.os_adm.ports_client
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_metering_label(cls, name, description):
|
def create_metering_label(cls, name, description):
|
||||||
|
@ -60,14 +60,14 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
|
|||||||
# Create port with allowed address pair attribute
|
# Create port with allowed address pair attribute
|
||||||
allowed_address_pairs = [{'ip_address': self.ip_address,
|
allowed_address_pairs = [{'ip_address': self.ip_address,
|
||||||
'mac_address': self.mac_address}]
|
'mac_address': self.mac_address}]
|
||||||
body = self.client.create_port(
|
body = self.ports_client.create_port(
|
||||||
network_id=self.network['id'],
|
network_id=self.network['id'],
|
||||||
allowed_address_pairs=allowed_address_pairs)
|
allowed_address_pairs=allowed_address_pairs)
|
||||||
port_id = body['port']['id']
|
port_id = body['port']['id']
|
||||||
self.addCleanup(self.client.delete_port, port_id)
|
self.addCleanup(self.ports_client.delete_port, port_id)
|
||||||
|
|
||||||
# Confirm port was created with allowed address pair attribute
|
# Confirm port was created with allowed address pair attribute
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
port = [p for p in ports if p['id'] == port_id]
|
port = [p for p in ports if p['id'] == port_id]
|
||||||
msg = 'Created port not found in list of ports returned by Neutron'
|
msg = 'Created port not found in list of ports returned by Neutron'
|
||||||
@ -76,9 +76,9 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
|
|||||||
|
|
||||||
def _update_port_with_address(self, address, mac_address=None, **kwargs):
|
def _update_port_with_address(self, address, mac_address=None, **kwargs):
|
||||||
# Create a port without allowed address pair
|
# Create a port without allowed address pair
|
||||||
body = self.client.create_port(network_id=self.network['id'])
|
body = self.ports_client.create_port(network_id=self.network['id'])
|
||||||
port_id = body['port']['id']
|
port_id = body['port']['id']
|
||||||
self.addCleanup(self.client.delete_port, port_id)
|
self.addCleanup(self.ports_client.delete_port, port_id)
|
||||||
if mac_address is None:
|
if mac_address is None:
|
||||||
mac_address = self.mac_address
|
mac_address = self.mac_address
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
|
|||||||
'mac_address': mac_address}]
|
'mac_address': mac_address}]
|
||||||
if kwargs:
|
if kwargs:
|
||||||
allowed_address_pairs.append(kwargs['allowed_address_pairs'])
|
allowed_address_pairs.append(kwargs['allowed_address_pairs'])
|
||||||
body = self.client.update_port(
|
body = self.ports_client.update_port(
|
||||||
port_id, allowed_address_pairs=allowed_address_pairs)
|
port_id, allowed_address_pairs=allowed_address_pairs)
|
||||||
allowed_address_pair = body['port']['allowed_address_pairs']
|
allowed_address_pair = body['port']['allowed_address_pairs']
|
||||||
self.assertEqual(allowed_address_pair, allowed_address_pairs)
|
self.assertEqual(allowed_address_pair, allowed_address_pairs)
|
||||||
@ -106,9 +106,9 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
|
|||||||
@test.idempotent_id('b3f20091-6cd5-472b-8487-3516137df933')
|
@test.idempotent_id('b3f20091-6cd5-472b-8487-3516137df933')
|
||||||
def test_update_port_with_multiple_ip_mac_address_pair(self):
|
def test_update_port_with_multiple_ip_mac_address_pair(self):
|
||||||
# Create an ip _address and mac_address through port create
|
# Create an ip _address and mac_address through port create
|
||||||
resp = self.client.create_port(network_id=self.network['id'])
|
resp = self.ports_client.create_port(network_id=self.network['id'])
|
||||||
newportid = resp['port']['id']
|
newportid = resp['port']['id']
|
||||||
self.addCleanup(self.client.delete_port, newportid)
|
self.addCleanup(self.ports_client.delete_port, newportid)
|
||||||
ipaddress = resp['port']['fixed_ips'][0]['ip_address']
|
ipaddress = resp['port']['fixed_ips'][0]['ip_address']
|
||||||
macaddress = resp['port']['mac_address']
|
macaddress = resp['port']['mac_address']
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
|
|||||||
del things_list[index]
|
del things_list[index]
|
||||||
|
|
||||||
def _clean_network(self):
|
def _clean_network(self):
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
for port in ports:
|
for port in ports:
|
||||||
if (port['device_owner'].startswith('network:router_interface')
|
if (port['device_owner'].startswith('network:router_interface')
|
||||||
@ -73,7 +73,7 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if port['id'] in [p['id'] for p in self.ports]:
|
if port['id'] in [p['id'] for p in self.ports]:
|
||||||
self.client.delete_port(port['id'])
|
self.ports_client.delete_port(port['id'])
|
||||||
self._remove_from_list_by_index(self.ports, port)
|
self._remove_from_list_by_index(self.ports, port)
|
||||||
body = self.subnets_client.list_subnets()
|
body = self.subnets_client.list_subnets()
|
||||||
subnets = body['subnets']
|
subnets = body['subnets']
|
||||||
@ -203,9 +203,9 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
|
|||||||
real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
|
real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
|
||||||
for sub in [subnet_dhcp,
|
for sub in [subnet_dhcp,
|
||||||
subnet_slaac]]
|
subnet_slaac]]
|
||||||
self.client.delete_port(port['id'])
|
self.ports_client.delete_port(port['id'])
|
||||||
self.ports.pop()
|
self.ports.pop()
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports_id_list = [i['id'] for i in body['ports']]
|
ports_id_list = [i['id'] for i in body['ports']]
|
||||||
self.assertNotIn(port['id'], ports_id_list)
|
self.assertNotIn(port['id'], ports_id_list)
|
||||||
self._clean_network()
|
self._clean_network()
|
||||||
@ -362,7 +362,7 @@ class NetworksTestDHCPv6(base.BaseNetworkTest):
|
|||||||
admin_state_up=True)
|
admin_state_up=True)
|
||||||
port = self.create_router_interface(router['id'],
|
port = self.create_router_interface(router['id'],
|
||||||
subnet['id'])
|
subnet['id'])
|
||||||
body = self.client.show_port(port['port_id'])
|
body = self.ports_client.show_port(port['port_id'])
|
||||||
return subnet, body['port']
|
return subnet, body['port']
|
||||||
|
|
||||||
@test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d')
|
@test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d')
|
||||||
|
@ -59,14 +59,14 @@ class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
|
|||||||
@test.idempotent_id('d2c17063-3767-4a24-be4f-a23dbfa133c9')
|
@test.idempotent_id('d2c17063-3767-4a24-be4f-a23dbfa133c9')
|
||||||
def test_create_list_port_with_extra_dhcp_options(self):
|
def test_create_list_port_with_extra_dhcp_options(self):
|
||||||
# Create a port with Extra DHCP Options
|
# Create a port with Extra DHCP Options
|
||||||
body = self.client.create_port(
|
body = self.ports_client.create_port(
|
||||||
network_id=self.network['id'],
|
network_id=self.network['id'],
|
||||||
extra_dhcp_opts=self.extra_dhcp_opts)
|
extra_dhcp_opts=self.extra_dhcp_opts)
|
||||||
port_id = body['port']['id']
|
port_id = body['port']['id']
|
||||||
self.addCleanup(self.client.delete_port, port_id)
|
self.addCleanup(self.ports_client.delete_port, port_id)
|
||||||
|
|
||||||
# Confirm port created has Extra DHCP Options
|
# Confirm port created has Extra DHCP Options
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
port = [p for p in ports if p['id'] == port_id]
|
port = [p for p in ports if p['id'] == port_id]
|
||||||
self.assertTrue(port)
|
self.assertTrue(port)
|
||||||
@ -76,12 +76,12 @@ class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
|
|||||||
def test_update_show_port_with_extra_dhcp_options(self):
|
def test_update_show_port_with_extra_dhcp_options(self):
|
||||||
# Update port with extra dhcp options
|
# Update port with extra dhcp options
|
||||||
name = data_utils.rand_name('new-port-name')
|
name = data_utils.rand_name('new-port-name')
|
||||||
body = self.client.update_port(
|
body = self.ports_client.update_port(
|
||||||
self.port['id'],
|
self.port['id'],
|
||||||
name=name,
|
name=name,
|
||||||
extra_dhcp_opts=self.extra_dhcp_opts)
|
extra_dhcp_opts=self.extra_dhcp_opts)
|
||||||
# Confirm extra dhcp options were added to the port
|
# Confirm extra dhcp options were added to the port
|
||||||
body = self.client.show_port(self.port['id'])
|
body = self.ports_client.show_port(self.port['id'])
|
||||||
self._confirm_extra_dhcp_options(body['port'], self.extra_dhcp_opts)
|
self._confirm_extra_dhcp_options(body['port'], self.extra_dhcp_opts)
|
||||||
|
|
||||||
def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
|
def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
|
||||||
|
@ -130,13 +130,13 @@ class FloatingIPTestJSON(base.BaseNetworkTest):
|
|||||||
self.addCleanup(self.client.delete_floatingip,
|
self.addCleanup(self.client.delete_floatingip,
|
||||||
created_floating_ip['id'])
|
created_floating_ip['id'])
|
||||||
# Create a port
|
# Create a port
|
||||||
port = self.client.create_port(network_id=self.network['id'])
|
port = self.ports_client.create_port(network_id=self.network['id'])
|
||||||
created_port = port['port']
|
created_port = port['port']
|
||||||
floating_ip = self.client.update_floatingip(
|
floating_ip = self.client.update_floatingip(
|
||||||
created_floating_ip['id'],
|
created_floating_ip['id'],
|
||||||
port_id=created_port['id'])
|
port_id=created_port['id'])
|
||||||
# Delete port
|
# Delete port
|
||||||
self.client.delete_port(created_port['id'])
|
self.ports_client.delete_port(created_port['id'])
|
||||||
# Verifies the details of the floating_ip
|
# Verifies the details of the floating_ip
|
||||||
floating_ip = self.client.show_floatingip(created_floating_ip['id'])
|
floating_ip = self.client.show_floatingip(created_floating_ip['id'])
|
||||||
shown_floating_ip = floating_ip['floatingip']
|
shown_floating_ip = floating_ip['floatingip']
|
||||||
@ -197,10 +197,10 @@ class FloatingIPTestJSON(base.BaseNetworkTest):
|
|||||||
list_ips = [str(ip) for ip in ips[-3:-1]]
|
list_ips = [str(ip) for ip in ips[-3:-1]]
|
||||||
fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
|
fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
|
||||||
# Create port
|
# Create port
|
||||||
body = self.client.create_port(network_id=self.network['id'],
|
body = self.ports_client.create_port(network_id=self.network['id'],
|
||||||
fixed_ips=fixed_ips)
|
fixed_ips=fixed_ips)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.addCleanup(self.client.delete_port, port['id'])
|
self.addCleanup(self.ports_client.delete_port, port['id'])
|
||||||
# Create floating ip
|
# Create floating ip
|
||||||
body = self.client.create_floatingip(
|
body = self.client.create_floatingip(
|
||||||
floating_network_id=self.ext_net_id,
|
floating_network_id=self.ext_net_id,
|
||||||
|
@ -444,9 +444,9 @@ class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
|
|||||||
|
|
||||||
def _delete_ports(self, created_ports):
|
def _delete_ports(self, created_ports):
|
||||||
for n in created_ports:
|
for n in created_ports:
|
||||||
self.client.delete_port(n['id'])
|
self.ports_client.delete_port(n['id'])
|
||||||
# Asserting that the ports are not found in the list after deletion
|
# Asserting that the ports are not found in the list after deletion
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports_list = [port['id'] for port in body['ports']]
|
ports_list = [port['id'] for port in body['ports']]
|
||||||
for n in created_ports:
|
for n in created_ports:
|
||||||
self.assertNotIn(n['id'], ports_list)
|
self.assertNotIn(n['id'], ports_list)
|
||||||
@ -522,7 +522,7 @@ class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
|
|||||||
created_ports = body['ports']
|
created_ports = body['ports']
|
||||||
self.addCleanup(self._delete_ports, created_ports)
|
self.addCleanup(self._delete_ports, created_ports)
|
||||||
# Asserting that the ports are found in the list after creation
|
# Asserting that the ports are found in the list after creation
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports_list = [port['id'] for port in body['ports']]
|
ports_list = [port['id'] for port in body['ports']]
|
||||||
for n in created_ports:
|
for n in created_ports:
|
||||||
self.assertIsNotNone(n['id'])
|
self.assertIsNotNone(n['id'])
|
||||||
|
@ -41,7 +41,7 @@ class NetworksNegativeTestJSON(base.BaseNetworkTest):
|
|||||||
@test.idempotent_id('a954861d-cbfd-44e8-b0a9-7fab111f235d')
|
@test.idempotent_id('a954861d-cbfd-44e8-b0a9-7fab111f235d')
|
||||||
def test_show_non_existent_port(self):
|
def test_show_non_existent_port(self):
|
||||||
non_exist_id = data_utils.rand_uuid()
|
non_exist_id = data_utils.rand_uuid()
|
||||||
self.assertRaises(lib_exc.NotFound, self.client.show_port,
|
self.assertRaises(lib_exc.NotFound, self.ports_client.show_port,
|
||||||
non_exist_id)
|
non_exist_id)
|
||||||
|
|
||||||
@test.attr(type=['negative'])
|
@test.attr(type=['negative'])
|
||||||
@ -79,13 +79,14 @@ class NetworksNegativeTestJSON(base.BaseNetworkTest):
|
|||||||
def test_create_port_on_non_existent_network(self):
|
def test_create_port_on_non_existent_network(self):
|
||||||
non_exist_net_id = data_utils.rand_uuid()
|
non_exist_net_id = data_utils.rand_uuid()
|
||||||
self.assertRaises(lib_exc.NotFound,
|
self.assertRaises(lib_exc.NotFound,
|
||||||
self.client.create_port, network_id=non_exist_net_id)
|
self.ports_client.create_port,
|
||||||
|
network_id=non_exist_net_id)
|
||||||
|
|
||||||
@test.attr(type=['negative'])
|
@test.attr(type=['negative'])
|
||||||
@test.idempotent_id('cf8eef21-4351-4f53-adcd-cc5cb1e76b92')
|
@test.idempotent_id('cf8eef21-4351-4f53-adcd-cc5cb1e76b92')
|
||||||
def test_update_non_existent_port(self):
|
def test_update_non_existent_port(self):
|
||||||
non_exist_port_id = data_utils.rand_uuid()
|
non_exist_port_id = data_utils.rand_uuid()
|
||||||
self.assertRaises(lib_exc.NotFound, self.client.update_port,
|
self.assertRaises(lib_exc.NotFound, self.ports_client.update_port,
|
||||||
non_exist_port_id, name='new_name')
|
non_exist_port_id, name='new_name')
|
||||||
|
|
||||||
@test.attr(type=['negative'])
|
@test.attr(type=['negative'])
|
||||||
@ -93,4 +94,4 @@ class NetworksNegativeTestJSON(base.BaseNetworkTest):
|
|||||||
def test_delete_non_existent_port(self):
|
def test_delete_non_existent_port(self):
|
||||||
non_exist_port_id = data_utils.rand_uuid()
|
non_exist_port_id = data_utils.rand_uuid()
|
||||||
self.assertRaises(lib_exc.NotFound,
|
self.assertRaises(lib_exc.NotFound,
|
||||||
self.client.delete_port, non_exist_port_id)
|
self.ports_client.delete_port, non_exist_port_id)
|
||||||
|
@ -45,8 +45,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
cls.port = cls.create_port(cls.network)
|
cls.port = cls.create_port(cls.network)
|
||||||
|
|
||||||
def _delete_port(self, port_id):
|
def _delete_port(self, port_id):
|
||||||
self.client.delete_port(port_id)
|
self.ports_client.delete_port(port_id)
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports_list = body['ports']
|
ports_list = body['ports']
|
||||||
self.assertFalse(port_id in [n['id'] for n in ports_list])
|
self.assertFalse(port_id in [n['id'] for n in ports_list])
|
||||||
|
|
||||||
@ -54,16 +54,16 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
@test.idempotent_id('c72c1c0c-2193-4aca-aaa4-b1442640f51c')
|
@test.idempotent_id('c72c1c0c-2193-4aca-aaa4-b1442640f51c')
|
||||||
def test_create_update_delete_port(self):
|
def test_create_update_delete_port(self):
|
||||||
# Verify port creation
|
# Verify port creation
|
||||||
body = self.client.create_port(network_id=self.network['id'])
|
body = self.ports_client.create_port(network_id=self.network['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
# Schedule port deletion with verification upon test completion
|
# Schedule port deletion with verification upon test completion
|
||||||
self.addCleanup(self._delete_port, port['id'])
|
self.addCleanup(self._delete_port, port['id'])
|
||||||
self.assertTrue(port['admin_state_up'])
|
self.assertTrue(port['admin_state_up'])
|
||||||
# Verify port update
|
# Verify port update
|
||||||
new_name = "New_Port"
|
new_name = "New_Port"
|
||||||
body = self.client.update_port(port['id'],
|
body = self.ports_client.update_port(port['id'],
|
||||||
name=new_name,
|
name=new_name,
|
||||||
admin_state_up=False)
|
admin_state_up=False)
|
||||||
updated_port = body['port']
|
updated_port = body['port']
|
||||||
self.assertEqual(updated_port['name'], new_name)
|
self.assertEqual(updated_port['name'], new_name)
|
||||||
self.assertFalse(updated_port['admin_state_up'])
|
self.assertFalse(updated_port['admin_state_up'])
|
||||||
@ -107,8 +107,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
'end': str(address + 6)}]}
|
'end': str(address + 6)}]}
|
||||||
subnet = self.create_subnet(network, **allocation_pools)
|
subnet = self.create_subnet(network, **allocation_pools)
|
||||||
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
||||||
body = self.client.create_port(network_id=net_id)
|
body = self.ports_client.create_port(network_id=net_id)
|
||||||
self.addCleanup(self.client.delete_port, body['port']['id'])
|
self.addCleanup(self.ports_client.delete_port, body['port']['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
ip_address = port['fixed_ips'][0]['ip_address']
|
ip_address = port['fixed_ips'][0]['ip_address']
|
||||||
start_ip_address = allocation_pools['allocation_pools'][0]['start']
|
start_ip_address = allocation_pools['allocation_pools'][0]['start']
|
||||||
@ -120,7 +120,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
@test.idempotent_id('c9a685bd-e83f-499c-939f-9f7863ca259f')
|
@test.idempotent_id('c9a685bd-e83f-499c-939f-9f7863ca259f')
|
||||||
def test_show_port(self):
|
def test_show_port(self):
|
||||||
# Verify the details of port
|
# Verify the details of port
|
||||||
body = self.client.show_port(self.port['id'])
|
body = self.ports_client.show_port(self.port['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.assertIn('id', port)
|
self.assertIn('id', port)
|
||||||
# TODO(Santosh)- This is a temporary workaround to compare create_port
|
# TODO(Santosh)- This is a temporary workaround to compare create_port
|
||||||
@ -134,8 +134,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
def test_show_port_fields(self):
|
def test_show_port_fields(self):
|
||||||
# Verify specific fields of a port
|
# Verify specific fields of a port
|
||||||
fields = ['id', 'mac_address']
|
fields = ['id', 'mac_address']
|
||||||
body = self.client.show_port(self.port['id'],
|
body = self.ports_client.show_port(self.port['id'],
|
||||||
fields=fields)
|
fields=fields)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.assertEqual(sorted(port.keys()), sorted(fields))
|
self.assertEqual(sorted(port.keys()), sorted(fields))
|
||||||
for field_name in fields:
|
for field_name in fields:
|
||||||
@ -145,7 +145,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
@test.idempotent_id('cf95b358-3e92-4a29-a148-52445e1ac50e')
|
@test.idempotent_id('cf95b358-3e92-4a29-a148-52445e1ac50e')
|
||||||
def test_list_ports(self):
|
def test_list_ports(self):
|
||||||
# Verify the port exists in the list of all ports
|
# Verify the port exists in the list of all ports
|
||||||
body = self.client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports = [port['id'] for port in body['ports']
|
ports = [port['id'] for port in body['ports']
|
||||||
if port['id'] == self.port['id']]
|
if port['id'] == self.port['id']]
|
||||||
self.assertNotEmpty(ports, "Created port not found in the list")
|
self.assertNotEmpty(ports, "Created port not found in the list")
|
||||||
@ -157,14 +157,14 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
subnet = self.create_subnet(network)
|
subnet = self.create_subnet(network)
|
||||||
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
||||||
# Create two ports
|
# Create two ports
|
||||||
port_1 = self.client.create_port(network_id=network['id'])
|
port_1 = self.ports_client.create_port(network_id=network['id'])
|
||||||
self.addCleanup(self.client.delete_port, port_1['port']['id'])
|
self.addCleanup(self.ports_client.delete_port, port_1['port']['id'])
|
||||||
port_2 = self.client.create_port(network_id=network['id'])
|
port_2 = self.ports_client.create_port(network_id=network['id'])
|
||||||
self.addCleanup(self.client.delete_port, port_2['port']['id'])
|
self.addCleanup(self.ports_client.delete_port, port_2['port']['id'])
|
||||||
# List ports filtered by fixed_ips
|
# List ports filtered by fixed_ips
|
||||||
port_1_fixed_ip = port_1['port']['fixed_ips'][0]['ip_address']
|
port_1_fixed_ip = port_1['port']['fixed_ips'][0]['ip_address']
|
||||||
fixed_ips = 'ip_address=' + port_1_fixed_ip
|
fixed_ips = 'ip_address=' + port_1_fixed_ip
|
||||||
port_list = self.client.list_ports(fixed_ips=fixed_ips)
|
port_list = self.ports_client.list_ports(fixed_ips=fixed_ips)
|
||||||
# Check that we got the desired port
|
# Check that we got the desired port
|
||||||
ports = port_list['ports']
|
ports = port_list['ports']
|
||||||
tenant_ids = set([port['tenant_id'] for port in ports])
|
tenant_ids = set([port['tenant_id'] for port in ports])
|
||||||
@ -190,14 +190,14 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
||||||
router = self.create_router(data_utils.rand_name('router-'))
|
router = self.create_router(data_utils.rand_name('router-'))
|
||||||
self.addCleanup(self.client.delete_router, router['id'])
|
self.addCleanup(self.client.delete_router, router['id'])
|
||||||
port = self.client.create_port(network_id=network['id'])
|
port = self.ports_client.create_port(network_id=network['id'])
|
||||||
# Add router interface to port created above
|
# Add router interface to port created above
|
||||||
self.client.add_router_interface_with_port_id(
|
self.client.add_router_interface_with_port_id(
|
||||||
router['id'], port['port']['id'])
|
router['id'], port['port']['id'])
|
||||||
self.addCleanup(self.client.remove_router_interface_with_port_id,
|
self.addCleanup(self.client.remove_router_interface_with_port_id,
|
||||||
router['id'], port['port']['id'])
|
router['id'], port['port']['id'])
|
||||||
# List ports filtered by router_id
|
# List ports filtered by router_id
|
||||||
port_list = self.client.list_ports(device_id=router['id'])
|
port_list = self.ports_client.list_ports(device_id=router['id'])
|
||||||
ports = port_list['ports']
|
ports = port_list['ports']
|
||||||
self.assertEqual(len(ports), 1)
|
self.assertEqual(len(ports), 1)
|
||||||
self.assertEqual(ports[0]['id'], port['port']['id'])
|
self.assertEqual(ports[0]['id'], port['port']['id'])
|
||||||
@ -207,7 +207,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
def test_list_ports_fields(self):
|
def test_list_ports_fields(self):
|
||||||
# Verify specific fields of ports
|
# Verify specific fields of ports
|
||||||
fields = ['id', 'mac_address']
|
fields = ['id', 'mac_address']
|
||||||
body = self.client.list_ports(fields=fields)
|
body = self.ports_client.list_ports(fields=fields)
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
self.assertNotEmpty(ports, "Port list returned is empty")
|
self.assertNotEmpty(ports, "Port list returned is empty")
|
||||||
# Asserting the fields returned are correct
|
# Asserting the fields returned are correct
|
||||||
@ -231,7 +231,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
# Create a port with multiple IP addresses
|
# Create a port with multiple IP addresses
|
||||||
port = self.create_port(network,
|
port = self.create_port(network,
|
||||||
fixed_ips=fixed_ips)
|
fixed_ips=fixed_ips)
|
||||||
self.addCleanup(self.client.delete_port, port['id'])
|
self.addCleanup(self.ports_client.delete_port, port['id'])
|
||||||
self.assertEqual(2, len(port['fixed_ips']))
|
self.assertEqual(2, len(port['fixed_ips']))
|
||||||
check_fixed_ips = [subnet_1['id'], subnet_2['id']]
|
check_fixed_ips = [subnet_1['id'], subnet_2['id']]
|
||||||
for item in port['fixed_ips']:
|
for item in port['fixed_ips']:
|
||||||
@ -269,8 +269,8 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
"network_id": self.network['id'],
|
"network_id": self.network['id'],
|
||||||
"admin_state_up": True,
|
"admin_state_up": True,
|
||||||
"fixed_ips": fixed_ip_1}
|
"fixed_ips": fixed_ip_1}
|
||||||
body = self.client.create_port(**post_body)
|
body = self.ports_client.create_port(**post_body)
|
||||||
self.addCleanup(self.client.delete_port, body['port']['id'])
|
self.addCleanup(self.ports_client.delete_port, body['port']['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
|
|
||||||
# Update the port with security groups
|
# Update the port with security groups
|
||||||
@ -280,7 +280,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
"admin_state_up": False,
|
"admin_state_up": False,
|
||||||
"fixed_ips": fixed_ip_2,
|
"fixed_ips": fixed_ip_2,
|
||||||
"security_groups": security_groups_list}
|
"security_groups": security_groups_list}
|
||||||
body = self.client.update_port(port['id'], **update_body)
|
body = self.ports_client.update_port(port['id'], **update_body)
|
||||||
port_show = body['port']
|
port_show = body['port']
|
||||||
# Verify the security groups and other attributes updated to port
|
# Verify the security groups and other attributes updated to port
|
||||||
exclude_keys = set(port_show).symmetric_difference(update_body)
|
exclude_keys = set(port_show).symmetric_difference(update_body)
|
||||||
@ -308,16 +308,16 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
@test.idempotent_id('13e95171-6cbd-489c-9d7c-3f9c58215c18')
|
@test.idempotent_id('13e95171-6cbd-489c-9d7c-3f9c58215c18')
|
||||||
def test_create_show_delete_port_user_defined_mac(self):
|
def test_create_show_delete_port_user_defined_mac(self):
|
||||||
# Create a port for a legal mac
|
# Create a port for a legal mac
|
||||||
body = self.client.create_port(network_id=self.network['id'])
|
body = self.ports_client.create_port(network_id=self.network['id'])
|
||||||
old_port = body['port']
|
old_port = body['port']
|
||||||
free_mac_address = old_port['mac_address']
|
free_mac_address = old_port['mac_address']
|
||||||
self.client.delete_port(old_port['id'])
|
self.ports_client.delete_port(old_port['id'])
|
||||||
# Create a new port with user defined mac
|
# Create a new port with user defined mac
|
||||||
body = self.client.create_port(network_id=self.network['id'],
|
body = self.ports_client.create_port(network_id=self.network['id'],
|
||||||
mac_address=free_mac_address)
|
mac_address=free_mac_address)
|
||||||
self.addCleanup(self.client.delete_port, body['port']['id'])
|
self.addCleanup(self.ports_client.delete_port, body['port']['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
body = self.client.show_port(port['id'])
|
body = self.ports_client.show_port(port['id'])
|
||||||
show_port = body['port']
|
show_port = body['port']
|
||||||
self.assertEqual(free_mac_address,
|
self.assertEqual(free_mac_address,
|
||||||
show_port['mac_address'])
|
show_port['mac_address'])
|
||||||
@ -330,7 +330,7 @@ class PortsTestJSON(sec_base.BaseSecGroupTest):
|
|||||||
subnet = self.create_subnet(network)
|
subnet = self.create_subnet(network)
|
||||||
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
self.addCleanup(self.subnets_client.delete_subnet, subnet['id'])
|
||||||
port = self.create_port(network, security_groups=[])
|
port = self.create_port(network, security_groups=[])
|
||||||
self.addCleanup(self.client.delete_port, port['id'])
|
self.addCleanup(self.ports_client.delete_port, port['id'])
|
||||||
self.assertIsNotNone(port['security_groups'])
|
self.assertIsNotNone(port['security_groups'])
|
||||||
self.assertEmpty(port['security_groups'])
|
self.assertEmpty(port['security_groups'])
|
||||||
|
|
||||||
@ -352,9 +352,9 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
|
|||||||
def test_create_port_binding_ext_attr(self):
|
def test_create_port_binding_ext_attr(self):
|
||||||
post_body = {"network_id": self.network['id'],
|
post_body = {"network_id": self.network['id'],
|
||||||
"binding:host_id": self.host_id}
|
"binding:host_id": self.host_id}
|
||||||
body = self.admin_client.create_port(**post_body)
|
body = self.admin_ports_client.create_port(**post_body)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.addCleanup(self.admin_client.delete_port, port['id'])
|
self.addCleanup(self.admin_ports_client.delete_port, port['id'])
|
||||||
host_id = port['binding:host_id']
|
host_id = port['binding:host_id']
|
||||||
self.assertIsNotNone(host_id)
|
self.assertIsNotNone(host_id)
|
||||||
self.assertEqual(self.host_id, host_id)
|
self.assertEqual(self.host_id, host_id)
|
||||||
@ -362,11 +362,11 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
|
|||||||
@test.idempotent_id('6f6c412c-711f-444d-8502-0ac30fbf5dd5')
|
@test.idempotent_id('6f6c412c-711f-444d-8502-0ac30fbf5dd5')
|
||||||
def test_update_port_binding_ext_attr(self):
|
def test_update_port_binding_ext_attr(self):
|
||||||
post_body = {"network_id": self.network['id']}
|
post_body = {"network_id": self.network['id']}
|
||||||
body = self.admin_client.create_port(**post_body)
|
body = self.admin_ports_client.create_port(**post_body)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.addCleanup(self.admin_client.delete_port, port['id'])
|
self.addCleanup(self.admin_ports_client.delete_port, port['id'])
|
||||||
update_body = {"binding:host_id": self.host_id}
|
update_body = {"binding:host_id": self.host_id}
|
||||||
body = self.admin_client.update_port(port['id'], **update_body)
|
body = self.admin_ports_client.update_port(port['id'], **update_body)
|
||||||
updated_port = body['port']
|
updated_port = body['port']
|
||||||
host_id = updated_port['binding:host_id']
|
host_id = updated_port['binding:host_id']
|
||||||
self.assertIsNotNone(host_id)
|
self.assertIsNotNone(host_id)
|
||||||
@ -376,18 +376,18 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
|
|||||||
def test_list_ports_binding_ext_attr(self):
|
def test_list_ports_binding_ext_attr(self):
|
||||||
# Create a new port
|
# Create a new port
|
||||||
post_body = {"network_id": self.network['id']}
|
post_body = {"network_id": self.network['id']}
|
||||||
body = self.admin_client.create_port(**post_body)
|
body = self.admin_ports_client.create_port(**post_body)
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.addCleanup(self.admin_client.delete_port, port['id'])
|
self.addCleanup(self.admin_ports_client.delete_port, port['id'])
|
||||||
|
|
||||||
# Update the port's binding attributes so that is now 'bound'
|
# Update the port's binding attributes so that is now 'bound'
|
||||||
# to a host
|
# to a host
|
||||||
update_body = {"binding:host_id": self.host_id}
|
update_body = {"binding:host_id": self.host_id}
|
||||||
self.admin_client.update_port(port['id'], **update_body)
|
self.admin_ports_client.update_port(port['id'], **update_body)
|
||||||
|
|
||||||
# List all ports, ensure new port is part of list and its binding
|
# List all ports, ensure new port is part of list and its binding
|
||||||
# attributes are set and accurate
|
# attributes are set and accurate
|
||||||
body = self.admin_client.list_ports()
|
body = self.admin_ports_client.list_ports()
|
||||||
ports_list = body['ports']
|
ports_list = body['ports']
|
||||||
pids_list = [p['id'] for p in ports_list]
|
pids_list = [p['id'] for p in ports_list]
|
||||||
self.assertIn(port['id'], pids_list)
|
self.assertIn(port['id'], pids_list)
|
||||||
@ -399,10 +399,11 @@ class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
|
|||||||
|
|
||||||
@test.idempotent_id('b54ac0ff-35fc-4c79-9ca3-c7dbd4ea4f13')
|
@test.idempotent_id('b54ac0ff-35fc-4c79-9ca3-c7dbd4ea4f13')
|
||||||
def test_show_port_binding_ext_attr(self):
|
def test_show_port_binding_ext_attr(self):
|
||||||
body = self.admin_client.create_port(network_id=self.network['id'])
|
body = self.admin_ports_client.create_port(
|
||||||
|
network_id=self.network['id'])
|
||||||
port = body['port']
|
port = body['port']
|
||||||
self.addCleanup(self.admin_client.delete_port, port['id'])
|
self.addCleanup(self.admin_ports_client.delete_port, port['id'])
|
||||||
body = self.admin_client.show_port(port['id'])
|
body = self.admin_ports_client.show_port(port['id'])
|
||||||
show_port = body['port']
|
show_port = body['port']
|
||||||
self.assertEqual(port['binding:host_id'],
|
self.assertEqual(port['binding:host_id'],
|
||||||
show_port['binding:host_id'])
|
show_port['binding:host_id'])
|
||||||
|
@ -144,7 +144,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
self.assertIn('subnet_id', interface.keys())
|
self.assertIn('subnet_id', interface.keys())
|
||||||
self.assertIn('port_id', interface.keys())
|
self.assertIn('port_id', interface.keys())
|
||||||
# Verify router id is equal to device id in port details
|
# Verify router id is equal to device id in port details
|
||||||
show_port_body = self.client.show_port(
|
show_port_body = self.ports_client.show_port(
|
||||||
interface['port_id'])
|
interface['port_id'])
|
||||||
self.assertEqual(show_port_body['port']['device_id'],
|
self.assertEqual(show_port_body['port']['device_id'],
|
||||||
router['id'])
|
router['id'])
|
||||||
@ -155,7 +155,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
network = self.create_network()
|
network = self.create_network()
|
||||||
self.create_subnet(network)
|
self.create_subnet(network)
|
||||||
router = self._create_router(data_utils.rand_name('router-'))
|
router = self._create_router(data_utils.rand_name('router-'))
|
||||||
port_body = self.client.create_port(
|
port_body = self.ports_client.create_port(
|
||||||
network_id=network['id'])
|
network_id=network['id'])
|
||||||
# add router interface to port created above
|
# add router interface to port created above
|
||||||
interface = self.client.add_router_interface_with_port_id(
|
interface = self.client.add_router_interface_with_port_id(
|
||||||
@ -165,7 +165,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
self.assertIn('subnet_id', interface.keys())
|
self.assertIn('subnet_id', interface.keys())
|
||||||
self.assertIn('port_id', interface.keys())
|
self.assertIn('port_id', interface.keys())
|
||||||
# Verify router id is equal to device id in port details
|
# Verify router id is equal to device id in port details
|
||||||
show_port_body = self.client.show_port(
|
show_port_body = self.ports_client.show_port(
|
||||||
interface['port_id'])
|
interface['port_id'])
|
||||||
self.assertEqual(show_port_body['port']['device_id'],
|
self.assertEqual(show_port_body['port']['device_id'],
|
||||||
router['id'])
|
router['id'])
|
||||||
@ -181,7 +181,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
self.assertEqual(v, actual_ext_gw_info[k])
|
self.assertEqual(v, actual_ext_gw_info[k])
|
||||||
|
|
||||||
def _verify_gateway_port(self, router_id):
|
def _verify_gateway_port(self, router_id):
|
||||||
list_body = self.admin_client.list_ports(
|
list_body = self.admin_ports_client.list_ports(
|
||||||
network_id=CONF.network.public_network_id,
|
network_id=CONF.network.public_network_id,
|
||||||
device_id=router_id)
|
device_id=router_id)
|
||||||
self.assertEqual(len(list_body['ports']), 1)
|
self.assertEqual(len(list_body['ports']), 1)
|
||||||
@ -245,7 +245,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
self.client.update_router(router['id'], external_gateway_info={})
|
self.client.update_router(router['id'], external_gateway_info={})
|
||||||
self._verify_router_gateway(router['id'])
|
self._verify_router_gateway(router['id'])
|
||||||
# No gateway port expected
|
# No gateway port expected
|
||||||
list_body = self.admin_client.list_ports(
|
list_body = self.admin_ports_client.list_ports(
|
||||||
network_id=CONF.network.public_network_id,
|
network_id=CONF.network.public_network_id,
|
||||||
device_id=router['id'])
|
device_id=router['id'])
|
||||||
self.assertFalse(list_body['ports'])
|
self.assertFalse(list_body['ports'])
|
||||||
@ -357,7 +357,7 @@ class RoutersTest(base.BaseRouterTest):
|
|||||||
interface02['port_id'])
|
interface02['port_id'])
|
||||||
|
|
||||||
def _verify_router_interface(self, router_id, subnet_id, port_id):
|
def _verify_router_interface(self, router_id, subnet_id, port_id):
|
||||||
show_port_body = self.client.show_port(port_id)
|
show_port_body = self.ports_client.show_port(port_id)
|
||||||
interface_port = show_port_body['port']
|
interface_port = show_port_body['port']
|
||||||
self.assertEqual(router_id, interface_port['device_id'])
|
self.assertEqual(router_id, interface_port['device_id'])
|
||||||
self.assertEqual(subnet_id,
|
self.assertEqual(subnet_id,
|
||||||
|
@ -164,7 +164,7 @@ class NeutronResourcesTestJSON(base.BaseOrchestrationTest):
|
|||||||
router_id = self.test_resources.get('Router')['physical_resource_id']
|
router_id = self.test_resources.get('Router')['physical_resource_id']
|
||||||
network_id = self.test_resources.get('Network')['physical_resource_id']
|
network_id = self.test_resources.get('Network')['physical_resource_id']
|
||||||
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
|
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
|
||||||
body = self.network_client.list_ports()
|
body = self.ports_client.list_ports()
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
router_ports = filter(lambda port: port['device_id'] ==
|
router_ports = filter(lambda port: port['device_id'] ==
|
||||||
router_id, ports)
|
router_id, ports)
|
||||||
|
@ -107,6 +107,7 @@ from tempest.services.messaging.json.messaging_client import \
|
|||||||
MessagingClient
|
MessagingClient
|
||||||
from tempest.services.network.json.network_client import NetworkClient
|
from tempest.services.network.json.network_client import NetworkClient
|
||||||
from tempest.services.network.json.networks_client import NetworksClient
|
from tempest.services.network.json.networks_client import NetworksClient
|
||||||
|
from tempest.services.network.json.ports_client import PortsClient
|
||||||
from tempest.services.network.json.subnets_client import SubnetsClient
|
from tempest.services.network.json.subnets_client import SubnetsClient
|
||||||
from tempest.services.object_storage.account_client import AccountClient
|
from tempest.services.object_storage.account_client import AccountClient
|
||||||
from tempest.services.object_storage.container_client import ContainerClient
|
from tempest.services.object_storage.container_client import ContainerClient
|
||||||
@ -213,6 +214,14 @@ class Manager(manager.Manager):
|
|||||||
build_interval=CONF.network.build_interval,
|
build_interval=CONF.network.build_interval,
|
||||||
build_timeout=CONF.network.build_timeout,
|
build_timeout=CONF.network.build_timeout,
|
||||||
**self.default_params)
|
**self.default_params)
|
||||||
|
self.ports_client = PortsClient(
|
||||||
|
self.auth_provider,
|
||||||
|
CONF.network.catalog_type,
|
||||||
|
CONF.network.region or CONF.identity.region,
|
||||||
|
endpoint_type=CONF.network.endpoint_type,
|
||||||
|
build_interval=CONF.network.build_interval,
|
||||||
|
build_timeout=CONF.network.build_timeout,
|
||||||
|
**self.default_params)
|
||||||
self.messaging_client = MessagingClient(
|
self.messaging_client = MessagingClient(
|
||||||
self.auth_provider,
|
self.auth_provider,
|
||||||
CONF.messaging.catalog_type,
|
CONF.messaging.catalog_type,
|
||||||
|
@ -384,6 +384,7 @@ class NetworkService(BaseService):
|
|||||||
self.client = manager.network_client
|
self.client = manager.network_client
|
||||||
self.networks_client = manager.networks_client
|
self.networks_client = manager.networks_client
|
||||||
self.subnets_client = manager.subnets_client
|
self.subnets_client = manager.subnets_client
|
||||||
|
self.ports_client = manager.ports_client
|
||||||
|
|
||||||
def _filter_by_conf_networks(self, item_list):
|
def _filter_by_conf_networks(self, item_list):
|
||||||
if not item_list or not all(('network_id' in i for i in item_list)):
|
if not item_list or not all(('network_id' in i for i in item_list)):
|
||||||
@ -621,7 +622,7 @@ class NetworkMeteringLabelService(NetworkService):
|
|||||||
class NetworkPortService(NetworkService):
|
class NetworkPortService(NetworkService):
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
client = self.client
|
client = self.ports_client
|
||||||
ports = [port for port in
|
ports = [port for port in
|
||||||
client.list_ports(**self.tenant_filter)['ports']
|
client.list_ports(**self.tenant_filter)['ports']
|
||||||
if port["device_owner"] == "" or
|
if port["device_owner"] == "" or
|
||||||
@ -634,7 +635,7 @@ class NetworkPortService(NetworkService):
|
|||||||
return ports
|
return ports
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
client = self.client
|
client = self.ports_client
|
||||||
ports = self.list()
|
ports = self.list()
|
||||||
for port in ports:
|
for port in ports:
|
||||||
try:
|
try:
|
||||||
|
@ -43,7 +43,8 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
|
|||||||
identity_version=self.identity_version)
|
identity_version=self.identity_version)
|
||||||
(self.identity_admin_client, self.network_admin_client,
|
(self.identity_admin_client, self.network_admin_client,
|
||||||
self.networks_admin_client,
|
self.networks_admin_client,
|
||||||
self.subnets_admin_client) = self._get_admin_clients()
|
self.subnets_admin_client,
|
||||||
|
self.ports_admin_client) = self._get_admin_clients()
|
||||||
# Domain where isolated credentials are provisioned (v3 only).
|
# Domain where isolated credentials are provisioned (v3 only).
|
||||||
# Use that of the admin account is None is configured.
|
# Use that of the admin account is None is configured.
|
||||||
self.creds_domain_name = None
|
self.creds_domain_name = None
|
||||||
@ -64,10 +65,10 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
|
|||||||
os = clients.Manager(self.default_admin_creds)
|
os = clients.Manager(self.default_admin_creds)
|
||||||
if self.identity_version == 'v2':
|
if self.identity_version == 'v2':
|
||||||
return (os.identity_client, os.network_client, os.networks_client,
|
return (os.identity_client, os.network_client, os.networks_client,
|
||||||
os.subnets_client)
|
os.subnets_client, os.ports_client)
|
||||||
else:
|
else:
|
||||||
return (os.identity_v3_client, os.network_client,
|
return (os.identity_v3_client, os.network_client,
|
||||||
os.networks_client, os.subnets_client)
|
os.networks_client, os.subnets_client, os.ports_client)
|
||||||
|
|
||||||
def _create_creds(self, suffix="", admin=False, roles=None):
|
def _create_creds(self, suffix="", admin=False, roles=None):
|
||||||
"""Create random credentials under the following schema.
|
"""Create random credentials under the following schema.
|
||||||
|
@ -62,6 +62,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
|||||||
# Neutron network client
|
# Neutron network client
|
||||||
cls.network_client = cls.manager.network_client
|
cls.network_client = cls.manager.network_client
|
||||||
cls.networks_client = cls.manager.networks_client
|
cls.networks_client = cls.manager.networks_client
|
||||||
|
cls.ports_client = cls.manager.ports_client
|
||||||
cls.subnets_client = cls.manager.subnets_client
|
cls.subnets_client = cls.manager.subnets_client
|
||||||
# Heat client
|
# Heat client
|
||||||
cls.orchestration_client = cls.manager.orchestration_client
|
cls.orchestration_client = cls.manager.orchestration_client
|
||||||
@ -661,7 +662,7 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
|
|
||||||
def _list_ports(self, *args, **kwargs):
|
def _list_ports(self, *args, **kwargs):
|
||||||
"""List ports using admin creds """
|
"""List ports using admin creds """
|
||||||
ports_list = self.admin_manager.network_client.list_ports(
|
ports_list = self.admin_manager.ports_client.list_ports(
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
return ports_list['ports']
|
return ports_list['ports']
|
||||||
|
|
||||||
@ -735,14 +736,14 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
def _create_port(self, network_id, client=None, namestart='port-quotatest',
|
def _create_port(self, network_id, client=None, namestart='port-quotatest',
|
||||||
**kwargs):
|
**kwargs):
|
||||||
if not client:
|
if not client:
|
||||||
client = self.network_client
|
client = self.ports_client
|
||||||
name = data_utils.rand_name(namestart)
|
name = data_utils.rand_name(namestart)
|
||||||
result = client.create_port(
|
result = client.create_port(
|
||||||
name=name,
|
name=name,
|
||||||
network_id=network_id,
|
network_id=network_id,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.assertIsNotNone(result, 'Unable to allocate port')
|
self.assertIsNotNone(result, 'Unable to allocate port')
|
||||||
port = net_resources.DeletablePort(client=client,
|
port = net_resources.DeletablePort(ports_client=client,
|
||||||
**result['port'])
|
**result['port'])
|
||||||
self.addCleanup(self.delete_wrapper, port.delete)
|
self.addCleanup(self.delete_wrapper, port.delete)
|
||||||
return port
|
return port
|
||||||
@ -1129,11 +1130,13 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
def create_server(self, name=None, image=None, flavor=None,
|
def create_server(self, name=None, image=None, flavor=None,
|
||||||
wait_on_boot=True, wait_on_delete=True,
|
wait_on_boot=True, wait_on_delete=True,
|
||||||
network_client=None, networks_client=None,
|
network_client=None, networks_client=None,
|
||||||
create_kwargs=None):
|
ports_client=None, create_kwargs=None):
|
||||||
if network_client is None:
|
if network_client is None:
|
||||||
network_client = self.network_client
|
network_client = self.network_client
|
||||||
if networks_client is None:
|
if networks_client is None:
|
||||||
networks_client = self.networks_client
|
networks_client = self.networks_client
|
||||||
|
if ports_client is None:
|
||||||
|
ports_client = self.ports_client
|
||||||
|
|
||||||
vnic_type = CONF.network.port_vnic_type
|
vnic_type = CONF.network.port_vnic_type
|
||||||
|
|
||||||
@ -1177,7 +1180,7 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
for net in networks:
|
for net in networks:
|
||||||
net_id = net['uuid']
|
net_id = net['uuid']
|
||||||
port = self._create_port(network_id=net_id,
|
port = self._create_port(network_id=net_id,
|
||||||
client=network_client,
|
client=ports_client,
|
||||||
**create_port_body)
|
**create_port_body)
|
||||||
ports.append({'port': port.id})
|
ports.append({'port': port.id})
|
||||||
if ports:
|
if ports:
|
||||||
|
@ -117,7 +117,7 @@ class BaremetalBasicOps(manager.BaremetalScenarioTest):
|
|||||||
def validate_ports(self):
|
def validate_ports(self):
|
||||||
for port in self.get_ports(self.node['uuid']):
|
for port in self.get_ports(self.node['uuid']):
|
||||||
n_port_id = port['extra']['vif_port_id']
|
n_port_id = port['extra']['vif_port_id']
|
||||||
body = self.network_client.show_port(n_port_id)
|
body = self.ports_client.show_port(n_port_id)
|
||||||
n_port = body['port']
|
n_port = body['port']
|
||||||
self.assertEqual(n_port['device_id'], self.instance['id'])
|
self.assertEqual(n_port['device_id'], self.instance['id'])
|
||||||
self.assertEqual(n_port['mac_address'], port['address'])
|
self.assertEqual(n_port['mac_address'], port['address'])
|
||||||
|
@ -250,7 +250,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
net_id=self.new_net.id)['interfaceAttachment']
|
net_id=self.new_net.id)['interfaceAttachment']
|
||||||
self.addCleanup(self.network_client.wait_for_resource_deletion,
|
self.addCleanup(self.network_client.wait_for_resource_deletion,
|
||||||
'port',
|
'port',
|
||||||
interface['port_id'])
|
interface['port_id'], client=self.ports_client)
|
||||||
self.addCleanup(self.delete_wrapper,
|
self.addCleanup(self.delete_wrapper,
|
||||||
self.interface_client.delete_interface,
|
self.interface_client.delete_interface,
|
||||||
server['id'], interface['port_id'])
|
server['id'], interface['port_id'])
|
||||||
@ -268,7 +268,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
"Old port: %s. Number of new ports: %d" % (
|
"Old port: %s. Number of new ports: %d" % (
|
||||||
CONF.network.build_timeout, old_port,
|
CONF.network.build_timeout, old_port,
|
||||||
len(self.new_port_list)))
|
len(self.new_port_list)))
|
||||||
new_port = net_resources.DeletablePort(client=self.network_client,
|
new_port = net_resources.DeletablePort(ports_client=self.ports_client,
|
||||||
**self.new_port_list[0])
|
**self.new_port_list[0])
|
||||||
|
|
||||||
def check_new_nic():
|
def check_new_nic():
|
||||||
@ -609,12 +609,12 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
self.check_public_network_connectivity(
|
self.check_public_network_connectivity(
|
||||||
should_connect=True, msg="before updating "
|
should_connect=True, msg="before updating "
|
||||||
"admin_state_up of instance port to False")
|
"admin_state_up of instance port to False")
|
||||||
self.network_client.update_port(port_id, admin_state_up=False)
|
self.ports_client.update_port(port_id, admin_state_up=False)
|
||||||
self.check_public_network_connectivity(
|
self.check_public_network_connectivity(
|
||||||
should_connect=False, msg="after updating "
|
should_connect=False, msg="after updating "
|
||||||
"admin_state_up of instance port to False",
|
"admin_state_up of instance port to False",
|
||||||
should_check_floating_ip_status=False)
|
should_check_floating_ip_status=False)
|
||||||
self.network_client.update_port(port_id, admin_state_up=True)
|
self.ports_client.update_port(port_id, admin_state_up=True)
|
||||||
self.check_public_network_connectivity(
|
self.check_public_network_connectivity(
|
||||||
should_connect=True, msg="after updating "
|
should_connect=True, msg="after updating "
|
||||||
"admin_state_up of instance port to True")
|
"admin_state_up of instance port to True")
|
||||||
@ -653,7 +653,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
waiters.wait_for_server_termination(self.servers_client, server['id'])
|
waiters.wait_for_server_termination(self.servers_client, server['id'])
|
||||||
# Assert the port still exists on the network but is unbound from
|
# Assert the port still exists on the network but is unbound from
|
||||||
# the deleted server.
|
# the deleted server.
|
||||||
port = self.network_client.show_port(port_id)['port']
|
port = self.ports_client.show_port(port_id)['port']
|
||||||
self.assertEqual(self.network['id'], port['network_id'])
|
self.assertEqual(self.network['id'], port['network_id'])
|
||||||
self.assertEqual('', port['device_id'])
|
self.assertEqual('', port['device_id'])
|
||||||
self.assertEqual('', port['device_owner'])
|
self.assertEqual('', port['device_owner'])
|
||||||
|
@ -250,6 +250,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||||||
name=name,
|
name=name,
|
||||||
network_client=tenant.manager.network_client,
|
network_client=tenant.manager.network_client,
|
||||||
networks_client=tenant.manager.networks_client,
|
networks_client=tenant.manager.networks_client,
|
||||||
|
ports_client=tenant.manager.ports_client,
|
||||||
create_kwargs=create_kwargs)
|
create_kwargs=create_kwargs)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sorted([s['name'] for s in security_groups]),
|
sorted([s['name'] for s in security_groups]),
|
||||||
@ -514,7 +515,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||||||
port_id = self._list_ports(device_id=server_id)[0]['id']
|
port_id = self._list_ports(device_id=server_id)[0]['id']
|
||||||
|
|
||||||
# update port with new security group and check connectivity
|
# update port with new security group and check connectivity
|
||||||
self.network_client.update_port(port_id, security_groups=[
|
self.ports_client.update_port(port_id, security_groups=[
|
||||||
new_tenant.security_groups['new_sg'].id])
|
new_tenant.security_groups['new_sg'].id])
|
||||||
self._check_connectivity(
|
self._check_connectivity(
|
||||||
access_point=access_point_ssh,
|
access_point=access_point_ssh,
|
||||||
@ -581,16 +582,16 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
|||||||
|
|
||||||
# Flip the port's port security and check connectivity
|
# Flip the port's port security and check connectivity
|
||||||
try:
|
try:
|
||||||
self.network_client.update_port(port_id,
|
self.ports_client.update_port(port_id,
|
||||||
port_security_enabled=True,
|
port_security_enabled=True,
|
||||||
security_groups=[])
|
security_groups=[])
|
||||||
self._check_connectivity(access_point=access_point_ssh,
|
self._check_connectivity(access_point=access_point_ssh,
|
||||||
ip=self._get_server_ip(server),
|
ip=self._get_server_ip(server),
|
||||||
should_succeed=False)
|
should_succeed=False)
|
||||||
|
|
||||||
self.network_client.update_port(port_id,
|
self.ports_client.update_port(port_id,
|
||||||
port_security_enabled=False,
|
port_security_enabled=False,
|
||||||
security_groups=[])
|
security_groups=[])
|
||||||
self._check_connectivity(
|
self._check_connectivity(
|
||||||
access_point=access_point_ssh,
|
access_point=access_point_ssh,
|
||||||
ip=self._get_server_ip(server))
|
ip=self._get_server_ip(server))
|
||||||
|
@ -34,28 +34,6 @@ class NetworkClient(base.BaseNetworkClient):
|
|||||||
quotas
|
quotas
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def create_port(self, **kwargs):
|
|
||||||
uri = '/ports'
|
|
||||||
post_data = {'port': kwargs}
|
|
||||||
return self.create_resource(uri, post_data)
|
|
||||||
|
|
||||||
def update_port(self, port_id, **kwargs):
|
|
||||||
uri = '/ports/%s' % port_id
|
|
||||||
post_data = {'port': kwargs}
|
|
||||||
return self.update_resource(uri, post_data)
|
|
||||||
|
|
||||||
def show_port(self, port_id, **fields):
|
|
||||||
uri = '/ports/%s' % port_id
|
|
||||||
return self.show_resource(uri, **fields)
|
|
||||||
|
|
||||||
def delete_port(self, port_id):
|
|
||||||
uri = '/ports/%s' % port_id
|
|
||||||
return self.delete_resource(uri)
|
|
||||||
|
|
||||||
def list_ports(self, **filters):
|
|
||||||
uri = '/ports'
|
|
||||||
return self.list_resources(uri, **filters)
|
|
||||||
|
|
||||||
def create_floatingip(self, **kwargs):
|
def create_floatingip(self, **kwargs):
|
||||||
uri = '/floatingips'
|
uri = '/floatingips'
|
||||||
post_data = {'floatingip': kwargs}
|
post_data = {'floatingip': kwargs}
|
||||||
@ -175,20 +153,22 @@ class NetworkClient(base.BaseNetworkClient):
|
|||||||
uri = '/ports'
|
uri = '/ports'
|
||||||
return self.create_resource(uri, post_data)
|
return self.create_resource(uri, post_data)
|
||||||
|
|
||||||
def wait_for_resource_deletion(self, resource_type, id):
|
def wait_for_resource_deletion(self, resource_type, id, client=None):
|
||||||
"""Waits for a resource to be deleted."""
|
"""Waits for a resource to be deleted."""
|
||||||
start_time = int(time.time())
|
start_time = int(time.time())
|
||||||
while True:
|
while True:
|
||||||
if self.is_resource_deleted(resource_type, id):
|
if self.is_resource_deleted(resource_type, id, client=client):
|
||||||
return
|
return
|
||||||
if int(time.time()) - start_time >= self.build_timeout:
|
if int(time.time()) - start_time >= self.build_timeout:
|
||||||
raise exceptions.TimeoutException
|
raise exceptions.TimeoutException
|
||||||
time.sleep(self.build_interval)
|
time.sleep(self.build_interval)
|
||||||
|
|
||||||
def is_resource_deleted(self, resource_type, id):
|
def is_resource_deleted(self, resource_type, id, client=None):
|
||||||
|
if client is None:
|
||||||
|
client = self
|
||||||
method = 'show_' + resource_type
|
method = 'show_' + resource_type
|
||||||
try:
|
try:
|
||||||
getattr(self, method)(id)
|
getattr(client, method)(id)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise Exception("Unknown resource type %s " % resource_type)
|
raise Exception("Unknown resource type %s " % resource_type)
|
||||||
except lib_exc.NotFound:
|
except lib_exc.NotFound:
|
||||||
|
38
tempest/services/network/json/ports_client.py
Normal file
38
tempest/services/network/json/ports_client.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from tempest.services.network.json import base
|
||||||
|
|
||||||
|
|
||||||
|
class PortsClient(base.BaseNetworkClient):
|
||||||
|
|
||||||
|
def create_port(self, **kwargs):
|
||||||
|
uri = '/ports'
|
||||||
|
post_data = {'port': kwargs}
|
||||||
|
return self.create_resource(uri, post_data)
|
||||||
|
|
||||||
|
def update_port(self, port_id, **kwargs):
|
||||||
|
uri = '/ports/%s' % port_id
|
||||||
|
post_data = {'port': kwargs}
|
||||||
|
return self.update_resource(uri, post_data)
|
||||||
|
|
||||||
|
def show_port(self, port_id, **fields):
|
||||||
|
uri = '/ports/%s' % port_id
|
||||||
|
return self.show_resource(uri, **fields)
|
||||||
|
|
||||||
|
def delete_port(self, port_id):
|
||||||
|
uri = '/ports/%s' % port_id
|
||||||
|
return self.delete_resource(uri)
|
||||||
|
|
||||||
|
def list_ports(self, **filters):
|
||||||
|
uri = '/ports'
|
||||||
|
return self.list_resources(uri, **filters)
|
@ -44,6 +44,7 @@ class DeletableResource(AttributeDict):
|
|||||||
self.network_client = kwargs.pop('network_client', None)
|
self.network_client = kwargs.pop('network_client', None)
|
||||||
self.networks_client = kwargs.pop('networks_client', None)
|
self.networks_client = kwargs.pop('networks_client', None)
|
||||||
self.subnets_client = kwargs.pop('subnets_client', None)
|
self.subnets_client = kwargs.pop('subnets_client', None)
|
||||||
|
self.ports_client = kwargs.pop('ports_client', None)
|
||||||
super(DeletableResource, self).__init__(*args, **kwargs)
|
super(DeletableResource, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -152,7 +153,7 @@ class DeletableFloatingIp(DeletableResource):
|
|||||||
class DeletablePort(DeletableResource):
|
class DeletablePort(DeletableResource):
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
self.client.delete_port(self.id)
|
self.ports_client.delete_port(self.id)
|
||||||
|
|
||||||
|
|
||||||
class DeletableSecurityGroup(DeletableResource):
|
class DeletableSecurityGroup(DeletableResource):
|
||||||
|
@ -376,7 +376,7 @@ class TestDynamicCredentialProvider(base.TestCase):
|
|||||||
'tempest.services.network.json.network_client.NetworkClient.'
|
'tempest.services.network.json.network_client.NetworkClient.'
|
||||||
'remove_router_interface_with_subnet_id')
|
'remove_router_interface_with_subnet_id')
|
||||||
return_values = ({'status': 200}, {'ports': []})
|
return_values = ({'status': 200}, {'ports': []})
|
||||||
port_list_mock = mock.patch.object(creds.network_admin_client,
|
port_list_mock = mock.patch.object(creds.ports_admin_client,
|
||||||
'list_ports',
|
'list_ports',
|
||||||
return_value=return_values)
|
return_value=return_values)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user