From 12a9c926c0cdf0681800948f07255209d3d1092f Mon Sep 17 00:00:00 2001 From: Capirca Team Date: Tue, 6 Aug 2024 08:57:20 -0700 Subject: [PATCH] Move ACL entry transport configuration from `acl-entry//transport` to `acl-entry/transport`, to match the current canonical OpenConfig ACL entry schema. PiperOrigin-RevId: 659975442 --- capirca/lib/openconfig.py | 13 ++++++++---- tests/lib/openconfig_test.py | 40 ++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/capirca/lib/openconfig.py b/capirca/lib/openconfig.py index f8cb5740..94b8dc1a 100644 --- a/capirca/lib/openconfig.py +++ b/capirca/lib/openconfig.py @@ -144,17 +144,22 @@ def ConvertToDict(self): # 'any' starts and ends with zero. if not start == end == 0: if start == end: - ace_dict[family]['transport']['config']['source-port'] = int(start) + ace_dict['transport']['config']['source-port'] = int(start) else: - ace_dict[family]['transport']['config']['source-port'] = '%d..%d' % (start, end) + ace_dict['transport']['config']['source-port'] = '%d..%d' % ( + start, + end, + ) # Destination Port for start, end in dports: if not start == end == 0: if start == end: - ace_dict[family]['transport']['config']['destination-port'] = int(start) + ace_dict['transport']['config']['destination-port'] = int(start) else: - ace_dict[family]['transport']['config']['destination-port'] = '%d..%d' % (start, end) + ace_dict['transport']['config']['destination-port'] = ( + '%d..%d' % (start, end) + ) # Protocol for proto in protos: diff --git a/tests/lib/openconfig_test.py b/tests/lib/openconfig_test.py index 53dc4372..484e764b 100644 --- a/tests/lib/openconfig_test.py +++ b/tests/lib/openconfig_test.py @@ -231,10 +231,11 @@ "ipv4": { "config": { "protocol": 6 + } }, "transport": { "config": { - "source-port": 53} + "source-port": 53 } } } @@ -252,10 +253,11 @@ "ipv4": { "config": { "protocol": 6 + } }, "transport": { "config": { - "destination-port": 53} + "destination-port": 53 } } } @@ -273,10 +275,11 @@ "ipv4": { "config": { "protocol": 17 + } }, "transport": { "config": { - "destination-port": 53} + "destination-port": 53 } } }, @@ -289,12 +292,13 @@ "ipv4": { "config": { "protocol": 6 - }, - "transport": { - "config": { - "destination-port": 53} - } } + }, + "transport": { + "config": { + "destination-port": 53 + } + } } ] """ @@ -312,11 +316,11 @@ "destination-address": "10.2.3.4/32", "protocol": 17, "source-address": "10.2.3.4/32" - }, - "transport": { - "config": { - "destination-port": 53 - } + } + }, + "transport": { + "config": { + "destination-port": 53 } } }, @@ -331,11 +335,11 @@ "destination-address": "10.2.3.4/32", "protocol": 6, "source-address": "10.2.3.4/32" - }, - "transport": { - "config": { - "destination-port": 53 - } + } + }, + "transport": { + "config": { + "destination-port": 53 } } }