Merge "Replace hardcoded port name generation with function"
This commit is contained in:
commit
f8a30cc5b1
@ -244,7 +244,7 @@ def _create_subnets_and_or_port(interface, neutron_network_id, endpoint_id):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
port = {
|
port = {
|
||||||
'name': '-'.join([endpoint_id, 'port']),
|
'name': utils.get_neutron_port_name(endpoint_id),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'network_id': neutron_network_id,
|
'network_id': neutron_network_id,
|
||||||
'device_owner': constants.DEVICE_OWNER,
|
'device_owner': constants.DEVICE_OWNER,
|
||||||
@ -723,7 +723,7 @@ def network_driver_leave():
|
|||||||
.format(neutron_network_name)
|
.format(neutron_network_name)
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
neutron_port_name = '-'.join([endpoint_id, 'port'])
|
neutron_port_name = utils.get_neutron_port_name(endpoint_id)
|
||||||
filtered_ports = _get_ports_by_attrs(name=neutron_port_name)
|
filtered_ports = _get_ports_by_attrs(name=neutron_port_name)
|
||||||
if not filtered_ports:
|
if not filtered_ports:
|
||||||
raise exceptions.NoResourceException(
|
raise exceptions.NoResourceException(
|
||||||
|
@ -14,6 +14,7 @@ from neutronclient.tests.unit import test_cli20
|
|||||||
|
|
||||||
from kuryr import app
|
from kuryr import app
|
||||||
from kuryr import binding
|
from kuryr import binding
|
||||||
|
from kuryr import utils
|
||||||
|
|
||||||
|
|
||||||
class TestCase(test_cli20.CLITestV20Base):
|
class TestCase(test_cli20.CLITestV20Base):
|
||||||
@ -165,7 +166,7 @@ class TestKuryrBase(TestCase):
|
|||||||
fake_port = {
|
fake_port = {
|
||||||
'port': {
|
'port': {
|
||||||
"status": "DOWN",
|
"status": "DOWN",
|
||||||
"name": '-'.join([docker_endpoint_id, '0', 'port']),
|
"name": utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
"allowed_address_pairs": [],
|
"allowed_address_pairs": [],
|
||||||
"admin_state_up": True,
|
"admin_state_up": True,
|
||||||
"network_id": neutron_network_id,
|
"network_id": neutron_network_id,
|
||||||
|
@ -177,7 +177,7 @@ class TestKuryr(base.TestKuryrBase):
|
|||||||
fake_neutron_port_id = str(uuid.uuid4())
|
fake_neutron_port_id = str(uuid.uuid4())
|
||||||
fake_port_request = {
|
fake_port_request = {
|
||||||
'port': {
|
'port': {
|
||||||
'name': '-'.join([docker_endpoint_id, 'port']),
|
'name': utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'mac_address': fake_mac_address,
|
'mac_address': fake_mac_address,
|
||||||
'network_id': fake_neutron_network_id,
|
'network_id': fake_neutron_network_id,
|
||||||
@ -286,7 +286,7 @@ class TestKuryr(base.TestKuryrBase):
|
|||||||
fake_neutron_port_id = str(uuid.uuid4())
|
fake_neutron_port_id = str(uuid.uuid4())
|
||||||
fake_port_request = {
|
fake_port_request = {
|
||||||
'port': {
|
'port': {
|
||||||
'name': '-'.join([docker_endpoint_id, 'port']),
|
'name': utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'mac_address': fake_mac_address,
|
'mac_address': fake_mac_address,
|
||||||
'network_id': fake_neutron_network_id,
|
'network_id': fake_neutron_network_id,
|
||||||
@ -396,7 +396,7 @@ class TestKuryr(base.TestKuryrBase):
|
|||||||
self.mox.StubOutWithMock(app.neutron, 'create_port')
|
self.mox.StubOutWithMock(app.neutron, 'create_port')
|
||||||
fake_port_request = {
|
fake_port_request = {
|
||||||
'port': {
|
'port': {
|
||||||
'name': '-'.join([docker_endpoint_id, 'port']),
|
'name': utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'device_owner': constants.DEVICE_OWNER,
|
'device_owner': constants.DEVICE_OWNER,
|
||||||
'device_id': docker_endpoint_id,
|
'device_id': docker_endpoint_id,
|
||||||
|
@ -21,6 +21,7 @@ from oslo_serialization import jsonutils
|
|||||||
from kuryr import app
|
from kuryr import app
|
||||||
from kuryr.common import constants
|
from kuryr.common import constants
|
||||||
from kuryr.tests import base
|
from kuryr.tests import base
|
||||||
|
from kuryr import utils
|
||||||
|
|
||||||
|
|
||||||
class TestKuryrEndpointFailures(base.TestKuryrFailures):
|
class TestKuryrEndpointFailures(base.TestKuryrFailures):
|
||||||
@ -85,7 +86,7 @@ class TestKuryrEndpointFailures(base.TestKuryrFailures):
|
|||||||
self.mox.StubOutWithMock(app.neutron, 'create_port')
|
self.mox.StubOutWithMock(app.neutron, 'create_port')
|
||||||
fake_port_request = {
|
fake_port_request = {
|
||||||
'port': {
|
'port': {
|
||||||
'name': '-'.join([docker_endpoint_id, 'port']),
|
'name': utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'device_owner': constants.DEVICE_OWNER,
|
'device_owner': constants.DEVICE_OWNER,
|
||||||
'device_id': docker_endpoint_id,
|
'device_id': docker_endpoint_id,
|
||||||
@ -105,7 +106,7 @@ class TestKuryrEndpointFailures(base.TestKuryrFailures):
|
|||||||
fake_port = {
|
fake_port = {
|
||||||
"port": {
|
"port": {
|
||||||
"status": "DOWN",
|
"status": "DOWN",
|
||||||
"name": '-'.join([docker_endpoint_id, 'port']),
|
"name": utils.get_neutron_port_name(docker_endpoint_id),
|
||||||
"allowed_address_pairs": [],
|
"allowed_address_pairs": [],
|
||||||
"admin_state_up": True,
|
"admin_state_up": True,
|
||||||
"network_id": neutron_network_id,
|
"network_id": neutron_network_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user