The previous version depended on the AgentDbMixin to be loaded by any plugin, and also introduced an __init__ on the mixin which was problematic: mixins are expected to be classes which add methods to another class, but to implement no constructor. One of the plugins had one of the elements of MRO not calling to super().__init__ and hence not triggering this __init__ method. This change requires the plugins using the rpc callback mechanism to provide the AgentDbMixin which is used to refresh cache of known resource consumers (agents) and versions on demand, this way we make it more clear that the rpc_callback api is currently designed to be used with agents only, despite of its extensibility to other areas. Change-Id: Ie96b52dbe3a1f32cd4c11de8d8a5eff663fbf7f6 Related-Bug: #1584204
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from neutron_lib import exceptions
|
|
|
|
from neutron._i18n import _
|
|
|
|
|
|
class CallbackWrongResourceType(exceptions.NeutronException):
|
|
message = _('Callback for %(resource_type)s returned wrong resource type')
|
|
|
|
|
|
class CallbackNotFound(exceptions.NeutronException):
|
|
message = _('Callback for %(resource_type)s not found')
|
|
|
|
|
|
class CallbacksMaxLimitReached(exceptions.NeutronException):
|
|
message = _("Cannot add multiple callbacks for %(resource_type)s")
|
|
|
|
|
|
class NoAgentDbMixinImplemented(exceptions.NeutronException):
|
|
message = _("RPC callbacks mechanism needs the implementation of "
|
|
"AgentDbMixin in the plugin, as so far it's only designed "
|
|
"to work with agents")
|