lambda param: param['id'] == alarm_descriptor['vnf-monitoring-param-ref'],
vnfd['monitoring-param'])
)
+ metric_name = self._get_metric_name(vnf_monitoring_param, vdur, vnfd)
alarm_uuid = await self.mon_client.create_alarm(
- metric_name=alarm_descriptor['vnf-monitoring-param-ref'],
+ metric_name=metric_name,
ns_id=nsr_id,
vdu_name=vdur['name'],
vnf_member_index=vnfr['member-vnf-index-ref'],
log.debug("There is no alarming action configured for alarm %s.", alarm_uuid)
finally:
database.db.close()
+
+ def _get_metric_name(self, vnf_monitoring_param: dict, vdur: dict, vnfd: dict):
+ vdu = next(
+ filter(lambda vdu: vdu['id'] == vdur['vdu-id-ref'], vnfd['vdu'])
+ )
+ if 'vdu-monitoring-param' in vnf_monitoring_param:
+ vdu_monitoring_param = next(filter(
+ lambda param: param['id'] == vnf_monitoring_param['vdu-monitoring-param'][
+ 'vdu-monitoring-param-ref'], vdu['monitoring-param']))
+ nfvi_metric = vdu_monitoring_param['nfvi-metric']
+ return nfvi_metric
+ if 'vdu-metric' in vnf_monitoring_param:
+ vnf_metric_name = vnf_monitoring_param['vdu-metric']['vdu-metric-name-ref']
+ return vnf_metric_name
+ if 'vnf-metric' in vnf_monitoring_param:
+ vnf_metric_name = vnf_monitoring_param['vnf-metric']['vnf-metric-name-ref']
+ return vnf_metric_name
+ raise ValueError('No metric name found for vnf_monitoring_param %s' % vnf_monitoring_param['id'])
config = Config()
agent = PolicyModuleAgent(config, self.loop)
self.loop.run_until_complete(agent.alarming_service.configure_vnf_alarms("test_nsr_id"))
- create_alarm.assert_any_call(metric_name='cirros_vnf_memory_util',
+ create_alarm.assert_any_call(metric_name='average_memory_utilization',
ns_id='test_nsr_id',
- operation='LT',
- statistic='AVERAGE',
- threshold=20.0,
vdu_name='cirros_ns-1-cirros_vnfd-VM-1',
- vnf_member_index='1')
- create_alarm.assert_any_call(metric_name='cirros_vnf_memory_util',
- ns_id='test_nsr_id',
- operation='LT',
- statistic='AVERAGE',
+ vnf_member_index='1',
threshold=20.0,
+ operation='LT',
+ statistic='AVERAGE')
+ create_alarm.assert_any_call(metric_name='average_memory_utilization',
+ ns_id='test_nsr_id',
vdu_name='cirros_ns-2-cirros_vnfd-VM-1',
- vnf_member_index='2')
+ vnf_member_index='2',
+ threshold=20.0,
+ operation='LT',
+ statistic='AVERAGE')
if __name__ == '__main__':