ml2: added qos_profile_id to get_device_details payload
This is needed to make l2 agent qos extension determine which rules to apply to the port, if any. Partially-Implements: blueprint quantum-qos-api Change-Id: Idefa819f9a21cf53762b1fb923dafb63f2b256e0
This commit is contained in:
parent
66520a4293
commit
301ffb02ec
|
@ -28,6 +28,7 @@ from neutron.common import rpc as n_rpc
|
|||
from neutron.common import topics
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import qos
|
||||
from neutron.i18n import _LW
|
||||
from neutron import manager
|
||||
from neutron.plugins.ml2 import driver_api as api
|
||||
|
@ -106,6 +107,8 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
host,
|
||||
port_context.network.current)
|
||||
|
||||
qos_profile_id = (port.get(qos.QOS_POLICY_ID) or
|
||||
port_context.network._network.get(qos.QOS_POLICY_ID))
|
||||
entry = {'device': device,
|
||||
'network_id': port['network_id'],
|
||||
'port_id': port['id'],
|
||||
|
@ -118,6 +121,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
'device_owner': port['device_owner'],
|
||||
'allowed_address_pairs': port['allowed_address_pairs'],
|
||||
'port_security_enabled': port.get(psec.PORTSECURITY, True),
|
||||
'qos_policy_id': qos_profile_id,
|
||||
'profile': port[portbindings.PROFILE]}
|
||||
LOG.debug("Returning: %s", entry)
|
||||
return entry
|
||||
|
|
|
@ -28,6 +28,7 @@ from neutron.agent import rpc as agent_rpc
|
|||
from neutron.common import constants
|
||||
from neutron.common import exceptions
|
||||
from neutron.common import topics
|
||||
from neutron.extensions import qos
|
||||
from neutron.plugins.ml2.drivers import type_tunnel
|
||||
from neutron.plugins.ml2 import managers
|
||||
from neutron.plugins.ml2 import rpc as plugin_rpc
|
||||
|
@ -134,6 +135,31 @@ class RpcCallbacksTestCase(base.BaseTestCase):
|
|||
self.callbacks.get_device_details(mock.Mock())
|
||||
self.assertTrue(self.plugin.update_port_status.called)
|
||||
|
||||
def test_get_device_details_qos_policy_id_none(self):
|
||||
port = collections.defaultdict(lambda: 'fake_port')
|
||||
self.plugin.get_bound_port_context().current = port
|
||||
self.plugin.get_bound_port_context().network._network = (
|
||||
{"id": "fake_network"})
|
||||
res = self.callbacks.get_device_details(mock.Mock(), host='fake')
|
||||
self.assertIsNone(res['qos_policy_id'])
|
||||
|
||||
def test_get_device_details_qos_policy_id_inherited_from_network(self):
|
||||
port = collections.defaultdict(lambda: 'fake_port')
|
||||
self.plugin.get_bound_port_context().current = port
|
||||
self.plugin.get_bound_port_context().network._network = (
|
||||
{"id": "fake_network", qos.QOS_POLICY_ID: 'test-policy-id'})
|
||||
res = self.callbacks.get_device_details(mock.Mock(), host='fake')
|
||||
self.assertEqual('test-policy-id', res['qos_policy_id'])
|
||||
|
||||
def test_get_device_details_qos_policy_id_taken_from_port(self):
|
||||
port = collections.defaultdict(
|
||||
lambda: 'fake_port', {qos.QOS_POLICY_ID: 'test-port-policy-id'})
|
||||
self.plugin.get_bound_port_context().current = port
|
||||
self.plugin.get_bound_port_context().network._network = (
|
||||
{"id": "fake_network", qos.QOS_POLICY_ID: 'test-net-policy-id'})
|
||||
res = self.callbacks.get_device_details(mock.Mock(), host='fake')
|
||||
self.assertEqual('test-port-policy-id', res['qos_policy_id'])
|
||||
|
||||
def test_get_devices_details_list(self):
|
||||
devices = [1, 2, 3, 4, 5]
|
||||
kwargs = {'host': 'fake_host', 'agent_id': 'fake_agent_id'}
|
||||
|
|
Loading…
Reference in New Issue