From: Gilles Thouenon Date: Wed, 10 Mar 2021 15:37:19 +0000 (+0100) Subject: Set port states in portMapping X-Git-Tag: 3.0.0~13 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=15197bf3dcde69a90f01963ffa524fbf6354555c Set port states in portMapping - set the administrative and operational states of a port in the mapping object - update functional tests accordingly JIRA: TRNSPRTPCE-415 Signed-off-by: Gilles Thouenon Change-Id: I2fd0ac50fe23275e5136577c538262d4203c300a --- diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java index 1234abae5..c3e5a744a 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java @@ -583,7 +583,12 @@ public class PortMappingVersion121 { .setSupportingCircuitPackName(circuitPackName) .setSupportingPort(port.getPortName()) .setPortDirection(port.getPortDirection().getName()); - + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } if (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN) || (port.getInterfaces() == null)) { return mpBldr.build(); } @@ -639,7 +644,12 @@ public class PortMappingVersion121 { if (partnerLcp != null) { mpBldr.setPartnerLcp(partnerLcp); } - + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } return mpBldr.build(); } diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java index cad6985d1..6bff30368 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java @@ -774,6 +774,12 @@ public class PortMappingVersion221 { .setSupportingCircuitPackName(circuitPackName) .setSupportingPort(port.getPortName()) .setPortDirection(port.getPortDirection().getName()); + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } if ((port.getInterfaces() == null) || (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN) @@ -852,6 +858,12 @@ public class PortMappingVersion221 { } mpBldr.setSupportedInterfaceCapability(supportedIntf); } + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } return mpBldr.build(); } diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java index 7a1c28106..3f1486636 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java @@ -830,6 +830,12 @@ public class PortMappingVersion710 { .setSupportingCircuitPackName(circuitPackName) .setSupportingPort(port.getPortName()) .setPortDirection(port.getPortDirection().getName()); + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } if ((port.getInterfaces() == null) || (!logicalConnectionPoint.contains(StringConstants.TTP_TOKEN) @@ -905,6 +911,12 @@ public class PortMappingVersion710 { } mpBldr.setSupportedInterfaceCapability(supportedIntf); } + if (port.getAdministrativeState() != null) { + mpBldr.setPortAdminState(port.getAdministrativeState().name()); + } + if (port.getOperationalState() != null) { + mpBldr.setPortOperState(port.getOperationalState().name()); + } return mpBldr.build(); } diff --git a/tests/transportpce_tests/1.2.1/test_portmapping.py b/tests/transportpce_tests/1.2.1/test_portmapping.py index 51694b568..5cc4c14dd 100644 --- a/tests/transportpce_tests/1.2.1/test_portmapping.py +++ b/tests/transportpce_tests/1.2.1/test_portmapping.py @@ -86,7 +86,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0', - 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_05_rdm_portmapping_SRG1_PP7_TXRX(self): @@ -95,7 +96,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0', - 'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_06_rdm_portmapping_SRG3_PP1_TXRX(self): @@ -104,7 +106,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0', - 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_07_xpdr_device_connection(self): @@ -141,7 +144,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network', - 'lcp-hash-val': 'OSvMgUyP+mE='}, + 'lcp-hash-val': 'OSvMgUyP+mE=', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_11_xpdr_portmapping_NETWORK2(self): @@ -152,7 +156,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT3', 'port-qual': 'xpdr-network', - 'lcp-hash-val': 'OSvMgUyP+mI='}, + 'lcp-hash-val': 'OSvMgUyP+mI=', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_12_xpdr_portmapping_CLIENT1(self): @@ -164,7 +169,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AO9UFkY/TLYw'}, + 'lcp-hash-val': 'AO9UFkY/TLYw', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_13_xpdr_portmapping_CLIENT2(self): @@ -176,7 +182,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/C2-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AO9UFkY/TLYz'}, + 'lcp-hash-val': 'AO9UFkY/TLYz', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_14_xpdr_portmapping_CLIENT3(self): @@ -188,7 +195,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/C3-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT3', 'connection-map-lcp': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional', - 'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLYy'}, + 'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLYy', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_15_xpdr_portmapping_CLIENT4(self): @@ -199,7 +207,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): {'supporting-port': 'C4', 'supporting-circuit-pack-name': '1/0/C4-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT4', 'port-direction': 'bidirectional', - 'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLY1'}, + 'port-qual': 'xpdr-client', 'lcp-hash-val': 'AO9UFkY/TLY1', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_16_xpdr_device_disconnection(self): diff --git a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py index b57f57874..9787e4071 100644 --- a/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/1.2.1/test_renderer_service_path_nominal.py @@ -52,11 +52,13 @@ class TransportPCERendererTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0', - 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) self.assertIn( {'supporting-port': 'C7', 'supporting-circuit-pack-name': '4/0', - 'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG1-PP7-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) def test_04_xpdr_portmapping(self): @@ -67,14 +69,16 @@ class TransportPCERendererTesting(unittest.TestCase): {'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1', 'port-qual': 'xpdr-network', - 'lcp-hash-val': 'OSvMgUyP+mE='}, + 'lcp-hash-val': 'OSvMgUyP+mE=', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '1/0/C1-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AO9UFkY/TLYw'}, + 'lcp-hash-val': 'AO9UFkY/TLYw', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) def test_05_service_path_create(self): diff --git a/tests/transportpce_tests/2.2.1/test_otn_renderer.py b/tests/transportpce_tests/2.2.1/test_otn_renderer.py index 20356b297..8c2cec49f 100644 --- a/tests/transportpce_tests/2.2.1/test_otn_renderer.py +++ b/tests/transportpce_tests/2.2.1/test_otn_renderer.py @@ -59,6 +59,8 @@ class TransportPCEtesting(unittest.TestCase): self.assertEqual('bidirectional', res_mapping['port-direction']) self.assertEqual('xpdr-client', res_mapping['port-qual']) self.assertEqual('FqlcrxV7p3g=', res_mapping['lcp-hash-val']) + self.assertEqual('InService', res_mapping['port-admin-state']) + self.assertEqual('InService', res_mapping['port-oper-state']) self.assertIn('org-openroadm-port-types:if-10GE-ODU2e', res_mapping['supported-interface-capability']) self.assertIn('org-openroadm-port-types:if-10GE-ODU2', res_mapping['supported-interface-capability']) self.assertIn('org-openroadm-port-types:if-10GE', res_mapping['supported-interface-capability']) @@ -77,8 +79,10 @@ class TransportPCEtesting(unittest.TestCase): "port-qual": "xpdr-network", "supporting-circuit-pack-name": "CP1-CFP0", "xponder-type": "mpdr", - 'lcp-hash-val': 'Swfw02qXGyI='}, - res['mapping']) + 'lcp-hash-val': 'Swfw02qXGyI=', + 'port-admin-state': 'InService', + 'port-oper-state': 'InService'}, + res['mapping']) def test_04_service_path_create_OCH_OTU4(self): response = test_utils.service_path_request("create", "service_OCH_OTU4", "1", @@ -109,7 +113,9 @@ class TransportPCEtesting(unittest.TestCase): "port-qual": "xpdr-network", "supporting-circuit-pack-name": "CP1-CFP0", "xponder-type": "mpdr", - "lcp-hash-val": "Swfw02qXGyI="}, + "lcp-hash-val": "Swfw02qXGyI=", + "port-admin-state": "InService", + "port-oper-state": "InService"}, res['mapping']) def test_06_check_interface_och(self): @@ -183,7 +189,9 @@ class TransportPCEtesting(unittest.TestCase): "supporting-circuit-pack-name": "CP1-CFP0", "xponder-type": "mpdr", "supporting-odu4": "XPDR1-NETWORK1-ODU4", - "lcp-hash-val": "Swfw02qXGyI=" + "lcp-hash-val": "Swfw02qXGyI=", + "port-admin-state": "InService", + "port-oper-state": "InService" }, res['mapping']) diff --git a/tests/transportpce_tests/2.2.1/test_portmapping.py b/tests/transportpce_tests/2.2.1/test_portmapping.py index 7692c3246..831cf0d99 100644 --- a/tests/transportpce_tests/2.2.1/test_portmapping.py +++ b/tests/transportpce_tests/2.2.1/test_portmapping.py @@ -70,7 +70,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0', - 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_05_rdm_portmapping_DEG2_TTP_TXRX_with_ots_oms(self): @@ -81,7 +82,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): {'supporting-port': 'L1', 'supporting-circuit-pack-name': '2/0', 'logical-connection-point': 'DEG2-TTP-TXRX', 'supporting-oms': 'OMS-DEG2-TTP-TXRX', 'supporting-ots': 'OTS-DEG2-TTP-TXRX', - 'port-direction': 'bidirectional'}, + 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_06_rdm_portmapping_SRG1_PP3_TXRX(self): @@ -90,7 +92,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0', - 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_07_rdm_portmapping_SRG3_PP1_TXRX(self): @@ -99,7 +102,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'C1', 'supporting-circuit-pack-name': '5/0', - 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG3-PP1-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_08_xpdr_device_connection(self): @@ -137,7 +141,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1', - 'lcp-hash-val': 'AMkDwQ7xTmRI'}, + 'lcp-hash-val': 'AMkDwQ7xTmRI', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_12_xpdr_portmapping_NETWORK2(self): @@ -149,7 +154,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/2-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK2', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT2', 'port-qual': 'xpdr-network', - 'lcp-hash-val': 'AMkDwQ7xTmRL'}, + 'lcp-hash-val': 'AMkDwQ7xTmRL', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_13_xpdr_portmapping_CLIENT1(self): @@ -162,7 +168,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AJUUr6I5fALj'}, + 'lcp-hash-val': 'AJUUr6I5fALj', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_14_xpdr_portmapping_CLIENT2(self): @@ -175,7 +182,8 @@ class TransportPCEPortMappingTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/2-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT2', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK2', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AJUUr6I5fALg'}, + 'lcp-hash-val': 'AJUUr6I5fALg', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['mapping']) def test_15_xpdr_device_disconnection(self): diff --git a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py index e1dfb0df6..432ae1294 100644 --- a/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py +++ b/tests/transportpce_tests/2.2.1/test_renderer_service_path_nominal.py @@ -48,11 +48,13 @@ class TransportPCERendererTesting(unittest.TestCase): res = response.json() self.assertIn( {'supporting-port': 'L1', 'supporting-circuit-pack-name': '1/0', - 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'DEG1-TTP-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) self.assertIn( {'supporting-port': 'C3', 'supporting-circuit-pack-name': '3/0', - 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional'}, + 'logical-connection-point': 'SRG1-PP3-TXRX', 'port-direction': 'bidirectional', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) def test_04_xpdr_portmapping(self): @@ -64,7 +66,8 @@ class TransportPCERendererTesting(unittest.TestCase): 'supporting-port': '1', 'supporting-circuit-pack-name': '1/0/1-PLUG-NET', 'logical-connection-point': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-network', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-CLIENT1', - 'lcp-hash-val': 'AMkDwQ7xTmRI'}, + 'lcp-hash-val': 'AMkDwQ7xTmRI', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) self.assertIn( {'supported-interface-capability': ['org-openroadm-port-types:if-100GE'], @@ -72,7 +75,8 @@ class TransportPCERendererTesting(unittest.TestCase): 'supporting-circuit-pack-name': '1/0/1-PLUG-CLIENT', 'logical-connection-point': 'XPDR1-CLIENT1', 'port-direction': 'bidirectional', 'connection-map-lcp': 'XPDR1-NETWORK1', 'port-qual': 'xpdr-client', - 'lcp-hash-val': 'AJUUr6I5fALj'}, + 'lcp-hash-val': 'AJUUr6I5fALj', + 'port-admin-state': 'InService', 'port-oper-state': 'InService'}, res['nodes'][0]['mapping']) def test_05_service_path_create(self):