1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
13 from oslo_log import log as logging
15 from neutron._i18n import _LW
16 from neutron.api.rpc.callbacks import events
17 from neutron.api.rpc.callbacks.producer import registry
18 from neutron.api.rpc.callbacks import resources
19 from neutron.api.rpc.handlers import resources_rpc
20 from neutron.objects.qos import policy as policy_object
21 from neutron.services.qos.notification_drivers import qos_base
24 LOG = logging.getLogger(__name__)
27 def _get_qos_policy_cb(resource, policy_id, **kwargs):
28 context = kwargs.get('context')
31 'Received %(resource)s %(policy_id)s without context'),
32 {'resource': resource, 'policy_id': policy_id}
36 policy = policy_object.QosPolicy.get_by_id(context, policy_id)
40 class RpcQosServiceNotificationDriver(
41 qos_base.QosServiceNotificationDriverBase):
42 """RPC message queue service notification driver for QoS."""
45 self.notification_api = resources_rpc.ResourcesPushRpcApi()
46 registry.provide(_get_qos_policy_cb, resources.QOS_POLICY)
48 def get_description(self):
49 return "Message queue updates"
51 def create_policy(self, context, policy):
52 #No need to update agents on create
55 def update_policy(self, context, policy):
56 self.notification_api.push(context, policy, events.UPDATED)
58 def delete_policy(self, context, policy):
59 self.notification_api.push(context, policy, events.DELETED)