From 09edd7badf57a1c1f45bc4ce6cd5e243cae3af76 Mon Sep 17 00:00:00 2001 From: vish Date: Sat, 1 Oct 2016 02:11:34 +0000 Subject: [PATCH] Fixes event ordering for alarm monitor and scale actions. This commit adds code to support the below related to alarm monitoring and scaling: 1.Consolidates the two event captures in the update_vnf_with_alarm method into just a single event capture with alarm url details. 2.Captures events in update_vnf_with_alarm method when policy action and alarm action name are missing. 3.Captures the event information for ActionAutoscalingHeat policy action invocation and scaling action in the right time order. Change-Id: Iea255a4f454fb0c721b152090514ad8ca8732890 Closes-Bug: #1629453 --- tacker/vnfm/monitor.py | 14 +++++++++----- tacker/vnfm/plugin.py | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tacker/vnfm/monitor.py b/tacker/vnfm/monitor.py index 83ac3486a..0f87ea5a4 100644 --- a/tacker/vnfm/monitor.py +++ b/tacker/vnfm/monitor.py @@ -219,22 +219,26 @@ class VNFAlarmMonitor(object): params = dict() params['vnf_id'] = vnf['id'] params['mon_policy_name'] = policy_name - _log_monitor_events(t_context.get_admin_context(), - vnf, - "update vnf with alarm") driver = policy_dict['triggers']['resize_compute'][ 'event_type']['implementation'] policy_action = policy_dict['triggers']['resize_compute'].get('action') if not policy_action: + _log_monitor_events(t_context.get_admin_context(), + vnf, + "Alarm not set: policy action missing") return alarm_action_name = policy_action['resize_compute'].get('action_name') if not alarm_action_name: + _log_monitor_events(t_context.get_admin_context(), + vnf, + "Alarm not set: alarm action name missing") return params['mon_policy_action'] = alarm_action_name alarm_url = self.call_alarm_url(driver, vnf, params) + details = "Alarm URL set successfully: %s" % alarm_url _log_monitor_events(t_context.get_admin_context(), vnf, - "Alarm url invoked") + details) return alarm_url # vnf['attribute']['alarm_url'] = alarm_url ---> create # by plugin or vm_db @@ -389,10 +393,10 @@ class ActionAutoscalingHeat(ActionPolicy): @classmethod def execute_action(cls, plugin, vnf_dict, scale): vnf_id = vnf_dict['id'] - plugin.create_vnf_scale(t_context.get_admin_context(), vnf_id, scale) _log_monitor_events(t_context.get_admin_context(), vnf_dict, "ActionAutoscalingHeat invoked") + plugin.create_vnf_scale(t_context.get_admin_context(), vnf_id, scale) @ActionPolicy.register('log') diff --git a/tacker/vnfm/plugin.py b/tacker/vnfm/plugin.py index 579dcb4d9..cd0f0c287 100644 --- a/tacker/vnfm/plugin.py +++ b/tacker/vnfm/plugin.py @@ -759,6 +759,10 @@ class VNFMPlugin(vnfm_db.VNFMPluginDb, VNFMMgmtMixin): cp = policy['properties']['resize_compute']['condition'].\ get('comparison_operator') if bckend_policy_type == constants.POLICY_SCALING: + if vnf_dict['status'] != constants.ACTIVE: + LOG.info(context, vnf_dict, + "Scaling Policy action skipped") + return action = 'scaling' scale = {} scale.setdefault('scale', {})