OpenStack Networking (Neutron)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0KB

  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
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  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
  11. # under the License.
  12. from oslo_log import log as logging
  13. from neutron._i18n import _LW
  14. from neutron.api.rpc.callbacks import events
  15. from neutron.api.rpc.callbacks.producer import registry
  16. from neutron.api.rpc.callbacks import resources
  17. from neutron.api.rpc.handlers import resources_rpc
  18. from neutron.objects.qos import policy as policy_object
  19. from neutron.services.qos.notification_drivers import qos_base
  20. LOG = logging.getLogger(__name__)
  21. def _get_qos_policy_cb(resource, policy_id, **kwargs):
  22. context = kwargs.get('context')
  23. if context is None:
  24. LOG.warning(_LW(
  25. 'Received %(resource)s %(policy_id)s without context'),
  26. {'resource': resource, 'policy_id': policy_id}
  27. )
  28. return
  29. policy = policy_object.QosPolicy.get_object(context, id=policy_id)
  30. return policy
  31. class RpcQosServiceNotificationDriver(
  32. qos_base.QosServiceNotificationDriverBase):
  33. """RPC message queue service notification driver for QoS."""
  34. def __init__(self):
  35. self.notification_api = resources_rpc.ResourcesPushRpcApi()
  36. registry.provide(_get_qos_policy_cb, resources.QOS_POLICY)
  37. def get_description(self):
  38. return "Message queue updates"
  39. def create_policy(self, context, policy):
  40. #No need to update agents on create
  41. pass
  42. def update_policy(self, context, policy):
  43. self.notification_api.push(context, policy, events.UPDATED)
  44. def delete_policy(self, context, policy):
  45. self.notification_api.push(context, policy, events.DELETED)