From 9aed07979d592108f8f52a3ae6a742b914df6ca5 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Thu, 20 Apr 2023 13:08:57 +0000
Subject: [PATCH] Service component - L2NM OpenConfig ServiceHandler:

- Removed hardcoded histogram buckets
- Removed unneeded delete rules
- Corrected order of delete rules
---
 .../l2nm_openconfig/ConfigRules.py            | 20 +++++++++----------
 .../L2NMOpenConfigServiceHandler.py           | 17 +---------------
 2 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
index 63e818a83..5afedb33d 100644
--- a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
+++ b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
@@ -98,22 +98,22 @@ def teardown_config_rules(
 
     json_config_rules = [
 
-        json_config_rule_delete(
-            '/network_instance[{:s}]/connection_point[{:s}]'.format(network_instance_name, connection_point_id),
-            {'name': network_instance_name, 'connection_point': connection_point_id, 'VC_ID': circuit_id}),
+        #json_config_rule_delete(
+        #    '/network_instance[{:s}]/connection_point[{:s}]'.format(network_instance_name, connection_point_id),
+        #    {'name': network_instance_name, 'connection_point': connection_point_id, 'VC_ID': circuit_id}),
+
+        #json_config_rule_delete(
+        #    '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_cirid_name),
+        #    {'name': network_instance_name, 'id': if_cirid_name, 'interface': if_cirid_name,
+        #     'subinterface': sub_interface_index}),
 
         json_config_rule_delete(
-            '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_cirid_name),
-            {'name': network_instance_name, 'id': if_cirid_name, 'interface': if_cirid_name,
-             'subinterface': sub_interface_index}),
+            '/network_instance[{:s}]'.format(network_instance_name),
+            {'name': network_instance_name}),
 
         json_config_rule_delete(
             '/interface[{:s}]/subinterface[{:d}]'.format(if_cirid_name, sub_interface_index),
             {'name': if_cirid_name, 'index': sub_interface_index}),
 
-        json_config_rule_delete(
-            '/network_instance[{:s}]'.format(network_instance_name),
-            {'name': network_instance_name}),
-
     ]
     return json_config_rules
diff --git a/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py b/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py
index d511c8947..aae9e968b 100644
--- a/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py
+++ b/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py
@@ -14,7 +14,7 @@
 
 import json, logging
 from typing import Any, List, Optional, Tuple, Union
-from common.method_wrappers.Decorator import MetricTypeEnum, MetricsPool, metered_subclass_method, INF
+from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method
 from common.proto.context_pb2 import ConfigRule, DeviceId, Service
 from common.tools.object_factory.Device import json_device_id
 from common.type_checkers.Checkers import chk_type
@@ -26,22 +26,7 @@ from .ConfigRules import setup_config_rules, teardown_config_rules
 
 LOGGER = logging.getLogger(__name__)
 
-HISTOGRAM_BUCKETS = (
-    # .005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, INF
-    0.0010, 0.0025, 0.0050, 0.0075,
-    0.0100, 0.0250, 0.0500, 0.0750,
-    0.1000, 0.2500, 0.5000, 0.7500,
-    1.0000, 2.5000, 5.0000, 7.5000,
-    10.0000, 25.000, 50.0000, 75.000,
-    100.0, INF
-)
 METRICS_POOL = MetricsPool('Service', 'Handler', labels={'handler': 'l2nm_openconfig'})
-METRICS_POOL.get_or_create('SetEndpoint',      MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
-METRICS_POOL.get_or_create('DeleteEndpoint',   MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
-METRICS_POOL.get_or_create('SetConstraint',    MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
-METRICS_POOL.get_or_create('DeleteConstraint', MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
-METRICS_POOL.get_or_create('SetConfig',        MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
-METRICS_POOL.get_or_create('DeleteConfig',     MetricTypeEnum.HISTOGRAM_DURATION, buckets=HISTOGRAM_BUCKETS)
 
 class L2NMOpenConfigServiceHandler(_ServiceHandler):
     def __init__(   # pylint: disable=super-init-not-called
-- 
GitLab