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
This commit is contained in:
vish 2016-10-01 02:11:34 +00:00
parent 42b0f867cf
commit 09edd7badf
2 changed files with 13 additions and 5 deletions

View File

@ -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')

View File

@ -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', {})