Merge "QoS integration - callbacks should support a list of policies"
This commit is contained in:
commit
f41ef9b532
@ -3228,8 +3228,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
error = _("Configured %s not found") % field
|
||||
raise nsx_exc.NsxPluginException(err_msg=error)
|
||||
|
||||
def _handle_qos_notification(self, qos_policy, event_type):
|
||||
qos_utils.handle_qos_notification(qos_policy, event_type, self._dvs)
|
||||
def _handle_qos_notification(self, qos_policys, event_type):
|
||||
qos_utils.handle_qos_notification(qos_policys, event_type, self._dvs)
|
||||
|
||||
def get_az_by_hint(self, hint):
|
||||
az = self._availability_zones_data.get_availability_zone(hint)
|
||||
|
@ -90,12 +90,18 @@ class NsxVQosRule(object):
|
||||
return self
|
||||
|
||||
|
||||
def handle_qos_notification(policy_obj, event_type, dvs):
|
||||
def handle_qos_notification(policies_list, event_type, dvs):
|
||||
# Check if QoS policy rule was created/deleted/updated
|
||||
# Only if the policy rule was updated, we need to update the dvs
|
||||
if (event_type == callbacks_events.UPDATED and
|
||||
hasattr(policy_obj, "rules")):
|
||||
if event_type != callbacks_events.UPDATED:
|
||||
return
|
||||
|
||||
for policy_obj in policies_list:
|
||||
if hasattr(policy_obj, "rules"):
|
||||
handle_qos_policy_notification(policy_obj, dvs)
|
||||
|
||||
|
||||
def handle_qos_policy_notification(policy_obj, dvs):
|
||||
# Reload the policy as admin so we will have a context
|
||||
context = n_context.get_admin_context()
|
||||
admin_policy = qos_policy.QosPolicy.get_object(
|
||||
|
@ -32,7 +32,12 @@ LOG = logging.getLogger(__name__)
|
||||
MAX_KBPS_MIN_VALUE = 1024
|
||||
|
||||
|
||||
def handle_qos_notification(policy_obj, event_type):
|
||||
def handle_qos_notification(policies_list, event_type):
|
||||
for policy_obj in policies_list:
|
||||
handle_qos_policy_notification(policy_obj, event_type)
|
||||
|
||||
|
||||
def handle_qos_policy_notification(policy_obj, event_type):
|
||||
handler = QosNotificationsHandler()
|
||||
context = n_context.get_admin_context()
|
||||
|
||||
|
@ -609,7 +609,7 @@ 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,
|
||||
plugin._handle_qos_notification([fake_policy],
|
||||
callbacks_events.UPDATED)
|
||||
# make sure the policy data was read, and the dvs was updated
|
||||
self.assertTrue(fake_init_from_policy.called)
|
||||
|
@ -22,10 +22,10 @@ class DummyNotificationDriver(
|
||||
message_queue.RpcQosServiceNotificationDriver):
|
||||
|
||||
def create_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification(policy, events.CREATED)
|
||||
qos_utils.handle_qos_notification([policy], events.CREATED)
|
||||
|
||||
def update_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification(policy, events.UPDATED)
|
||||
qos_utils.handle_qos_notification([policy], events.UPDATED)
|
||||
|
||||
def delete_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification(policy, events.DELETED)
|
||||
qos_utils.handle_qos_notification([policy], events.DELETED)
|
||||
|
@ -33,7 +33,7 @@ class DummyNsxVNotificationDriver(
|
||||
pass
|
||||
|
||||
def update_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification(policy, events.UPDATED, self._dvs)
|
||||
qos_utils.handle_qos_notification([policy], events.UPDATED, self._dvs)
|
||||
|
||||
def delete_policy(self, context, policy):
|
||||
qos_utils.handle_qos_notification(policy, events.DELETED, self._dvs)
|
||||
qos_utils.handle_qos_notification([policy], events.DELETED, self._dvs)
|
||||
|
Loading…
Reference in New Issue
Block a user