Add device_owner while creating neutron port.

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>
This commit is contained in:
Pengfei Ni 2015-10-08 18:56:44 +08:00
parent 15b3cfa3d9
commit 16250e932c
4 changed files with 21 additions and 7 deletions

View File

@ -49,3 +49,5 @@ SCHEMA = {
},
"SUCCESS": {}
}
DEVICE_OWNER = 'kuryr:container'

View File

@ -24,7 +24,6 @@ from kuryr.common import exceptions
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')
@ -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

View File

@ -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)
@ -165,6 +165,8 @@ class TestKuryr(base.TestKuryrBase):
'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}]
}
}
@ -270,6 +272,8 @@ class TestKuryr(base.TestKuryrBase):
'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},
@ -374,6 +378,8 @@ class TestKuryr(base.TestKuryrBase):
'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': [{

View File

@ -85,6 +85,8 @@ class TestKuryrEndpointFailures(base.TestKuryrFailures):
'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'
@ -106,7 +108,8 @@ class TestKuryrEndpointFailures(base.TestKuryrFailures):
"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,
@ -209,8 +212,10 @@ class TestKuryrEndpointCreateFailures(TestKuryrEndpointFailures):
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.