From 1587331770e329c611fa236791291d6a02982c3b Mon Sep 17 00:00:00 2001 From: armingol Date: Tue, 20 Dec 2022 09:18:07 +0100 Subject: [PATCH 01/19] Changes in local --- manifests/pathcompservice.yaml | 2 +- manifests/serviceservice.yaml | 2 +- scripts/run_tests_locally-device-openconfig.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/pathcompservice.yaml b/manifests/pathcompservice.yaml index 51c83a0f3..4492d1cb1 100644 --- a/manifests/pathcompservice.yaml +++ b/manifests/pathcompservice.yaml @@ -20,7 +20,7 @@ spec: selector: matchLabels: app: pathcompservice - replicas: 5 + replicas: 1 template: metadata: labels: diff --git a/manifests/serviceservice.yaml b/manifests/serviceservice.yaml index 089be20f9..d9ecc998e 100644 --- a/manifests/serviceservice.yaml +++ b/manifests/serviceservice.yaml @@ -20,7 +20,7 @@ spec: selector: matchLabels: app: serviceservice - replicas: 5 + replicas: 1 template: metadata: labels: diff --git a/scripts/run_tests_locally-device-openconfig.sh b/scripts/run_tests_locally-device-openconfig.sh index f87346fed..0d493db9c 100755 --- a/scripts/run_tests_locally-device-openconfig.sh +++ b/scripts/run_tests_locally-device-openconfig.sh @@ -14,7 +14,7 @@ # limitations under the License. -PROJECTDIR=`pwd` +PROJECTDIR=/home/ubuntu/controller/ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc -- GitLab From 9a9057960a1eb6fe53bab2860aee65679f1bb89b Mon Sep 17 00:00:00 2001 From: armingol Date: Wed, 21 Dec 2022 14:28:57 +0100 Subject: [PATCH 02/19] L3NM D3.2 evaluation changes --- .../l3nm_openconfig/ConfigRules.py | 242 +++++++----------- src/tests/tools/load_gen/RequestGenerator.py | 42 ++- src/tests/tools/load_gen/__main__.py | 8 +- 3 files changed, 134 insertions(+), 158 deletions(-) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 3a5aff588..49d49fa79 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -29,109 +29,109 @@ def setup_config_rules( network_interface_desc = '{:s}-NetIf'.format(service_uuid) network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid) - mtu = json_settings.get('mtu', 1450 ) # 1512 + mtu = 3000 # 1512 #address_families = json_settings.get('address_families', [] ) # ['IPV4'] - bgp_as = json_settings.get('bgp_as', 0 ) # 65000 - bgp_route_target = json_settings.get('bgp_route_target', '0:0') # 65000:333 + bgp_as = json_settings.get('bgp_as', 65000 ) # 65000 + bgp_route_target = json_settings.get('bgp_route_target', '65000:123') # 65000:333 - #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' + router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 + policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 + policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 + if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) json_config_rules = [ json_config_rule_set( '/network_instance[{:s}]'.format(network_instance_name), { - 'name': network_instance_name, 'description': network_interface_desc, 'type': 'L3VRF', + 'name': network_instance_name, + 'description': network_interface_desc, + 'type': 'L3VRF', 'route_distinguisher': route_distinguisher, - #'router_id': router_id, 'address_families': address_families, - }), - json_config_rule_set( - '/interface[{:s}]'.format(endpoint_uuid), { - 'name': endpoint_uuid, 'description': network_interface_desc, 'mtu': mtu, - }), - json_config_rule_set( - '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), { - 'name': endpoint_uuid, 'index': sub_interface_index, - 'description': network_subinterface_desc, 'vlan_id': vlan_id, - 'address_ip': address_ip, 'address_prefix': address_prefix, - }), - json_config_rule_set( - '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { - 'name': network_instance_name, 'id': if_subif_name, 'interface': endpoint_uuid, - 'subinterface': sub_interface_index, }), json_config_rule_set( '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), { - 'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP', 'as': bgp_as, - }), - json_config_rule_set( - '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { - 'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP', - 'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE', + 'name': network_instance_name, + 'protocol_name': 'BGP', + 'identifier': 'BGP', + 'as': bgp_as, + 'router_id': router_id, + }), + json_config_rule_set( + '/network_instance[{:s}]/protocols[DIRECTLY_CONNECTED]'.format(network_instance_name), { + 'name': network_instance_name, + 'identifier': 'DIRECTLY_CONNECTED', + 'protocol_name': 'DIRECTLY_CONNECTED', + }), + json_config_rule_set( + '/interface[{:s}]/subinterface[0]'.format(if_subif_name), { + 'name': if_subif_name, + 'type':'l3ipvlan', + 'mtu': mtu, + 'index': 0, + 'description': network_subinterface_desc, + 'vlan_id': vlan_id, + 'address_ip': address_ip, + 'address_prefix': address_prefix, }), json_config_rule_set( - '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( - network_instance_name), { - 'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP', - 'address_family': 'IPV4', #'default_import_policy': 'REJECT_ROUTE', - }), - json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), { - 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - }), + '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { + 'name': network_instance_name, + 'id': if_subif_name, + 'interface': if_subif_name, + 'subinterface': 0, + }), json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format( + '/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( network_instance_name, bgp_route_target), { 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), - }), - json_config_rule_set( - '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), { - 'policy_name': '{:s}_import'.format(network_instance_name), - }), + }), json_config_rule_set( - '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format( - network_instance_name, '3'), { - 'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3', + '/routing_policy/policy_definition[{:s}_import]/statement[3]'.format( + network_instance_name), { + 'policy_name': policy_import, + 'statement_name': '3', 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - 'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE', - }), + 'policy_result': 'ACCEPT_ROUTE', + }), json_config_rule_set( - # pylint: disable=duplicate-string-formatting-argument '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format( - network_instance_name, network_instance_name), { - 'name': network_instance_name, 'import_policy': '{:s}_import'.format(network_instance_name), - }), - json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), { - 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - }), + network_instance_name, policy_import), { + 'name': network_instance_name, + 'import_policy': policy_import, + }), json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format( + '/routing_policy/bgp_defined_set[{:s}_rt_export][{:s}]'.format( network_instance_name, bgp_route_target), { 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), - }), - json_config_rule_set( - '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), { - 'policy_name': '{:s}_export'.format(network_instance_name), - }), + }), json_config_rule_set( - '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format( - network_instance_name, '3'), { - 'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3', + '/routing_policy/policy_definition[{:s}_export]/statement[3]'.format( + network_instance_name), { + 'policy_name': policy_export, + 'statement_name': '3', 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - 'match_set_options': 'ANY', 'policy_result': 'ACCEPT_ROUTE', - }), + 'policy_result': 'ACCEPT_ROUTE', + }), json_config_rule_set( - # pylint: disable=duplicate-string-formatting-argument '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format( - network_instance_name, network_instance_name), { - 'name': network_instance_name, 'export_policy': '{:s}_export'.format(network_instance_name), + network_instance_name, policy_export), { + 'name': network_instance_name, + 'export_policy': policy_export, + }), + json_config_rule_set( + '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( + network_instance_name), { + 'name': network_instance_name, + 'src_protocol': 'DIRECTLY_CONNECTED', + 'dst_protocol': 'BGP', + 'address_family': 'IPV4', + 'default_import_policy': 'ACCEPT_ROUTE', }), ] @@ -145,101 +145,57 @@ def teardown_config_rules( json_settings : Dict = {} if service_settings is None else service_settings.value json_endpoint_settings : Dict = {} if endpoint_settings is None else endpoint_settings.value - #mtu = json_settings.get('mtu', 1450 ) # 1512 + service_short_uuid = service_uuid.split('-')[-1] + network_instance_name = '{:s}-NetInst'.format(service_short_uuid) + #network_interface_desc = '{:s}-NetIf'.format(service_uuid) + #network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid) + + #mtu = json_settings.get('mtu', 3000 ) # 1512 #address_families = json_settings.get('address_families', [] ) # ['IPV4'] - #bgp_as = json_settings.get('bgp_as', 0 ) # 65000 - bgp_route_target = json_settings.get('bgp_route_target', '0:0') # 65000:333 + #bgp_as = json_settings.get('bgp_as', 65000 ) # 65000 + bgp_route_target = json_settings.get('bgp_route_target', '65000:123') # 65000:333 #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 + policy_import = json_endpoint_settings.get('policy_1', 2 ) # 2 + policy_export = json_endpoint_settings.get('policy_2', 7 ) # 30 + + if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) - if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) - service_short_uuid = service_uuid.split('-')[-1] - network_instance_name = '{:s}-NetInst'.format(service_short_uuid) - #network_interface_desc = '{:s}-NetIf'.format(service_uuid) - #network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid) json_config_rules = [ - json_config_rule_delete( - '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { - 'name': network_instance_name, 'id': if_subif_name, - }), - json_config_rule_delete( - '/interface[{:s}]/subinterface[{:d}]'.format(endpoint_uuid, sub_interface_index), { - 'name': endpoint_uuid, 'index': sub_interface_index, - }), - json_config_rule_delete( - '/interface[{:s}]'.format(endpoint_uuid), { - 'name': endpoint_uuid, - }), json_config_rule_delete( '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( network_instance_name), { - 'name': network_instance_name, 'src_protocol': 'DIRECTLY_CONNECTED', 'dst_protocol': 'BGP', + 'name': network_instance_name, + 'src_protocol': 'DIRECTLY_CONNECTED', + 'dst_protocol': 'BGP', 'address_family': 'IPV4', }), - json_config_rule_delete( - '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { - 'name': network_instance_name, 'src_protocol': 'STATIC', 'dst_protocol': 'BGP', - 'address_family': 'IPV4', - }), - json_config_rule_delete( - '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), { - 'name': network_instance_name, 'identifier': 'BGP', 'protocol_name': 'BGP', - }), - json_config_rule_delete( - # pylint: disable=duplicate-string-formatting-argument - '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format( - network_instance_name, network_instance_name), { - 'name': network_instance_name, - }), - json_config_rule_delete( - '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format( - network_instance_name, '3'), { - 'policy_name': '{:s}_import'.format(network_instance_name), 'statement_name': '3', - }), - json_config_rule_delete( - '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), { - 'policy_name': '{:s}_import'.format(network_instance_name), + json_config_rule_delete('/routing_policy/policy_definition[{:s}_import]/statement[3]'.format( + network_instance_name),{ + 'policy_name' : policy_import, }), - json_config_rule_delete( - '/routing_policy/bgp_defined_set[{:s}_rt_import][route-target:{:s}]'.format( - network_instance_name, bgp_route_target), { + + json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( + network_instance_name,bgp_route_target),{ 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), }), - json_config_rule_delete( - '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), { - 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), + json_config_rule_delete('/routing_policy/policy_definition[{:s}_export]/statement[3]'.format( + network_instance_name),{ + 'policy_name' : policy_export, }), - json_config_rule_delete( - # pylint: disable=duplicate-string-formatting-argument - '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format( - network_instance_name, network_instance_name), { - 'name': network_instance_name, - }), - json_config_rule_delete( - '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format( - network_instance_name, '3'), { - 'policy_name': '{:s}_export'.format(network_instance_name), 'statement_name': '3', - }), - json_config_rule_delete( - '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), { - 'policy_name': '{:s}_export'.format(network_instance_name), - }), - json_config_rule_delete( - '/routing_policy/bgp_defined_set[{:s}_rt_export][route-target:{:s}]'.format( - network_instance_name, bgp_route_target), { + + json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( + network_instance_name,bgp_route_target),{ 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), }), json_config_rule_delete( - '/routing_policy/bgp_defined_set[{:s}_rt_export]'.format(network_instance_name), { - 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), + '/interface[{:s}]'.format(if_subif_name), { + 'name': if_subif_name, }), json_config_rule_delete( '/network_instance[{:s}]'.format(network_instance_name), { diff --git a/src/tests/tools/load_gen/RequestGenerator.py b/src/tests/tools/load_gen/RequestGenerator.py index b0ec9bea6..7f146fe99 100644 --- a/src/tests/tools/load_gen/RequestGenerator.py +++ b/src/tests/tools/load_gen/RequestGenerator.py @@ -31,6 +31,11 @@ from .Parameters import Parameters LOGGER = logging.getLogger(__name__) +ROUTER_ID = { + 'R149': '5.5.5.5', + 'R155': '5.5.5.1', +} + class RequestGenerator: def __init__(self, parameters : Parameters) -> None: self._parameters = parameters @@ -205,8 +210,10 @@ class RequestGenerator: ] vlan_id = num_request % 1000 circuit_id = '{:03d}'.format(vlan_id) - src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) - dst_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) + src_router_id = ROUTER_ID.get(src_device_uuid) + if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) + dst_router_id = ROUTER_ID.get(dst_device_uuid) + if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(int(dst_device_uuid.replace('R', ''))) config_rules = [ json_config_rule_set('/settings', { 'mtu': 1512 @@ -234,35 +241,48 @@ class RequestGenerator: json_constraint_custom('bandwidth[gbps]', '10.0'), json_constraint_custom('latency[ms]', '20.0'), ] - vlan_id = num_request % 1000 - bgp_as = 60000 + (num_request % 10000) + + bgp_as = 65000 + (num_request % 10000) + + + vlan_id = num_request % 100 +100 + x= num_request % 255 + y= num_request % 25 * num_request % 10 bgp_route_target = '{:5d}:{:03d}'.format(bgp_as, 333) route_distinguisher = '{:5d}:{:03d}'.format(bgp_as, vlan_id) - src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) - dst_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) - src_address_ip = '.'.join([src_device_uuid.replace('R', ''), '0'] + src_endpoint_uuid.split('/')) - dst_address_ip = '.'.join([dst_device_uuid.replace('R', ''), '0'] + dst_endpoint_uuid.split('/')) + src_router_id = ROUTER_ID.get(src_device_uuid) + if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) + dst_router_id = ROUTER_ID.get(dst_device_uuid) + if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(int(dst_device_uuid.replace('R', ''))) + src_address_ip = '10.{:d}.{:d}.{:d}'.format(x,y,int(src_device_uuid.replace('R', ''))) + dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y,x,int(dst_device_uuid.replace('R', ''))) + policy_R1 = '7' + policy_R2 = '2' + config_rules = [ json_config_rule_set('/settings', { - 'mtu' : 1512, 'bgp_as' : bgp_as, 'bgp_route_target': bgp_route_target, }), json_config_rule_set('/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_uuid, src_endpoint_uuid), { 'router_id' : src_router_id, 'route_distinguisher': route_distinguisher, - 'sub_interface_index': vlan_id, 'vlan_id' : vlan_id, 'address_ip' : src_address_ip, 'address_prefix' : 16, + 'policy_1' : policy_R1, + 'policy_2' : policy_R2, + }), json_config_rule_set('/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_uuid, dst_endpoint_uuid), { 'router_id' : dst_router_id, 'route_distinguisher': route_distinguisher, - 'sub_interface_index': vlan_id, 'vlan_id' : vlan_id, 'address_ip' : dst_address_ip, 'address_prefix' : 16, + 'policy_1' : policy_R2, + 'policy_2' : policy_R1, + }), ] return json_service_l3nm_planned( diff --git a/src/tests/tools/load_gen/__main__.py b/src/tests/tools/load_gen/__main__.py index f622f4d14..88b4b16b1 100644 --- a/src/tests/tools/load_gen/__main__.py +++ b/src/tests/tools/load_gen/__main__.py @@ -24,13 +24,13 @@ LOGGER = logging.getLogger(__name__) def main(): LOGGER.info('Starting...') parameters = Parameters( - num_requests = 100, + num_requests = 1, request_types = [ - RequestType.SERVICE_L2NM, + #RequestType.SERVICE_L2NM, RequestType.SERVICE_L3NM, #RequestType.SERVICE_TAPI, - RequestType.SLICE_L2NM, - RequestType.SLICE_L3NM, + #RequestType.SLICE_L2NM, + #RequestType.SLICE_L3NM, ], offered_load = 50, holding_time = 10, -- GitLab From 993f9903a1e6883bc930afae01c68589e73398ad Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Wed, 21 Dec 2022 14:00:44 +0000 Subject: [PATCH 03/19] Service Handler L3NM OpenConfig - skipped endpoint configuration when no config rules are speicfied for an endpoint --- .../l3nm_openconfig/ConfigRules.py | 7 ++++-- .../L3NMOpenConfigServiceHandler.py | 24 +++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 49d49fa79..2a8f7794b 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -21,8 +21,11 @@ def setup_config_rules( service_settings : TreeNode, endpoint_settings : TreeNode ) -> List[Dict]: - json_settings : Dict = {} if service_settings is None else service_settings.value - json_endpoint_settings : Dict = {} if endpoint_settings is None else endpoint_settings.value + if service_settings is None: return [] + if endpoint_settings is None: return [] + + json_settings : Dict = service_settings.value + json_endpoint_settings : Dict = endpoint_settings.value service_short_uuid = service_uuid.split('-')[-1] network_instance_name = '{:s}-NetInst'.format(service_short_uuid) diff --git a/src/service/service/service_handlers/l3nm_openconfig/L3NMOpenConfigServiceHandler.py b/src/service/service/service_handlers/l3nm_openconfig/L3NMOpenConfigServiceHandler.py index 0f5cb6c55..3f8fc566c 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/L3NMOpenConfigServiceHandler.py +++ b/src/service/service/service_handlers/l3nm_openconfig/L3NMOpenConfigServiceHandler.py @@ -86,12 +86,12 @@ class L3NMOpenConfigServiceHandler(_ServiceHandler): json_config_rules = setup_config_rules( service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings) - - device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) - del device.device_config.config_rules[:] - for json_config_rule in json_config_rules: - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - self.__task_executor.configure_device(device) + if len(json_config_rules) > 0: + device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) + del device.device_config.config_rules[:] + for json_config_rule in json_config_rules: + device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + self.__task_executor.configure_device(device) results.append(True) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unable to SetEndpoint({:s})'.format(str(endpoint))) @@ -121,12 +121,12 @@ class L3NMOpenConfigServiceHandler(_ServiceHandler): json_config_rules = teardown_config_rules( service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings) - - device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) - del device.device_config.config_rules[:] - for json_config_rule in json_config_rules: - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - self.__task_executor.configure_device(device) + if len(json_config_rules) > 0: + device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) + del device.device_config.config_rules[:] + for json_config_rule in json_config_rules: + device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + self.__task_executor.configure_device(device) results.append(True) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unable to DeleteEndpoint({:s})'.format(str(endpoint))) -- GitLab From 2942dea40f427f704442c3b53b7a545f6c9e4c14 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Wed, 21 Dec 2022 14:49:14 +0000 Subject: [PATCH 04/19] Tools - load-gen: - fixing L3NM tests --- src/tests/tools/load_gen/RequestGenerator.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tests/tools/load_gen/RequestGenerator.py b/src/tests/tools/load_gen/RequestGenerator.py index 7f146fe99..51b80d972 100644 --- a/src/tests/tools/load_gen/RequestGenerator.py +++ b/src/tests/tools/load_gen/RequestGenerator.py @@ -248,17 +248,19 @@ class RequestGenerator: vlan_id = num_request % 100 +100 x= num_request % 255 y= num_request % 25 * num_request % 10 - bgp_route_target = '{:5d}:{:03d}'.format(bgp_as, 333) + bgp_route_target = '{:5d}:{:03d}'.format(bgp_as, vlan_id) route_distinguisher = '{:5d}:{:03d}'.format(bgp_as, vlan_id) src_router_id = ROUTER_ID.get(src_device_uuid) - if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) + src_router_num = int(src_device_uuid.replace('R', '')) + if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(src_router_num) + dst_router_num = int(dst_device_uuid.replace('R', '')) dst_router_id = ROUTER_ID.get(dst_device_uuid) - if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(int(dst_device_uuid.replace('R', ''))) + if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) src_address_ip = '10.{:d}.{:d}.{:d}'.format(x,y,int(src_device_uuid.replace('R', ''))) dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y,x,int(dst_device_uuid.replace('R', ''))) - policy_R1 = '7' - policy_R2 = '2' - + policy_R1 = num_request * 10 + src_router_num * 5 + dst_router_num + policy_R2 = num_request * 10 + dst_router_num * 5 + src_router_num + config_rules = [ json_config_rule_set('/settings', { 'bgp_as' : bgp_as, -- GitLab From 04ca36b1c79408fd612b9819a88c29127d9939bf Mon Sep 17 00:00:00 2001 From: armingol Date: Thu, 22 Dec 2022 19:20:07 +0100 Subject: [PATCH 05/19] TEST L2VPN changes --- .../l2nm_openconfig/ConfigRules.py | 84 ++++++++---------- .../L2NMOpenConfigServiceHandler.py | 24 +++--- .../l3nm_openconfig/ConfigRules.py | 86 +++---------------- src/tests/tools/load_gen/RequestGenerator.py | 13 ++- src/tests/tools/load_gen/__main__.py | 8 +- 5 files changed, 76 insertions(+), 139 deletions(-) diff --git a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py index f12c9ab98..8d08d6bdd 100644 --- a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py @@ -20,58 +20,63 @@ def setup_config_rules( service_uuid : str, connection_uuid : str, device_uuid : str, endpoint_uuid : str, service_settings : TreeNode, endpoint_settings : TreeNode ) -> List[Dict]: + + if service_settings is None: return [] + if endpoint_settings is None: return [] + + json_settings : Dict = service_settings.value + json_endpoint_settings : Dict = endpoint_settings.value json_settings : Dict = {} if service_settings is None else service_settings.value json_endpoint_settings : Dict = {} if endpoint_settings is None else endpoint_settings.value - mtu = json_settings.get('mtu', 1450 ) # 1512 + #mtu = json_settings.get('mtu', 1450 ) # 1512 #address_families = json_settings.get('address_families', [] ) # ['IPV4'] #bgp_as = json_settings.get('bgp_as', 0 ) # 65000 #bgp_route_target = json_settings.get('bgp_route_target', '0:0') # 65000:333 - router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' + #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 + #sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 - remote_router = json_endpoint_settings.get('remote_router', '0.0.0.0') # '5.5.5.5' - circuit_id = json_endpoint_settings.get('circuit_id', '000' ) # '111' + remote_router = json_endpoint_settings.get('remote_router', '5.5.5.5') # '5.5.5.5' + circuit_id = json_endpoint_settings.get('circuit_id', '111' ) # '111' if_cirid_name = '{:s}.{:s}'.format(endpoint_uuid, str(circuit_id)) network_instance_name = 'ELAN-AC:{:s}'.format(str(circuit_id)) connection_point_id = 'VC-1' json_config_rules = [ - json_config_rule_set( - '/network_instance[default]', - {'name': 'default', 'type': 'DEFAULT_INSTANCE', 'router_id': router_id}), - - json_config_rule_set( - '/network_instance[default]/protocols[OSPF]', - {'name': 'default', 'identifier': 'OSPF', 'protocol_name': 'OSPF'}), - - json_config_rule_set( - '/network_instance[default]/protocols[STATIC]', - {'name': 'default', 'identifier': 'STATIC', 'protocol_name': 'STATIC'}), - + json_config_rule_set( '/network_instance[{:s}]'.format(network_instance_name), - {'name': network_instance_name, 'type': 'L2VSI'}), + {'name': network_instance_name, + 'type': 'L2VSI'}), json_config_rule_set( - '/interface[{:s}]/subinterface[{:d}]'.format(if_cirid_name, sub_interface_index), - {'name': if_cirid_name, 'type': 'l2vlan', 'index': sub_interface_index, 'vlan_id': vlan_id}), + '/interface[{:s}]/subinterface[0]'.format(if_cirid_name), + {'name': if_cirid_name, + 'type': 'l2vlan', + 'index': 0, + 'vlan_id': vlan_id}), json_config_rule_set( '/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}), + {'name': network_instance_name, + 'id': if_cirid_name, + 'interface': if_cirid_name, + 'subinterface': 0 + }), json_config_rule_set( '/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, - 'remote_system': remote_router}), + {'name': network_instance_name, + 'connection_point': connection_point_id, + 'VC_ID': circuit_id, + 'remote_system': remote_router + }), ] return json_config_rules @@ -88,9 +93,9 @@ def teardown_config_rules( #bgp_as = json_settings.get('bgp_as', 0 ) # 65000 #bgp_route_target = json_settings.get('bgp_route_target', '0:0') # 65000:333 - router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' + #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 + #sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 #vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 @@ -102,33 +107,16 @@ def teardown_config_rules( connection_point_id = 'VC-1' 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}), + - 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( - '/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}), - - json_config_rule_delete( - '/network_instance[default]/protocols[STATIC]', - {'name': 'default', 'identifier': 'STATIC', 'protocol_name': 'STATIC'}), - - json_config_rule_delete( - '/network_instance[default]/protocols[OSPF]', - {'name': 'default', 'identifier': 'OSPF', 'protocol_name': 'OSPF'}), - + json_config_rule_delete( - '/network_instance[default]', - {'name': 'default', 'type': 'DEFAULT_INSTANCE', 'router_id': router_id}), + '/interface[{:s}]'.format(if_cirid_name), { + 'name': if_cirid_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 23df44413..6c41ac785 100644 --- a/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py +++ b/src/service/service/service_handlers/l2nm_openconfig/L2NMOpenConfigServiceHandler.py @@ -86,12 +86,12 @@ class L2NMOpenConfigServiceHandler(_ServiceHandler): json_config_rules = setup_config_rules( service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings) - - device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) - del device.device_config.config_rules[:] - for json_config_rule in json_config_rules: - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - self.__task_executor.configure_device(device) + if len(json_config_rules) > 0: + device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) + del device.device_config.config_rules[:] + for json_config_rule in json_config_rules: + device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + self.__task_executor.configure_device(device) results.append(True) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unable to SetEndpoint({:s})'.format(str(endpoint))) @@ -121,12 +121,12 @@ class L2NMOpenConfigServiceHandler(_ServiceHandler): json_config_rules = teardown_config_rules( service_uuid, connection_uuid, device_uuid, endpoint_uuid, settings, endpoint_settings) - - device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) - del device.device_config.config_rules[:] - for json_config_rule in json_config_rules: - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - self.__task_executor.configure_device(device) + if len(json_config_rules) > 0: + device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) + del device.device_config.config_rules[:] + for json_config_rule in json_config_rules: + device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + self.__task_executor.configure_device(device) results.append(True) except Exception as e: # pylint: disable=broad-except LOGGER.exception('Unable to DeleteEndpoint({:s})'.format(str(endpoint))) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 2a8f7794b..40f9d46ea 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -87,46 +87,6 @@ def setup_config_rules( 'interface': if_subif_name, 'subinterface': 0, }), - json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( - network_instance_name, bgp_route_target), { - 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), - }), - json_config_rule_set( - '/routing_policy/policy_definition[{:s}_import]/statement[3]'.format( - network_instance_name), { - 'policy_name': policy_import, - 'statement_name': '3', - 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - 'policy_result': 'ACCEPT_ROUTE', - }), - json_config_rule_set( - '/network_instance[{:s}]/inter_instance_policies[{:s}_import]'.format( - network_instance_name, policy_import), { - 'name': network_instance_name, - 'import_policy': policy_import, - }), - json_config_rule_set( - '/routing_policy/bgp_defined_set[{:s}_rt_export][{:s}]'.format( - network_instance_name, bgp_route_target), { - 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - 'ext_community_member' : 'route-target:{:s}'.format(bgp_route_target), - }), - json_config_rule_set( - '/routing_policy/policy_definition[{:s}_export]/statement[3]'.format( - network_instance_name), { - 'policy_name': policy_export, - 'statement_name': '3', - 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - 'policy_result': 'ACCEPT_ROUTE', - }), - json_config_rule_set( - '/network_instance[{:s}]/inter_instance_policies[{:s}_export]'.format( - network_instance_name, policy_export), { - 'name': network_instance_name, - 'export_policy': policy_export, - }), json_config_rule_set( '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( network_instance_name), { @@ -163,46 +123,28 @@ def teardown_config_rules( vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 - policy_import = json_endpoint_settings.get('policy_1', 2 ) # 2 - policy_export = json_endpoint_settings.get('policy_2', 7 ) # 30 + policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 + policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) json_config_rules = [ - json_config_rule_delete( - '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( - network_instance_name), { - 'name': network_instance_name, - 'src_protocol': 'DIRECTLY_CONNECTED', - 'dst_protocol': 'BGP', - 'address_family': 'IPV4', - }), - json_config_rule_delete('/routing_policy/policy_definition[{:s}_import]/statement[3]'.format( - network_instance_name),{ - 'policy_name' : policy_import, - }), - - json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( - network_instance_name,bgp_route_target),{ - 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - }), - json_config_rule_delete('/routing_policy/policy_definition[{:s}_export]/statement[3]'.format( - network_instance_name),{ - 'policy_name' : policy_export, - }), - - json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( - network_instance_name,bgp_route_target),{ - 'ext_community_set_name': '{:s}_rt_export'.format(network_instance_name), - }), + # json_config_rule_delete( + # '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { + # 'name': network_instance_name, + # 'id': if_subif_name, + # 'interface': if_subif_name, + # 'subinterface': 0, + # }), json_config_rule_delete( '/interface[{:s}]'.format(if_subif_name), { 'name': if_subif_name, }), - json_config_rule_delete( - '/network_instance[{:s}]'.format(network_instance_name), { - 'name': network_instance_name - }), + # json_config_rule_delete( + # '/network_instance[{:s}]'.format(network_instance_name), { + # 'name': network_instance_name + # }), + ] return json_config_rules diff --git a/src/tests/tools/load_gen/RequestGenerator.py b/src/tests/tools/load_gen/RequestGenerator.py index 51b80d972..419708f85 100644 --- a/src/tests/tools/load_gen/RequestGenerator.py +++ b/src/tests/tools/load_gen/RequestGenerator.py @@ -35,6 +35,10 @@ ROUTER_ID = { 'R149': '5.5.5.5', 'R155': '5.5.5.1', } +VIRTUALCIRCUIT = { + 'R149': '5.5.5.5', + 'R155': '5.5.5.1', +} class RequestGenerator: def __init__(self, parameters : Parameters) -> None: @@ -209,11 +213,13 @@ class RequestGenerator: json_constraint_custom('latency[ms]', '20.0'), ] vlan_id = num_request % 1000 - circuit_id = '{:03d}'.format(vlan_id) + circuit_id = vlan_id + 100 src_router_id = ROUTER_ID.get(src_device_uuid) if src_router_id is None: src_router_id = '10.0.0.{:d}'.format(int(src_device_uuid.replace('R', ''))) dst_router_id = ROUTER_ID.get(dst_device_uuid) if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(int(dst_device_uuid.replace('R', ''))) + remote = VIRTUALCIRCUIT.get(src_device_uuid) + config_rules = [ json_config_rule_set('/settings', { 'mtu': 1512 @@ -224,6 +230,7 @@ class RequestGenerator: 'vlan_id': vlan_id, 'remote_router': dst_router_id, 'circuit_id': circuit_id, + 'remote': remote, }), json_config_rule_set('/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_uuid, dst_endpoint_uuid), { 'router_id': dst_router_id, @@ -258,8 +265,8 @@ class RequestGenerator: if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) src_address_ip = '10.{:d}.{:d}.{:d}'.format(x,y,int(src_device_uuid.replace('R', ''))) dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y,x,int(dst_device_uuid.replace('R', ''))) - policy_R1 = num_request * 10 + src_router_num * 5 + dst_router_num - policy_R2 = num_request * 10 + dst_router_num * 5 + src_router_num + policy_R1 = vlan_id = num_request % 100 + policy_R2 = vlan_id = num_request % 100 +1 config_rules = [ json_config_rule_set('/settings', { diff --git a/src/tests/tools/load_gen/__main__.py b/src/tests/tools/load_gen/__main__.py index 88b4b16b1..c3e86cc3e 100644 --- a/src/tests/tools/load_gen/__main__.py +++ b/src/tests/tools/load_gen/__main__.py @@ -24,15 +24,15 @@ LOGGER = logging.getLogger(__name__) def main(): LOGGER.info('Starting...') parameters = Parameters( - num_requests = 1, + num_requests = 20, request_types = [ - #RequestType.SERVICE_L2NM, + RequestType.SERVICE_L2NM, RequestType.SERVICE_L3NM, #RequestType.SERVICE_TAPI, #RequestType.SLICE_L2NM, #RequestType.SLICE_L3NM, - ], - offered_load = 50, + ], + offered_load = 10, holding_time = 10, dry_mode = False, # in dry mode, no request is sent to TeraFlowSDN record_to_dlt = False, # if record_to_dlt, changes in device/link/service/slice are uploaded to DLT -- GitLab From e328939cee183f3b8cf2b9959e84f330ed9d689f Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Fri, 23 Dec 2022 09:06:44 +0000 Subject: [PATCH 06/19] Device component - OpenConfig Driver - added device identification per log line --- .../drivers/openconfig/OpenConfigDriver.py | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index 4aa42b180..d45ea48c4 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -38,8 +38,6 @@ logging.getLogger('apscheduler.executors.default').setLevel(logging.INFO if DEBU logging.getLogger('apscheduler.scheduler').setLevel(logging.INFO if DEBUG_MODE else logging.ERROR) logging.getLogger('monitoring-client').setLevel(logging.INFO if DEBUG_MODE else logging.ERROR) -LOGGER = logging.getLogger(__name__) - RE_GET_ENDPOINT_FROM_INTERFACE_KEY = re.compile(r'.*interface\[([^\]]+)\].*') RE_GET_ENDPOINT_FROM_INTERFACE_XPATH = re.compile(r".*interface\[oci\:name\='([^\]]+)'\].*") @@ -141,8 +139,9 @@ def compute_delta_sample(previous_sample, previous_timestamp, current_sample, cu return delta_sample class SamplesCache: - def __init__(self, netconf_handler : NetconfSessionHandler) -> None: + def __init__(self, netconf_handler : NetconfSessionHandler, logger : logging.Logger) -> None: self.__netconf_handler = netconf_handler + self.__logger = logger self.__lock = threading.Lock() self.__timestamp = None self.__absolute_samples = {} @@ -166,7 +165,7 @@ class SamplesCache: self.__absolute_samples[interface] = samples self.__timestamp = now except: # pylint: disable=bare-except - LOGGER.exception('Error collecting samples') + self.__logger.exception('Error collecting samples') def get(self, resource_key : str) -> Tuple[float, Dict]: self._refresh_samples() @@ -176,31 +175,33 @@ class SamplesCache: interface = match.group(1) return self.__timestamp, copy.deepcopy(self.__delta_samples.get(interface, {})) -def do_sampling(samples_cache : SamplesCache, resource_key : str, out_samples : queue.Queue) -> None: +def do_sampling( + samples_cache : SamplesCache, logger : logging.Logger, resource_key : str, out_samples : queue.Queue +) -> None: try: timestamp, samples = samples_cache.get(resource_key) counter_name = resource_key.split('/')[-1].split(':')[-1] value = samples.get(counter_name) if value is None: - LOGGER.warning('[do_sampling] value not found for {:s}'.format(resource_key)) + logger.warning('[do_sampling] value not found for {:s}'.format(resource_key)) return sample = (timestamp, resource_key, value) out_samples.put_nowait(sample) except: # pylint: disable=bare-except - LOGGER.exception('Error retrieving samples') + logger.exception('Error retrieving samples') def edit_config( - netconf_handler : NetconfSessionHandler, resources : List[Tuple[str, Any]], delete=False, commit_per_rule= False, - target='running', default_operation='merge', test_option=None, error_option=None, + netconf_handler : NetconfSessionHandler, logger : logging.Logger, resources : List[Tuple[str, Any]], delete=False, + commit_per_rule= False, target='running', default_operation='merge', test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin ): str_method = 'DeleteConfig' if delete else 'SetConfig' - LOGGER.info('[{:s}] resources = {:s}'.format(str_method, str(resources))) + logger.info('[{:s}] resources = {:s}'.format(str_method, str(resources))) results = [None for _ in resources] for i,resource in enumerate(resources): str_resource_name = 'resources[#{:d}]'.format(i) try: - LOGGER.info('[{:s}] resource = {:s}'.format(str_method, str(resource))) + logger.info('[{:s}] resource = {:s}'.format(str_method, str(resource))) chk_type(str_resource_name, resource, (list, tuple)) chk_length(str_resource_name, resource, min_length=2, max_length=2) resource_key,resource_value = resource @@ -208,7 +209,7 @@ def edit_config( str_config_message = compose_config( resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor) if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) - LOGGER.info('[{:s}] str_config_message[{:d}] = {:s}'.format( + logger.info('[{:s}] str_config_message[{:d}] = {:s}'.format( str_method, len(str_config_message), str(str_config_message))) netconf_handler.edit_config( config=str_config_message, target=target, default_operation=default_operation, @@ -219,7 +220,7 @@ def edit_config( except Exception as e: # pylint: disable=broad-except str_operation = 'preparing' if target == 'candidate' else ('deleting' if delete else 'setting') msg = '[{:s}] Exception {:s} {:s}: {:s}' - LOGGER.exception(msg.format(str_method, str_operation, str_resource_name, str(resource))) + logger.exception(msg.format(str_method, str_operation, str_resource_name, str(resource))) results[i] = e # if validation fails, store the exception return results @@ -243,6 +244,7 @@ METRICS_POOL.get_or_create('UnsubscribeState', MetricTypeEnum.HISTOGRAM_DURATION class OpenConfigDriver(_Driver): def __init__(self, address : str, port : int, **settings) -> None: # pylint: disable=super-init-not-called + self.__logger = logging.getLogger('{:s}:[{:s}:{:s}]'.format(str(__name__), str(address), str(port))) self.__lock = threading.Lock() #self.__initial = TreeNode('.') #self.__running = TreeNode('.') @@ -257,7 +259,7 @@ class OpenConfigDriver(_Driver): timezone=pytz.utc) self.__out_samples = queue.Queue() self.__netconf_handler : NetconfSessionHandler = NetconfSessionHandler(address, port, **settings) - self.__samples_cache = SamplesCache(self.__netconf_handler) + self.__samples_cache = SamplesCache(self.__netconf_handler, self.__logger) def Connect(self) -> bool: with self.__lock: @@ -295,13 +297,14 @@ class OpenConfigDriver(_Driver): try: chk_string(str_resource_name, resource_key, allow_empty=False) str_filter = get_filter(resource_key) - LOGGER.info('[GetConfig] str_filter = {:s}'.format(str(str_filter))) + self.__logger.info('[GetConfig] str_filter = {:s}'.format(str(str_filter))) if str_filter is None: str_filter = resource_key xml_data = self.__netconf_handler.get(filter=str_filter).data_ele if isinstance(xml_data, Exception): raise xml_data results.extend(parse(resource_key, xml_data)) except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception retrieving {:s}: {:s}'.format(str_resource_name, str(resource_key))) + MSG = 'Exception retrieving {:s}: {:s}' + self.__logger.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) # if validation fails, store the exception return results @@ -312,17 +315,19 @@ class OpenConfigDriver(_Driver): with self.__lock: if self.__netconf_handler.use_candidate: with self.__netconf_handler.locked(target='candidate'): - if self.__netconf_handler.commit_per_rule: - results = edit_config(self.__netconf_handler, resources, target='candidate', commit_per_rule= True) - else: - results = edit_config(self.__netconf_handler, resources, target='candidate') + commit_per_rule = bool(self.__netconf_handler.commit_per_rule) + results = edit_config( + self.__netconf_handler, self.__logger, resources, target='candidate', + commit_per_rule=commit_per_rule) + if not commit_per_rule: try: self.__netconf_handler.commit() except Exception as e: # pylint: disable=broad-except - LOGGER.exception('[SetConfig] Exception commiting resources: {:s}'.format(str(resources))) + MSG = '[SetConfig] Exception commiting resources: {:s}' + self.__logger.exception(MSG.format(str(resources))) results = [e for _ in resources] # if commit fails, set exception in each resource else: - results = edit_config(self.__netconf_handler, resources) + results = edit_config(self.__netconf_handler, self.__logger, resources) return results @metered_subclass_method(METRICS_POOL) @@ -332,17 +337,19 @@ class OpenConfigDriver(_Driver): with self.__lock: if self.__netconf_handler.use_candidate: with self.__netconf_handler.locked(target='candidate'): - if self.__netconf_handler.commit_per_rule: - results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True, commit_per_rule= True) - else: - results = edit_config(self.__netconf_handler, resources, target='candidate', delete=True) + commit_per_rule = bool(self.__netconf_handler.commit_per_rule) + results = edit_config( + self.__netconf_handler, self.__logger, resources, target='candidate', delete=True, + commit_per_rule=commit_per_rule) + if not commit_per_rule: try: self.__netconf_handler.commit() except Exception as e: # pylint: disable=broad-except - LOGGER.exception('[DeleteConfig] Exception commiting resources: {:s}'.format(str(resources))) + MSG = '[DeleteConfig] Exception commiting resources: {:s}' + self.__logger.exception(MSG.format(str(resources))) results = [e for _ in resources] # if commit fails, set exception in each resource else: - results = edit_config(self.__netconf_handler, resources, delete=True) + results = edit_config(self.__netconf_handler, self.__logger, resources, delete=True) return results @metered_subclass_method(METRICS_POOL) @@ -363,7 +370,8 @@ class OpenConfigDriver(_Driver): chk_float(str_subscription_name + '.sampling_duration', sampling_duration, min_value=0) chk_float(str_subscription_name + '.sampling_interval', sampling_interval, min_value=0) except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception validating {:s}: {:s}'.format(str_subscription_name, str(resource_key))) + MSG = 'Exception validating {:s}: {:s}' + self.__logger.exception(MSG.format(str_subscription_name, str(resource_key))) results.append(e) # if validation fails, store the exception continue @@ -374,7 +382,7 @@ class OpenConfigDriver(_Driver): job_id = 'k={:s}/d={:f}/i={:f}'.format(resource_key, sampling_duration, sampling_interval) job = self.__scheduler.add_job( - do_sampling, args=(self.__samples_cache, resource_key, self.__out_samples), + do_sampling, args=(self.__samples_cache, self.__logger, resource_key, self.__out_samples), kwargs={}, id=job_id, trigger='interval', seconds=sampling_interval, start_date=start_date, end_date=end_date, timezone=pytz.utc) @@ -401,7 +409,8 @@ class OpenConfigDriver(_Driver): chk_float(str_subscription_name + '.sampling_duration', sampling_duration, min_value=0) chk_float(str_subscription_name + '.sampling_interval', sampling_interval, min_value=0) except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Exception validating {:s}: {:s}'.format(str_subscription_name, str(resource_key))) + MSG = 'Exception validating {:s}: {:s}' + self.__logger.exception(MSG.format(str_subscription_name, str(resource_key))) results.append(e) # if validation fails, store the exception continue -- GitLab From fe0bcebd30b6711393127f1568da684e5d4dd77f Mon Sep 17 00:00:00 2001 From: armingol Date: Fri, 23 Dec 2022 12:29:11 +0100 Subject: [PATCH 07/19] Correct the delete error message --- src/device/service/driver_api/Tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/device/service/driver_api/Tools.py b/src/device/service/driver_api/Tools.py index 19c81d89b..2d8ce8530 100644 --- a/src/device/service/driver_api/Tools.py +++ b/src/device/service/driver_api/Tools.py @@ -28,7 +28,7 @@ def _set(resource : Tuple[str, Any]): return ACTION_MSG_SET.format(*tuple(map(str, resource))) def _delete(resource : Tuple[str, Any]): - return ACTION_MSG_SET.format(*tuple(map(str, resource))) + return ACTION_MSG_DELETE.format(*tuple(map(str, resource))) def _subscribe(subscription : Tuple[str, float, float]): return ACTION_MSG_SUBSCRIBE.format(*tuple(map(str, subscription))) -- GitLab From 41a1b30d6ff21c8e328a8f9bd672eb60f5ad3f2d Mon Sep 17 00:00:00 2001 From: armingol Date: Fri, 23 Dec 2022 12:29:50 +0100 Subject: [PATCH 08/19] Correct name of commit oer rule variables --- src/device/service/drivers/openconfig/OpenConfigDriver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index d45ea48c4..442ff5d90 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -66,7 +66,7 @@ class NetconfSessionHandler: self.__look_for_keys = settings.get('look_for_keys', True) self.__allow_agent = settings.get('allow_agent', True) self.__force_running = settings.get('force_running', False) - self.__commit_per_delete = settings.get('delete_rule', False) + self.__commit_per_rule = settings.get('commit_rule', False) self.__device_params = settings.get('device_params', {}) self.__manager_params = settings.get('manager_params', {}) self.__nc_params = settings.get('nc_params', {}) @@ -92,7 +92,7 @@ class NetconfSessionHandler: def use_candidate(self): return self.__candidate_supported and not self.__force_running @property - def commit_per_rule(self): return self.__commit_per_delete + def commit_per_rule(self): return self.__commit_per_rule @property def vendor(self): return self.__vendor -- GitLab From 5654a8758f4b1b7c6bc077caa0477cff2e4dd92e Mon Sep 17 00:00:00 2001 From: armingol Date: Fri, 23 Dec 2022 12:30:46 +0100 Subject: [PATCH 09/19] Correct L3VPN templates --- .../drivers/openconfig/templates/interface/edit_config.xml | 1 + .../templates/network_instance/interface/edit_config.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/device/service/drivers/openconfig/templates/interface/edit_config.xml b/src/device/service/drivers/openconfig/templates/interface/edit_config.xml index 4bc53ff1d..220f062b5 100644 --- a/src/device/service/drivers/openconfig/templates/interface/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/interface/edit_config.xml @@ -4,6 +4,7 @@ {% if operation is defined and operation != 'delete' %} {{name}} + ianaift:{{type}} {{mtu}} diff --git a/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml b/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml index bf8c0c077..855f321b4 100644 --- a/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml +++ b/src/device/service/drivers/openconfig/templates/network_instance/interface/edit_config.xml @@ -2,7 +2,7 @@ {{name}} - + {{id}} {{id}} -- GitLab From bb5907a1cb3df00f8b9b5114b42e087cd85e2159 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Fri, 23 Dec 2022 12:19:51 +0000 Subject: [PATCH 10/19] Device component: - fixes to collect performance evalaution values - structural architectures in openconfig driver --- .../service/DeviceServiceServicerImpl.py | 6 ++-- .../drivers/openconfig/OpenConfigDriver.py | 28 +++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/device/service/DeviceServiceServicerImpl.py b/src/device/service/DeviceServiceServicerImpl.py index 88f49de6f..b6b053df3 100644 --- a/src/device/service/DeviceServiceServicerImpl.py +++ b/src/device/service/DeviceServiceServicerImpl.py @@ -214,12 +214,12 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): driver : _Driver = self.driver_instance_cache.get(device_uuid) if driver is None: errors.append('Device({:s}) has not been added to this Device instance'.format(str(device_uuid))) - - if len(errors) == 0: + else: + #if len(errors) == 0: results_setconfig = driver.SetConfig(resources_to_set) errors.extend(check_set_errors(resources_to_set, results_setconfig)) - if len(errors) == 0: + #if len(errors) == 0: results_deleteconfig = driver.DeleteConfig(resources_to_delete) errors.extend(check_delete_errors(resources_to_delete, results_deleteconfig)) diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index d45ea48c4..305814e05 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -222,6 +222,14 @@ def edit_config( msg = '[{:s}] Exception {:s} {:s}: {:s}' logger.exception(msg.format(str_method, str_operation, str_resource_name, str(resource))) results[i] = e # if validation fails, store the exception + + if not commit_per_rule: + try: + netconf_handler.commit() + except Exception as e: # pylint: disable=broad-except + msg = '[{:s}] Exception committing: {:s}' + logger.exception(msg.format(str_method, str_operation, str(resources))) + results = [e for _ in resources] # if commit fails, set exception in each resource return results HISTOGRAM_BUCKETS = ( @@ -315,17 +323,9 @@ class OpenConfigDriver(_Driver): with self.__lock: if self.__netconf_handler.use_candidate: with self.__netconf_handler.locked(target='candidate'): - commit_per_rule = bool(self.__netconf_handler.commit_per_rule) results = edit_config( self.__netconf_handler, self.__logger, resources, target='candidate', - commit_per_rule=commit_per_rule) - if not commit_per_rule: - try: - self.__netconf_handler.commit() - except Exception as e: # pylint: disable=broad-except - MSG = '[SetConfig] Exception commiting resources: {:s}' - self.__logger.exception(MSG.format(str(resources))) - results = [e for _ in resources] # if commit fails, set exception in each resource + commit_per_rule=self.__netconf_handler.commit_per_rule) else: results = edit_config(self.__netconf_handler, self.__logger, resources) return results @@ -337,17 +337,9 @@ class OpenConfigDriver(_Driver): with self.__lock: if self.__netconf_handler.use_candidate: with self.__netconf_handler.locked(target='candidate'): - commit_per_rule = bool(self.__netconf_handler.commit_per_rule) results = edit_config( self.__netconf_handler, self.__logger, resources, target='candidate', delete=True, - commit_per_rule=commit_per_rule) - if not commit_per_rule: - try: - self.__netconf_handler.commit() - except Exception as e: # pylint: disable=broad-except - MSG = '[DeleteConfig] Exception commiting resources: {:s}' - self.__logger.exception(MSG.format(str(resources))) - results = [e for _ in resources] # if commit fails, set exception in each resource + commit_per_rule=self.__netconf_handler.commit_per_rule) else: results = edit_config(self.__netconf_handler, self.__logger, resources, delete=True) return results -- GitLab From 3a2cbc91a3ce8cbef669cbd7f255003d4d2c32e7 Mon Sep 17 00:00:00 2001 From: armingol Date: Mon, 9 Jan 2023 15:20:57 +0100 Subject: [PATCH 11/19] L3NM OpenConfig changes --- .../l3nm_openconfig/ConfigRules.py | 123 +++++++++++++----- src/tests/tools/load_gen/RequestGenerator.py | 10 +- 2 files changed, 97 insertions(+), 36 deletions(-) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 40f9d46ea..7e437276b 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -35,10 +35,8 @@ def setup_config_rules( mtu = 3000 # 1512 #address_families = json_settings.get('address_families', [] ) # ['IPV4'] bgp_as = json_settings.get('bgp_as', 65000 ) # 65000 - bgp_route_target = json_settings.get('bgp_route_target', '65000:123') # 65000:333 - + route_distinguisher = json_settings.get('route_distinguisher', '0:0' ) # '60001:801' router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' - route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 @@ -48,6 +46,7 @@ def setup_config_rules( if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) json_config_rules = [ + #Create network instance json_config_rule_set( '/network_instance[{:s}]'.format(network_instance_name), { 'name': network_instance_name, @@ -55,6 +54,7 @@ def setup_config_rules( 'type': 'L3VRF', 'route_distinguisher': route_distinguisher, }), + #Add BGP protocol to network instance json_config_rule_set( '/network_instance[{:s}]/protocols[BGP]'.format(network_instance_name), { 'name': network_instance_name, @@ -63,12 +63,14 @@ def setup_config_rules( 'as': bgp_as, 'router_id': router_id, }), - json_config_rule_set( + #Add DIRECTLY CONNECTED protocol to network instance + json_config_rule_set( '/network_instance[{:s}]/protocols[DIRECTLY_CONNECTED]'.format(network_instance_name), { 'name': network_instance_name, 'identifier': 'DIRECTLY_CONNECTED', 'protocol_name': 'DIRECTLY_CONNECTED', }), + #Create interface with subinterface json_config_rule_set( '/interface[{:s}]/subinterface[0]'.format(if_subif_name), { 'name': if_subif_name, @@ -80,6 +82,7 @@ def setup_config_rules( 'address_ip': address_ip, 'address_prefix': address_prefix, }), + #Associate interface to network instance json_config_rule_set( '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { 'name': network_instance_name, @@ -87,6 +90,49 @@ def setup_config_rules( 'interface': if_subif_name, 'subinterface': 0, }), + #Create routing policy + json_config_rule_set('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( + policy_import,route_distinguisher),{ + 'ext_community_set_name': 'set_{:s}'.format(policy_import), + 'ext_community_member' : route_distinguisher, + }), + json_config_rule_set( + '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format( + policy_import, policy_import),{ + 'policy_name' : policy_import, + 'statement_name' : 'stm_{:s}'.format(policy_import), + 'ext_community_set_name': 'set_{:s}'.format(policy_import), + 'policy_result' : 'ACCEPT_ROUTE', + }), + #Associate routing policy to network instance + json_config_rule_set( + '/network_instance[{:s}]/inter_instance_policies[{:s}]'.format( + network_instance_name, policy_import),{ + 'name' : network_instance_name, + 'import_policy': policy_import, + }), + #Create routing policy + json_config_rule_set('/routing_policy/bgp_defined_set[{:s}_rt_export][{:s}]'.format( + policy_export,route_distinguisher),{ + 'ext_community_set_name': 'set_{:s}'.format(policy_export), + 'ext_community_member' : route_distinguisher, + }), + json_config_rule_set( + '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format( + policy_export, policy_export),{ + 'policy_name' : policy_export, + 'statement_name' : 'stm_{:s}'.format(policy_export), + 'ext_community_set_name': 'set_{:s}'.format(policy_export), + 'policy_result' : 'ACCEPT_ROUTE', + }), + #Associate routing policy to network instance + json_config_rule_set( + '/network_instance[{:s}]/inter_instance_policies[{:s}]'.format( + network_instance_name, policy_export),{ + 'name' : network_instance_name, + 'export_policy': policy_export, + }), + #Create table connections json_config_rule_set( '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format( network_instance_name), { @@ -110,41 +156,58 @@ def teardown_config_rules( service_short_uuid = service_uuid.split('-')[-1] network_instance_name = '{:s}-NetInst'.format(service_short_uuid) + route_distinguisher = json_settings.get('route_distinguisher', '0:0' ) # '60001:801' + vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 + policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 + policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 + if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) #network_interface_desc = '{:s}-NetIf'.format(service_uuid) #network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid) - - #mtu = json_settings.get('mtu', 3000 ) # 1512 + #mtu = 3000 # 1512 #address_families = json_settings.get('address_families', [] ) # ['IPV4'] #bgp_as = json_settings.get('bgp_as', 65000 ) # 65000 - bgp_route_target = json_settings.get('bgp_route_target', '65000:123') # 65000:333 - #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' - #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 - policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 - policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 - - if_subif_name = '{:s}.{:d}'.format(endpoint_uuid, vlan_id) - json_config_rules = [ - # json_config_rule_delete( - # '/network_instance[{:s}]/interface[{:s}]'.format(network_instance_name, if_subif_name), { - # 'name': network_instance_name, - # 'id': if_subif_name, - # 'interface': if_subif_name, - # 'subinterface': 0, - # }), - json_config_rule_delete( - '/interface[{:s}]'.format(if_subif_name), { - 'name': if_subif_name, + #Delete table connections + json_config_rule_delete( + '/network_instance[{:s}]/table_connections[DIRECTLY_CONNECTED][BGP][IPV4]'.format(network_instance_name),{ + 'name' : network_instance_name, + 'src_protocol' : 'DIRECTLY_CONNECTED', + 'dst_protocol' : 'BGP', + 'address_family': 'IPV4', + }), + #Delete routing policy + json_config_rule_delete( + '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format( + policy_export, policy_export),{ + 'policy_name' : policy_export, + }), + json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_export][{:s}]'.format( + policy_export,route_distinguisher),{ + 'ext_community_set_name': 'set_{:s}'.format(policy_export), + }), + #Delete routing policy + json_config_rule_delete( + '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format( + policy_import, policy_import),{ + 'policy_name' : policy_import, + }), + json_config_rule_delete('/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format( + policy_import,route_distinguisher),{ + 'ext_community_set_name': 'set_{:s}'.format(policy_import), }), - # json_config_rule_delete( - # '/network_instance[{:s}]'.format(network_instance_name), { - # 'name': network_instance_name - # }), - + #Delete interface + json_config_rule_delete('/interface[{:s}]'.format(if_subif_name), + { + 'name': if_subif_name, + }), + #Delete network instance + json_config_rule_delete('/network_instance[{:s}]'.format(network_instance_name), + { + 'name': network_instance_name + }), ] return json_config_rules diff --git a/src/tests/tools/load_gen/RequestGenerator.py b/src/tests/tools/load_gen/RequestGenerator.py index 79261bcfc..8f900d935 100644 --- a/src/tests/tools/load_gen/RequestGenerator.py +++ b/src/tests/tools/load_gen/RequestGenerator.py @@ -268,7 +268,6 @@ class RequestGenerator: vlan_id = num_request % 100 +100 x= num_request % 255 y= num_request % 25 * num_request % 10 - bgp_route_target = '{:5d}:{:03d}'.format(bgp_as, vlan_id) route_distinguisher = '{:5d}:{:03d}'.format(bgp_as, vlan_id) src_router_id = ROUTER_ID.get(src_device_uuid) src_router_num = int(src_device_uuid.replace('R', '')) @@ -278,17 +277,17 @@ class RequestGenerator: if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) src_address_ip = '10.{:d}.{:d}.{:d}'.format(x,y,int(src_device_uuid.replace('R', ''))) dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y,x,int(dst_device_uuid.replace('R', ''))) - policy_R1 = vlan_id = num_request % 100 - policy_R2 = vlan_id = num_request % 100 +1 + policy_R1 = 'srv_{:d}_a'.format(vlan_id) + policy_R2 = 'srv_{:d}_b'.format(vlan_id) config_rules = [ json_config_rule_set('/settings', { 'bgp_as' : bgp_as, - 'bgp_route_target': bgp_route_target, + 'route_distinguisher': route_distinguisher, + }), json_config_rule_set('/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_uuid, src_endpoint_uuid), { 'router_id' : src_router_id, - 'route_distinguisher': route_distinguisher, 'vlan_id' : vlan_id, 'address_ip' : src_address_ip, 'address_prefix' : 16, @@ -298,7 +297,6 @@ class RequestGenerator: }), json_config_rule_set('/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_uuid, dst_endpoint_uuid), { 'router_id' : dst_router_id, - 'route_distinguisher': route_distinguisher, 'vlan_id' : vlan_id, 'address_ip' : dst_address_ip, 'address_prefix' : 16, -- GitLab From 140f654f91f414c5323a022f8ff660654cd8cc09 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Wed, 8 Feb 2023 13:10:38 +0000 Subject: [PATCH 12/19] Manifests: - enabled DEBUG logging for device and service --- manifests/deviceservice.yaml | 2 +- manifests/serviceservice.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/deviceservice.yaml b/manifests/deviceservice.yaml index ca2c81f0f..ddcc997cd 100644 --- a/manifests/deviceservice.yaml +++ b/manifests/deviceservice.yaml @@ -36,7 +36,7 @@ spec: - containerPort: 9192 env: - name: LOG_LEVEL - value: "INFO" + value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] diff --git a/manifests/serviceservice.yaml b/manifests/serviceservice.yaml index 3fa4a6e0d..801c06f52 100644 --- a/manifests/serviceservice.yaml +++ b/manifests/serviceservice.yaml @@ -36,7 +36,7 @@ spec: - containerPort: 9192 env: - name: LOG_LEVEL - value: "INFO" + value: "DEBUG" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:3030"] -- GitLab From e7e34ba20713db3f44bcfb006752819fb406e09e Mon Sep 17 00:00:00 2001 From: armingol Date: Wed, 8 Feb 2023 19:03:42 +0100 Subject: [PATCH 13/19] TODO tested --- .../l3nm_openconfig/ConfigRules.py | 76 ++++++++----------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 0309c17d7..2e6224a67 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -82,14 +82,14 @@ def setup_config_rules( 'protocol_name': 'DIRECTLY_CONNECTED', }), - # TODO: TO BE TESTED (TID) - ##Add STATIC protocol to network instance - #json_config_rule_set( - # '/network_instance[{:s}]/protocols[STATIC]'.format(network_instance_name), { - # 'name': network_instance_name, - # 'identifier': 'STATIC', - # 'protocol_name': 'STATIC', - #}), + + #Add STATIC protocol to network instance + json_config_rule_set( + '/network_instance[{:s}]/protocols[STATIC]'.format(network_instance_name), { + 'name': network_instance_name, + 'identifier': 'STATIC', + 'protocol_name': 'STATIC', + }), #Create interface with subinterface json_config_rule_set( @@ -167,15 +167,14 @@ def setup_config_rules( 'default_import_policy': 'ACCEPT_ROUTE', }), - # TODO: TO BE TESTED (TID) - #json_config_rule_set( - # '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { - # 'name' : network_instance_name, - # 'src_protocol' : 'STATIC', - # 'dst_protocol' : 'BGP', - # 'address_family' : 'IPV4', - # 'default_import_policy': 'ACCEPT_ROUTE', - #}), + json_config_rule_set( + '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { + 'name' : network_instance_name, + 'src_protocol' : 'STATIC', + 'dst_protocol' : 'BGP', + 'address_family' : 'IPV4', + 'default_import_policy': 'ACCEPT_ROUTE', + }), ] return json_config_rules @@ -220,51 +219,36 @@ def teardown_config_rules( 'address_family': 'IPV4', }), - # TODO: TO BE TESTED (TID) - #json_config_rule_delete( - # '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { - # 'name' : network_instance_name, - # 'src_protocol' : 'STATIC', - # 'dst_protocol' : 'BGP', - # 'address_family': 'IPV4', - #}), + + json_config_rule_delete( + '/network_instance[{:s}]/table_connections[STATIC][BGP][IPV4]'.format(network_instance_name), { + 'name' : network_instance_name, + 'src_protocol' : 'STATIC', + 'dst_protocol' : 'BGP', + 'address_family': 'IPV4', + }), #Delete export routing policy + json_config_rule_delete( - # pylint: disable=duplicate-string-formatting-argument - '/routing_policy/policy_definition[{:s}_export]/statement[{:s}]'.format(policy_export, policy_export), { - 'policy_name': policy_export, + '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), { + 'policy_name': '{:s}_export'.format(network_instance_name), }), - # TODO: TO BE TESTED IF IT IS ENOUGH ERASING "/routing_policy/policy_definition[{:s}_export]" - #json_config_rule_delete( - # '/routing_policy/policy_definition[{:s}_export]'.format(network_instance_name), { - # 'policy_name': '{:s}_export'.format(network_instance_name), - #}), json_config_rule_delete( '/routing_policy/bgp_defined_set[{:s}_rt_export][{:s}]'.format(policy_export, route_distinguisher), { 'ext_community_set_name': 'set_{:s}'.format(policy_export), }), #Delete import routing policy + json_config_rule_delete( - # pylint: disable=duplicate-string-formatting-argument - '/routing_policy/policy_definition[{:s}_import]/statement[{:s}]'.format(policy_import, policy_import), { - 'policy_name': policy_import, + '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), { + 'policy_name': '{:s}_import'.format(network_instance_name), }), - # TODO: TO BE TESTED IF IT IS ENOUGH ERASING "/routing_policy/policy_definition[{:s}_import]" - #json_config_rule_delete( - # '/routing_policy/policy_definition[{:s}_import]'.format(network_instance_name), { - # 'policy_name': '{:s}_import'.format(network_instance_name), - #}), json_config_rule_delete( '/routing_policy/bgp_defined_set[{:s}_rt_import][{:s}]'.format(policy_import, route_distinguisher), { 'ext_community_set_name': 'set_{:s}'.format(policy_import), }), - # TODO: TO BE TESTED IF IT IS NEEDED - #json_config_rule_delete( - # '/routing_policy/bgp_defined_set[{:s}_rt_import]'.format(network_instance_name), { - # 'ext_community_set_name': '{:s}_rt_import'.format(network_instance_name), - #}), #Delete interface; automatically deletes: # - /interface[]/subinterface[] -- GitLab From e4479517867a94798a0dc37e093b927822debf7e Mon Sep 17 00:00:00 2001 From: armingol Date: Fri, 10 Feb 2023 09:46:42 +0100 Subject: [PATCH 14/19] TODO L2 rueles --- .../load_gen/RequestGenerator.py | 23 +++++++------------ .../l2nm_openconfig/ConfigRules.py | 5 ++-- .../l3nm_openconfig/ConfigRules.py | 4 ++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/load_generator/load_gen/RequestGenerator.py b/src/load_generator/load_gen/RequestGenerator.py index a98d957a0..56fbf721c 100644 --- a/src/load_generator/load_gen/RequestGenerator.py +++ b/src/load_generator/load_gen/RequestGenerator.py @@ -245,26 +245,20 @@ class RequestGenerator: dst_device_name = self._device_data[dst_device_uuid]['name'] dst_router_id = ROUTER_ID.get(dst_device_name, '10.0.0.{:d}'.format(int(dst_device_name.replace('R', '')))) - # TODO: Check if it is needed (TID) - remote = VIRTUAL_CIRCUIT.get(src_device_uuid) - config_rules = [ json_config_rule_set('/settings', { 'mtu': 1512 }), json_config_rule_set( '/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_name, src_endpoint_name), { - 'router_id': src_router_id, - 'sub_interface_index': vlan_id, + 'sub_interface_index': 0, 'vlan_id': vlan_id, 'remote_router': dst_router_id, 'circuit_id': circuit_id, - 'remote': remote, }), json_config_rule_set( '/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_name, dst_endpoint_name), { - 'router_id': dst_router_id, - 'sub_interface_index': vlan_id, + 'sub_interface_index': 0, 'vlan_id': vlan_id, 'remote_router': src_router_id, 'circuit_id': circuit_id, @@ -300,9 +294,8 @@ class RequestGenerator: if dst_router_id is None: dst_router_id = '10.0.0.{:d}'.format(dst_router_num) dst_address_ip = '10.{:d}.{:d}.{:d}'.format(y, x, dst_router_num) - # TODO: RENAME TO POLICY AZ Y ZA (name of variable and name of policy) - policy_R1 = 'srv_{:d}_a'.format(vlan_id) - policy_R2 = 'srv_{:d}_b'.format(vlan_id) + policy_AZ = 'srv_{:d}_a'.format(vlan_id) + policy_ZA = 'srv_{:d}_b'.format(vlan_id) config_rules = [ json_config_rule_set('/settings', { @@ -318,8 +311,8 @@ class RequestGenerator: 'vlan_id' : vlan_id, 'address_ip' : src_address_ip, 'address_prefix' : 16, - 'policy_1' : policy_R1, - 'policy_2' : policy_R2, + 'policy_AZ' : policy_AZ, + 'policy_ZA' : policy_ZA, }), json_config_rule_set( '/device[{:s}]/endpoint[{:s}]/settings'.format(dst_device_name, dst_endpoint_name), { @@ -329,8 +322,8 @@ class RequestGenerator: 'vlan_id' : vlan_id, 'address_ip' : dst_address_ip, 'address_prefix' : 16, - 'policy_1' : policy_R2, - 'policy_2' : policy_R1, + 'policy_AZ' : policy_AZ, + 'policy_ZA' : policy_ZA, }), ] return json_service_l3nm_planned( diff --git a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py index fffa0fdfc..bbd91df93 100644 --- a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py @@ -37,12 +37,13 @@ def setup_config_rules( #router_id = json_endpoint_settings.get('router_id', '0.0.0.0') # '10.95.0.10' #route_distinguisher = json_endpoint_settings.get('route_distinguisher', '0:0' ) # '60001:801' - #sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 + sub_interface_index = json_endpoint_settings.get('sub_interface_index', 0 ) # 1 vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 remote_router = json_endpoint_settings.get('remote_router', '5.5.5.5') # '5.5.5.5' circuit_id = json_endpoint_settings.get('circuit_id', '111' ) # '111' + if_cirid_name = '{:s}.{:s}'.format(endpoint_name, str(circuit_id)) network_instance_name = 'ELAN-AC:{:s}'.format(str(circuit_id)) @@ -59,7 +60,7 @@ def setup_config_rules( '/interface[{:s}]/subinterface[0]'.format(if_cirid_name), {'name': if_cirid_name, 'type': 'l2vlan', - 'index': 0, + 'index': sub_interface_index, 'vlan_id': vlan_id}), json_config_rule_set( diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 2e6224a67..8862ac8dc 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -41,8 +41,8 @@ def setup_config_rules( vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 - policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 - policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 + policy_import = json_endpoint_settings.get('policy_AZ', '2' ) # 2 + policy_export = json_endpoint_settings.get('policy_ZA', '7' ) # 30 if_subif_name = '{:s}.{:d}'.format(endpoint_name, vlan_id) -- GitLab From 4e76efa63443cfabc7f336992e233c336c72963a Mon Sep 17 00:00:00 2001 From: armingol Date: Wed, 22 Feb 2023 14:59:47 +0100 Subject: [PATCH 15/19] L3VPN policies --- .../service/service_handlers/l3nm_openconfig/ConfigRules.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py index 8862ac8dc..351efe5a5 100644 --- a/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py +++ b/src/service/service/service_handlers/l3nm_openconfig/ConfigRules.py @@ -204,8 +204,8 @@ def teardown_config_rules( vlan_id = json_endpoint_settings.get('vlan_id', 1 ) # 400 #address_ip = json_endpoint_settings.get('address_ip', '0.0.0.0') # '2.2.2.1' #address_prefix = json_endpoint_settings.get('address_prefix', 24 ) # 30 - policy_import = json_endpoint_settings.get('policy_1', '2' ) # 2 - policy_export = json_endpoint_settings.get('policy_2', '7' ) # 30 + policy_import = json_endpoint_settings.get('policy_AZ', '2' ) # 2 + policy_export = json_endpoint_settings.get('policy_ZA', '7' ) # 30 if_subif_name = '{:s}.{:d}'.format(endpoint_name, vlan_id) -- GitLab From d73844d2d7455328f51b8c309ae632820b4c120d Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Thu, 23 Feb 2023 15:30:40 +0000 Subject: [PATCH 16/19] Pre-merge cleanup: - Reduced log levels to INFO - Generalized paths - Minor code and comment cleanup --- manifests/deviceservice.yaml | 2 +- manifests/serviceservice.yaml | 2 +- scripts/run_tests_locally-device-openconfig.sh | 2 +- src/load_generator/command/__main__.py | 6 +++--- src/load_generator/load_gen/RequestGenerator.py | 1 - 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/manifests/deviceservice.yaml b/manifests/deviceservice.yaml index ddcc997cd..ca2c81f0f 100644 --- a/manifests/deviceservice.yaml +++ b/manifests/deviceservice.yaml @@ -36,7 +36,7 @@ spec: - containerPort: 9192 env: - name: LOG_LEVEL - value: "DEBUG" + value: "INFO" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:2020"] diff --git a/manifests/serviceservice.yaml b/manifests/serviceservice.yaml index 801c06f52..3fa4a6e0d 100644 --- a/manifests/serviceservice.yaml +++ b/manifests/serviceservice.yaml @@ -36,7 +36,7 @@ spec: - containerPort: 9192 env: - name: LOG_LEVEL - value: "DEBUG" + value: "INFO" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:3030"] diff --git a/scripts/run_tests_locally-device-openconfig.sh b/scripts/run_tests_locally-device-openconfig.sh index b0a6f946f..06a8c8e10 100755 --- a/scripts/run_tests_locally-device-openconfig.sh +++ b/scripts/run_tests_locally-device-openconfig.sh @@ -14,7 +14,7 @@ # limitations under the License. -PROJECTDIR=/home/ubuntu/controller/ +PROJECTDIR=`pwd` cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc diff --git a/src/load_generator/command/__main__.py b/src/load_generator/command/__main__.py index 5db77fb54..2281767b1 100644 --- a/src/load_generator/command/__main__.py +++ b/src/load_generator/command/__main__.py @@ -31,9 +31,9 @@ def main(): RequestType.SERVICE_L3NM, #RequestType.SERVICE_MW, #RequestType.SERVICE_TAPI, - #RequestType.SLICE_L2NM, - #RequestType.SLICE_L3NM, - ], + RequestType.SLICE_L2NM, + RequestType.SLICE_L3NM, + ], offered_load = 10, holding_time = 10, dry_mode = False, # in dry mode, no request is sent to TeraFlowSDN diff --git a/src/load_generator/load_gen/RequestGenerator.py b/src/load_generator/load_gen/RequestGenerator.py index 0922ae5e0..7e0acbe76 100644 --- a/src/load_generator/load_gen/RequestGenerator.py +++ b/src/load_generator/load_gen/RequestGenerator.py @@ -322,7 +322,6 @@ class RequestGenerator: json_config_rule_set('/settings', { 'bgp_as' : bgp_as, 'route_distinguisher': route_distinguisher, - }), json_config_rule_set( '/device[{:s}]/endpoint[{:s}]/settings'.format(src_device_name, src_endpoint_name), { -- GitLab From d3e89f37d18145d8e1503151a60edce630932a37 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Thu, 23 Feb 2023 15:35:30 +0000 Subject: [PATCH 17/19] Pre-merge cleanup: - Updated Netconf/OpenConfig descriptor files - Normalized variable names in OpenConfigDriver - Minor code cleanup --- hackfest/tfs-descriptors/device-all.json | 8 +++--- .../device-netconf-openconfig.json | 2 +- hackfest/tfs-descriptors/old/device.json | 6 ++--- .../drivers/openconfig/OpenConfigDriver.py | 26 +++++++++---------- .../tests/Device_OpenConfig_Template.py | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/hackfest/tfs-descriptors/device-all.json b/hackfest/tfs-descriptors/device-all.json index 8cb8e0314..36a93fe98 100644 --- a/hackfest/tfs-descriptors/device-all.json +++ b/hackfest/tfs-descriptors/device-all.json @@ -9,7 +9,7 @@ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { "username": "admin", "password": "admin", "force_running": false, "hostkey_verify": false, "look_for_keys": false, - "allow_agent": false, "delete_rule": true, "device_params": {"name": "default"}, + "allow_agent": false, "commit_per_rule": true, "device_params": {"name": "default"}, "manager_params": {"timeout" : 120} }}} ]}, @@ -26,7 +26,7 @@ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { "username": "admin", "password": "admin", "force_running": false, "hostkey_verify": false, "look_for_keys": false, - "allow_agent": false, "delete_rule": true, "device_params": {"name": "default"}, + "allow_agent": false, "commit_per_rule": true, "device_params": {"name": "default"}, "manager_params": {"timeout" : 120} }}} ]}, @@ -43,7 +43,7 @@ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { "username": "admin", "password": "admin", "force_running": false, "hostkey_verify": false, "look_for_keys": false, - "allow_agent": false, "delete_rule": true, "device_params": {"name": "default"}, + "allow_agent": false, "commit_per_rule": true, "device_params": {"name": "default"}, "manager_params": {"timeout" : 120} }}} ]}, @@ -60,7 +60,7 @@ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { "username": "admin", "password": "admin", "force_running": false, "hostkey_verify": false, "look_for_keys": false, - "allow_agent": false, "delete_rule": true, "device_params": {"name": "default"}, + "allow_agent": false, "commit_per_rule": true, "device_params": {"name": "default"}, "manager_params": {"timeout" : 120} }}} ]}, diff --git a/hackfest/tfs-descriptors/device-netconf-openconfig.json b/hackfest/tfs-descriptors/device-netconf-openconfig.json index 7e01f037e..490e36efd 100644 --- a/hackfest/tfs-descriptors/device-netconf-openconfig.json +++ b/hackfest/tfs-descriptors/device-netconf-openconfig.json @@ -9,7 +9,7 @@ {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": { "username": "admin", "password": "admin", "force_running": false, "hostkey_verify": false, "look_for_keys": false, - "allow_agent": false, "delete_rule": true, "device_params": {"name": "default"}, + "allow_agent": false, "commit_per_rule": true, "device_params": {"name": "default"}, "manager_params": {"timeout" : 15} }}} ]}, diff --git a/hackfest/tfs-descriptors/old/device.json b/hackfest/tfs-descriptors/old/device.json index 03736314d..abe529e72 100644 --- a/hackfest/tfs-descriptors/old/device.json +++ b/hackfest/tfs-descriptors/old/device.json @@ -27,7 +27,7 @@ "device_config": {"config_rules": [ {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.0.2.15"}}, {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8301"}}, - {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"delete_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} + {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"commit_per_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} ]}, "device_operational_status": 1, "device_drivers": [1], @@ -39,7 +39,7 @@ "device_config": {"config_rules": [ {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.0.2.15"}}, {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8302"}}, - {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"delete_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} + {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"commit_per_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} ]}, "device_operational_status": 1, "device_drivers": [1], @@ -51,7 +51,7 @@ "device_config": {"config_rules": [ {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "10.0.2.15"}}, {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8303"}}, - {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"delete_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} + {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": "{\"username\": \"admin\", \"password\": \"admin\", \"force_running\": true, \"hostkey_verify\": false, \"look_for_keys\": false, \"allow_agent\": true, \"commit_per_rule\": false, \"device_params\" : {\"name\": \"default\"}, \"manager_params\" : {\"timeout\": 15}}"}} ]}, "device_operational_status": 1, "device_drivers": [1], diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index bce977dc9..c633fb1a5 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -58,18 +58,18 @@ class NetconfSessionHandler: self.__connected = threading.Event() self.__address = address self.__port = int(port) - self.__username = settings.get('username') - self.__password = settings.get('password') - self.__vendor = settings.get('vendor') - self.__key_filename = settings.get('key_filename') - self.__hostkey_verify = settings.get('hostkey_verify', True) - self.__look_for_keys = settings.get('look_for_keys', True) - self.__allow_agent = settings.get('allow_agent', True) - self.__force_running = settings.get('force_running', False) - self.__commit_per_rule = settings.get('commit_rule', False) - self.__device_params = settings.get('device_params', {}) - self.__manager_params = settings.get('manager_params', {}) - self.__nc_params = settings.get('nc_params', {}) + self.__username = settings.get('username') + self.__password = settings.get('password') + self.__vendor = settings.get('vendor') + self.__key_filename = settings.get('key_filename') + self.__hostkey_verify = settings.get('hostkey_verify', True) + self.__look_for_keys = settings.get('look_for_keys', True) + self.__allow_agent = settings.get('allow_agent', True) + self.__force_running = settings.get('force_running', False) + self.__commit_per_rule = settings.get('commit_per_rule', False) + self.__device_params = settings.get('device_params', {}) + self.__manager_params = settings.get('manager_params', {}) + self.__nc_params = settings.get('nc_params', {}) self.__manager : Manager = None self.__candidate_supported = False @@ -192,7 +192,7 @@ def do_sampling( def edit_config( netconf_handler : NetconfSessionHandler, logger : logging.Logger, resources : List[Tuple[str, Any]], delete=False, - commit_per_rule= False, target='running', default_operation='merge', test_option=None, error_option=None, + commit_per_rule=False, target='running', default_operation='merge', test_option=None, error_option=None, format='xml' # pylint: disable=redefined-builtin ): str_method = 'DeleteConfig' if delete else 'SetConfig' diff --git a/src/device/tests/Device_OpenConfig_Template.py b/src/device/tests/Device_OpenConfig_Template.py index 8ab453375..b9aae79a2 100644 --- a/src/device/tests/Device_OpenConfig_Template.py +++ b/src/device/tests/Device_OpenConfig_Template.py @@ -32,7 +32,7 @@ DEVICE_OC_CONNECT_RULES = json_device_connect_rules(DEVICE_OC_ADDRESS, DEVICE_OC 'hostkey_verify' : True, 'look_for_keys' : True, 'allow_agent' : True, - 'delete_rule' : False, + 'commit_per_rule': False, 'device_params' : {'name': 'default'}, 'manager_params' : {'timeout' : DEVICE_OC_TIMEOUT}, }) -- GitLab From 8e277f4b91d8ed13e00d1ec8e72b353da87b5d51 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Thu, 23 Feb 2023 15:39:12 +0000 Subject: [PATCH 18/19] Pre-merge cleanup: - Updated Netconf/OpenConfig log messages --- .../service/drivers/openconfig/OpenConfigDriver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py index c633fb1a5..a0c335193 100644 --- a/src/device/service/drivers/openconfig/OpenConfigDriver.py +++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py @@ -196,12 +196,12 @@ def edit_config( format='xml' # pylint: disable=redefined-builtin ): str_method = 'DeleteConfig' if delete else 'SetConfig' - logger.info('[{:s}] resources = {:s}'.format(str_method, str(resources))) + #logger.debug('[{:s}] resources = {:s}'.format(str_method, str(resources))) results = [None for _ in resources] for i,resource in enumerate(resources): str_resource_name = 'resources[#{:d}]'.format(i) try: - logger.info('[{:s}] resource = {:s}'.format(str_method, str(resource))) + #logger.debug('[{:s}] resource = {:s}'.format(str_method, str(resource))) chk_type(str_resource_name, resource, (list, tuple)) chk_length(str_resource_name, resource, min_length=2, max_length=2) resource_key,resource_value = resource @@ -209,8 +209,8 @@ def edit_config( str_config_message = compose_config( resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor) if str_config_message is None: raise UnsupportedResourceKeyException(resource_key) - logger.info('[{:s}] str_config_message[{:d}] = {:s}'.format( - str_method, len(str_config_message), str(str_config_message))) + #logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format( + # str_method, len(str_config_message), str(str_config_message))) netconf_handler.edit_config( config=str_config_message, target=target, default_operation=default_operation, test_option=test_option, error_option=error_option, format=format) @@ -305,7 +305,7 @@ class OpenConfigDriver(_Driver): try: chk_string(str_resource_name, resource_key, allow_empty=False) str_filter = get_filter(resource_key) - self.__logger.info('[GetConfig] str_filter = {:s}'.format(str(str_filter))) + #self.__logger.debug('[GetConfig] str_filter = {:s}'.format(str(str_filter))) if str_filter is None: str_filter = resource_key xml_data = self.__netconf_handler.get(filter=str_filter).data_ele if isinstance(xml_data, Exception): raise xml_data -- GitLab From 5fc285e6e44eb17ace9a4918615217e5328e001f Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Thu, 23 Feb 2023 15:44:29 +0000 Subject: [PATCH 19/19] Pre-merge cleanup: - Restored LoadGen default parameters --- src/load_generator/command/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/load_generator/command/__main__.py b/src/load_generator/command/__main__.py index 2281767b1..7504eb6da 100644 --- a/src/load_generator/command/__main__.py +++ b/src/load_generator/command/__main__.py @@ -25,7 +25,7 @@ LOGGER = logging.getLogger(__name__) def main(): LOGGER.info('Starting...') parameters = Parameters( - num_requests = 20, + num_requests = 100, request_types = [ RequestType.SERVICE_L2NM, RequestType.SERVICE_L3NM, @@ -34,7 +34,7 @@ def main(): RequestType.SLICE_L2NM, RequestType.SLICE_L3NM, ], - offered_load = 10, + offered_load = 50, holding_time = 10, dry_mode = False, # in dry mode, no request is sent to TeraFlowSDN record_to_dlt = False, # if record_to_dlt, changes in device/link/service/slice are uploaded to DLT -- GitLab