Fixes discrepancies with IM related to monitoring params 03/6803/3
authorBenjamin Diaz <bdiaz@whitestack.com>
Wed, 31 Oct 2018 03:58:22 +0000 (20:58 -0700)
committerBenjamin Diaz <bdiaz@whitestack.com>
Wed, 31 Oct 2018 04:04:56 +0000 (21:04 -0700)
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
Change-Id: Ie57107550b229292fad7ecb9ed154dd51bf5985e

osm_policy_module/core/agent.py
osm_policy_module/core/database.py
osm_policy_module/tests/integration/test_policy_agent.py

index 1e81141..24f1004 100644 (file)
@@ -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()
index e522b8d..7702cfd 100644 (file)
@@ -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: ")
index 11bc969..3126c0f 100644 (file)
@@ -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",