From: Benjamin Diaz Date: Wed, 31 Oct 2018 03:58:22 +0000 (-0700) Subject: Fixes discrepancies with IM related to monitoring params X-Git-Tag: v5.0.0~6 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F03%2F6803%2F3;p=osm%2FPOL.git Fixes discrepancies with IM related to monitoring params Signed-off-by: Benjamin Diaz Change-Id: Ie57107550b229292fad7ecb9ed154dd51bf5985e --- diff --git a/osm_policy_module/core/agent.py b/osm_policy_module/core/agent.py index 1e81141..24f1004 100644 --- a/osm_policy_module/core/agent.py +++ b/osm_policy_module/core/agent.py @@ -223,10 +223,13 @@ class PolicyModuleAgent: vnf_monitoring_param = next( filter( lambda param: param['id'] == scaling_criteria[ - 'vnf-monitoring-param-ref'], + 'vnf-monitoring-param-ref' + ], vnf_monitoring_params) ) - if not vdu_ref['vdu-id-ref'] == vnf_monitoring_param['vdu-ref']: + if vdu_ref['vdu-id-ref'] != vnf_monitoring_param['vdu-monitoring-param'][ + 'vdu-ref' + ]: continue vdu = next( filter(lambda vdu: vdu['id'] == vdu_ref['vdu-id-ref'], vnfd['vdu']) @@ -235,11 +238,17 @@ class PolicyModuleAgent: vdu_monitoring_param = next( filter( lambda param: param['id'] == vnf_monitoring_param[ - 'vdu-monitoring-param-ref'], + 'vdu-monitoring-param' + ][ + 'vdu-monitoring-param-ref' + ], vdu_monitoring_params)) vdurs = list( - filter(lambda vdur: vdur['vdu-id-ref'] == vnf_monitoring_param['vdu-ref'], - vnfr['vdur'])) + filter(lambda vdur: vdur['vdu-id-ref'] == vnf_monitoring_param[ + 'vdu-monitoring-param' + ][ + 'vdu-ref' + ], vnfr['vdur'])) for vdur in vdurs: try: (ScalingAlarm.select() diff --git a/osm_policy_module/core/database.py b/osm_policy_module/core/database.py index e522b8d..7702cfd 100644 --- a/osm_policy_module/core/database.py +++ b/osm_policy_module/core/database.py @@ -75,5 +75,5 @@ class DatabaseManager: db.connect() db.create_tables([ScalingGroup, ScalingPolicy, ScalingCriteria, ScalingAlarm]) db.close() - except Exception as e: + except Exception: log.exception("Error creating tables: ") diff --git a/osm_policy_module/tests/integration/test_policy_agent.py b/osm_policy_module/tests/integration/test_policy_agent.py index 11bc969..3126c0f 100644 --- a/osm_policy_module/tests/integration/test_policy_agent.py +++ b/osm_policy_module/tests/integration/test_policy_agent.py @@ -326,10 +326,28 @@ vnfd_record_mock = { "id": "cirros_vnf_memory_util", "name": "cirros_vnf_memory_util", "aggregation-type": "AVERAGE", - "vdu-monitoring-param-ref": "cirros_vnfd-VM_memory_util", - "vdu-ref": "cirros_vnfd-VM" + "vdu-monitoring-param": { + "vdu-monitoring-param-ref": "cirros_vnfd-VM_memory_util", + "vdu-ref": "cirros_vnfd-VM" + } + }, + { + "id": "haproxy_users", + "name": "haproxy_users", + "aggregation-type": "AVERAGE", + "vnf-metric": + {"vnf-metric-name-ref": "users"} } ], + "vdu-configuration": { + "juju": { + "charm": "testmetrics", + "proxy": True + }, + "metrics": { + "name": "users" + } + }, "description": "Simple VNF example with a cirros and a scaling group descriptor", "id": "cirros_vdu_scaling_vnf", "logo": "cirros-64.png",