Skip to content

Commit

Permalink
Add device_owner while creating neutron port.
Browse files Browse the repository at this point in the history
1. Set device_id to endpoint id
2. Set device_owner to kuryr:container

Change-Id: Ib080ee59f6428732f341167088a99f726ef74891
Closes-Bug: 1504001
Signed-off-by: Pengfei Ni <feiskyer@gmail.com>
  • Loading branch information
feiskyer committed Oct 19, 2015
1 parent 15b3cfa commit 16250e9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions kuryr/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@
},
"SUCCESS": {}
}

DEVICE_OWNER = 'kuryr:container'
3 changes: 2 additions & 1 deletion kuryr/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from kuryr import schemata
from kuryr import utils


cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
cfg.CONF.import_group('keystone_client', 'kuryr.common.config')

Expand Down Expand Up @@ -233,6 +232,8 @@ def _create_subnets_and_or_port(interface, neutron_network_id, endpoint_id):
'name': '-'.join([endpoint_id, 'port']),
'admin_state_up': True,
'network_id': neutron_network_id,
'device_owner': constants.DEVICE_OWNER,
'device_id': endpoint_id,
}
if interface_mac:
port['mac_address'] = interface_mac
Expand Down
12 changes: 9 additions & 3 deletions kuryr/tests/test_kuryr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class TestKuryr(base.TestKuryrBase):
- POST /NetworkDriver.Leave
"""
@ddt.data(('/Plugin.Activate', constants.SCHEMA['PLUGIN_ACTIVATE']),
('/NetworkDriver.EndpointOperInfo',
constants.SCHEMA['ENDPOINT_OPER_INFO']),
('/NetworkDriver.Leave', constants.SCHEMA['SUCCESS']))
('/NetworkDriver.EndpointOperInfo',
constants.SCHEMA['ENDPOINT_OPER_INFO']),
('/NetworkDriver.Leave', constants.SCHEMA['SUCCESS']))
@ddt.unpack
def test_remote_driver_endpoint(self, endpoint, expected):
response = self.app.post(endpoint)
Expand Down Expand Up @@ -165,6 +165,8 @@ def test_network_driver_create_endpoint_with_v4_subnetpool(self):
'admin_state_up': True,
'mac_address': fake_mac_address,
'network_id': fake_neutron_network_id,
'device_owner': constants.DEVICE_OWNER,
'device_id': docker_endpoint_id,
'fixed_ips': [{'subnet_id': subnet_v4_id}]
}
}
Expand Down Expand Up @@ -270,6 +272,8 @@ def test_network_driver_create_endpoint_with_subnetpools(self):
'admin_state_up': True,
'mac_address': fake_mac_address,
'network_id': fake_neutron_network_id,
'device_owner': constants.DEVICE_OWNER,
'device_id': docker_endpoint_id,
'fixed_ips': [
{'subnet_id': subnet_v4_id},
{'subnet_id': subnet_v6_id},
Expand Down Expand Up @@ -374,6 +378,8 @@ def test_network_driver_create_endpoint(self):
'port': {
'name': '-'.join([docker_endpoint_id, 'port']),
'admin_state_up': True,
'device_owner': constants.DEVICE_OWNER,
'device_id': docker_endpoint_id,
'mac_address': "fa:16:3e:20:57:c3",
'network_id': fake_neutron_network_id,
'fixed_ips': [{
Expand Down
11 changes: 8 additions & 3 deletions kuryr/tests/test_kuryr_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def _create_port_with_exception(self, neutron_network_id,
'port': {
'name': '-'.join([docker_endpoint_id, 'port']),
'admin_state_up': True,
'device_owner': constants.DEVICE_OWNER,
'device_id': docker_endpoint_id,
'fixed_ips': [{
'subnet_id': neutron_subnetv4_id,
'ip_address': '192.168.1.2'
Expand All @@ -106,7 +108,8 @@ def _create_port_with_exception(self, neutron_network_id,
"admin_state_up": True,
"network_id": neutron_network_id,
"tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa",
"device_owner": "",
"device_owner": constants.DEVICE_OWNER,
'device_id': docker_endpoint_id,
"mac_address": "fa:16:3e:20:57:c3",
'fixed_ips': [{
'subnet_id': neutron_subnetv4_id,
Expand Down Expand Up @@ -209,8 +212,10 @@ def test_create_endpoint_port_failures(self, GivenException):
fake_neutron_subnet_v6_id) = self._create_subnet_with_exception(
fake_neutron_network_id, fake_docker_endpoint_id, None)
self._create_port_with_exception(fake_neutron_network_id,
fake_docker_endpoint_id, fake_neutron_subnet_v4_id,
fake_neutron_subnet_v6_id, GivenException())
fake_docker_endpoint_id,
fake_neutron_subnet_v4_id,
fake_neutron_subnet_v6_id,
GivenException())
self._mock_out_network(fake_neutron_network_id, fake_docker_network_id)

# The port creation is failed and Kuryr rolles the created subnet back.
Expand Down

0 comments on commit 16250e9

Please sign in to comment.