From a2a1426df06046b4ae1f65707b759bf0d6ffe949 Mon Sep 17 00:00:00 2001
From: armingol <pablo.armingolrobles@telefonica.com>
Date: Wed, 12 Jul 2023 13:24:45 +0000
Subject: [PATCH] fix l2vpn openconfig bugs

---
 .../templates/VPN/Interfaces_multivendor.py         |  2 +-
 .../service_handlers/l2nm_openconfig/ConfigRules.py | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/device/service/drivers/openconfig/templates/VPN/Interfaces_multivendor.py b/src/device/service/drivers/openconfig/templates/VPN/Interfaces_multivendor.py
index 2327b849c..d6f72ee65 100644
--- a/src/device/service/drivers/openconfig/templates/VPN/Interfaces_multivendor.py
+++ b/src/device/service/drivers/openconfig/templates/VPN/Interfaces_multivendor.py
@@ -58,7 +58,7 @@ def create_If_SubIf(data,vendor, DEL):
                             with tag('index'): text('0')
                         with tag('config'):
                             with tag('index'): text('0')
-                            if vendor == 'ADVA' and len(data['vlan_id'] == 0): 
+                            if vendor == 'ADVA' and not 'vlan_id'in data: 
                                 with tag('untagged-allowed', 'xmlns="http://www.advaoptical.com/cim/adva-dnos-oc-interfaces"'):text('true')
                         with tag('vlan',  xmlns="http://openconfig.net/yang/vlan"):
                             with tag('match'):
diff --git a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
index 69daa057f..cedb39ebf 100644
--- a/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
+++ b/src/service/service/service_handlers/l2nm_openconfig/ConfigRules.py
@@ -40,16 +40,17 @@ def setup_config_rules(
     #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'
     network_instance_name   = json_endpoint_settings.get('ni_name',             'ELAN-AC:{:s}'.format(str(vlan_id)))  #ELAN-AC:1
-    virtual_circuit_id      = json_endpoint_settings.get('vc_id',               '111'    )  # '111'
+    # virtual_circuit_id      = json_endpoint_settings.get('vc_id',               '111'    )  # '111'
     connection_point        = json_endpoint_settings.get('conn_point',          '1'       ) # '111'
     #network_interface_desc    = '{:s}-NetIf'.format(service_uuid)
     network_interface_desc    = json_endpoint_settings.get('ni_description','')
     #network_subinterface_desc = '{:s}-NetSubIf'.format(service_uuid)
     network_subinterface_desc = json_endpoint_settings.get('subif_description','')
     
-    if_cirid_name           = '{:s}.{:s}'.format(endpoint_name, vlan_id)
+    if_cirid_name           = '{:s}.{:d}'.format(endpoint_name, vlan_id)
     connection_point_id     = 'VC-{:s}'.format(str(connection_point))                   #Provisionalmente comentado, en principio se deberia usar asi
     #connection_point_id     = 'VC-1'                                                   #Uso provisional
+    virtual_circuit_id      = vlan_id
 
     json_config_rules = [
 
@@ -96,14 +97,14 @@ def teardown_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
-    #vlan_id             = json_endpoint_settings.get('vlan_id',             1        )  # 400
+    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'
+    #circuit_id          = json_endpoint_settings.get('circuit_id',          '000'    )  # '111'
 
-    if_cirid_name         = '{:s}.{:s}'.format(endpoint_name, str(circuit_id))
-    network_instance_name = 'ELAN-AC:{:s}'.format(str(circuit_id))
+    if_cirid_name         = '{:s}.{:d}'.format(endpoint_name, vlan_id)
+    network_instance_name = 'ELAN-AC:{:s}'.format(str(vlan_id))
     connection_point_id   = 'VC-1'
 
     json_config_rules = [
-- 
GitLab