Replace subscribe with register for rpc callbacks
Commit I06c8302951c99039b532acd9f2a68d5b989fdab5 deprecated rpc callbacks subscribe and replaced them with register that get context and resource type too. Change-Id: Id80b1947c5dd329567609d3980b7790a01ab01ff
This commit is contained in:
parent
03dc732f7d
commit
e8a66301c6
@ -249,8 +249,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
self.supported_extension_aliases.append("dhcp-mtu")
|
||||
|
||||
# Bind QoS notifications
|
||||
callbacks_registry.subscribe(self._handle_qos_notification,
|
||||
callbacks_resources.QOS_POLICY)
|
||||
callbacks_registry.register(self._handle_qos_notification,
|
||||
callbacks_resources.QOS_POLICY)
|
||||
|
||||
# Make sure starting rpc listeners (for QoS and other agents)
|
||||
# will happen only once
|
||||
@ -3689,7 +3689,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
if cfg.CONF.nsxv.vdr_transit_network:
|
||||
edge_utils.validate_vdr_transit_network()
|
||||
|
||||
def _handle_qos_notification(self, qos_policys, event_type):
|
||||
def _handle_qos_notification(self, context, resource_type,
|
||||
qos_policys, event_type):
|
||||
qos_utils.handle_qos_notification(qos_policys, event_type, self._dvs)
|
||||
|
||||
def get_az_by_hint(self, hint):
|
||||
|
@ -213,8 +213,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
raise nsx_exc.NsxPluginException(err_msg=msg)
|
||||
|
||||
# Bind QoS notifications
|
||||
callbacks_registry.subscribe(qos_utils.handle_qos_notification,
|
||||
callbacks_resources.QOS_POLICY)
|
||||
callbacks_registry.register(qos_utils.handle_qos_notification,
|
||||
callbacks_resources.QOS_POLICY)
|
||||
self.start_rpc_listeners_called = False
|
||||
|
||||
self._unsubscribe_callback_events()
|
||||
|
@ -31,7 +31,8 @@ LOG = logging.getLogger(__name__)
|
||||
MAX_KBPS_MIN_VALUE = 1024
|
||||
|
||||
|
||||
def handle_qos_notification(policies_list, event_type):
|
||||
def handle_qos_notification(context, resource_type, policies_list,
|
||||
event_type):
|
||||
for policy_obj in policies_list:
|
||||
handle_qos_policy_notification(policy_obj, event_type)
|
||||
|
||||
|
@ -18,6 +18,7 @@ from eventlet import greenthread
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron.api.rpc.callbacks import events as callbacks_events
|
||||
from neutron.api.rpc.callbacks import resources as callbacks_resources
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron import context
|
||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
@ -621,8 +622,9 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxVPluginV2TestCase):
|
||||
return_value=fake_policy):
|
||||
with mock.patch.object(qos_pol.QosPolicy, "get_bound_networks",
|
||||
return_value=[net["id"]]):
|
||||
plugin._handle_qos_notification([fake_policy],
|
||||
callbacks_events.UPDATED)
|
||||
plugin._handle_qos_notification(
|
||||
ctx, callbacks_resources.QOS_POLICY,
|
||||
[fake_policy], callbacks_events.UPDATED)
|
||||
# make sure the policy data was read, and the dvs was updated
|
||||
self.assertTrue(fake_init_from_policy.called)
|
||||
self.assertTrue(fake_dvs_update.called)
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron.api.rpc.callbacks import events
|
||||
from neutron.api.rpc.callbacks import resources
|
||||
from neutron.services.qos.notification_drivers import message_queue
|
||||
from vmware_nsx.services.qos.nsx_v3 import utils as qos_utils
|
||||
|
||||
@ -22,10 +23,16 @@ class DummyNotificationDriver(
|
||||
message_queue.RpcQosServiceNotificationDriver):
|
||||
|
||||
def create_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification([policy], events.CREATED)
|
||||
qos_utils.handle_qos_notification(
|
||||
context, resources.QOS_POLICY,
|
||||
[policy], events.CREATED)
|
||||
|
||||
def update_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification([policy], events.UPDATED)
|
||||
qos_utils.handle_qos_notification(
|
||||
context, resources.QOS_POLICY,
|
||||
[policy], events.UPDATED)
|
||||
|
||||
def delete_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification([policy], events.DELETED)
|
||||
qos_utils.handle_qos_notification(
|
||||
context, resources.QOS_POLICY,
|
||||
[policy], events.DELETED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user