Migrate topology func. tests to RFC8040 Step 3 50/98850/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Sun, 5 Dec 2021 19:09:47 +0000 (20:09 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Sun, 5 Dec 2021 20:14:15 +0000 (21:14 +0100)
JIRA: TRNSPRTPCE-567
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I9991ee7377581dda4dc72ee5c65db203f65ffce6

tests/transportpce_tests/1.2.1/test03_topology.py
tests/transportpce_tests/2.2.1/test03_topology.py
tests/transportpce_tests/common/test_utils_rfc8040.py

index 4a1ae5c6e87b3a0bcf19a41e395616ea69e05455..c58557b3806f1398b2b81c7ebd421f9d82ec52f2 100644 (file)
@@ -21,7 +21,6 @@ import sys
 sys.path.append('transportpce_tests/common/')
 # pylint: disable=wrong-import-position
 # pylint: disable=import-error
-import test_utils  # nopep8
 import test_utils_rfc8040  # nopep8
 
 
@@ -254,14 +253,16 @@ class TransportPCETopologyTesting(unittest.TestCase):
     # Connect the tail XPDRA to ROADMA and vice versa
     def test_10_connect_tail_xpdr_rdm(self):
         # Connect the tail: XPDRA to ROADMA
-        response = test_utils.connect_xpdr_to_rdm_request("XPDRA01", "1", "1",
-                                                          "ROADMA01", "1", "SRG1-PP1-TXRX")
+        response = test_utils_rfc8040.connect_xpdr_to_rdm_request(
+            {'xpdr-node': 'XPDRA01', 'xpdr-num': '1', 'network-num': '1',
+             'rdm-node': 'ROADMA01', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'})
         self.assertEqual(response.status_code, requests.codes.ok)
 
     def test_11_connect_tail_rdm_xpdr(self):
         # Connect the tail: ROADMA to XPDRA
-        response = test_utils.connect_rdm_to_xpdr_request("XPDRA01", "1", "1",
-                                                          "ROADMA01", "1", "SRG1-PP1-TXRX")
+        response = test_utils_rfc8040.connect_rdm_to_xpdr_request(
+            {'xpdr-node': 'XPDRA01', 'xpdr-num': '1', 'network-num': '1',
+             'rdm-node': 'ROADMA01', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'})
         self.assertEqual(response.status_code, requests.codes.ok)
 
     def test_12_getLinks_OpenRoadmTopology(self):
index ef721954afbfee35d2481a58445b434cd59a7340..c03f8ed30e3ff288bedde77402b6adf7551ee2bd 100644 (file)
@@ -22,7 +22,6 @@ import sys
 sys.path.append('transportpce_tests/common/')
 # pylint: disable=wrong-import-position
 # pylint: disable=import-error
-import test_utils  # nopep8
 import test_utils_rfc8040  # nopep8
 
 
@@ -256,13 +255,15 @@ class TransportPCEtesting(unittest.TestCase):
     # Connect the tail XPDRA to ROADMA and vice versa
     def test_10_connect_tail_xpdr_rdm(self):
         # Connect the tail: XPDRA to ROADMA
-        response = test_utils.connect_xpdr_to_rdm_request("XPDR-A1", "1", "1",
-                                                          "ROADM-A1", "1", "SRG1-PP1-TXRX")
+        response = test_utils_rfc8040.connect_xpdr_to_rdm_request(
+            {'xpdr-node': 'XPDR-A1', 'xpdr-num': '1', 'network-num': '1',
+             'rdm-node': 'ROADM-A1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'})
         self.assertEqual(response.status_code, requests.codes.ok)
 
     def test_11_connect_tail_rdm_xpdr(self):
-        response = test_utils.connect_rdm_to_xpdr_request("XPDR-A1", "1", "1",
-                                                          "ROADM-A1", "1", "SRG1-PP1-TXRX")
+        response = test_utils_rfc8040.connect_rdm_to_xpdr_request(
+            {'xpdr-node': 'XPDR-A1', 'xpdr-num': '1', 'network-num': '1',
+             'rdm-node': 'ROADM-A1', 'srg-num': '1', 'termination-point-num': 'SRG1-PP1-TXRX'})
         self.assertEqual(response.status_code, requests.codes.ok)
 
     def test_12_getLinks_OpenRoadmTopology(self):
index 5382058139ef42b57fdbb68bd9cdafc53d8feedb..5c88187b138c532abf4791ca0ed3c97df3eba296 100644 (file)
@@ -105,6 +105,20 @@ def delete_request(url):
         headers=TYPE_APPLICATION_JSON,
         auth=(ODL_LOGIN, ODL_PWD))
 
+
+def post_request(url, data):
+    if data:
+        print(json.dumps(data))
+        return requests.request(
+            "POST", url.format(RESTCONF_BASE_URL),
+            data=json.dumps(data),
+            headers=TYPE_APPLICATION_JSON,
+            auth=(ODL_LOGIN, ODL_PWD))
+    return requests.request(
+        "POST", url.format(RESTCONF_BASE_URL),
+        headers=TYPE_APPLICATION_JSON,
+        auth=(ODL_LOGIN, ODL_PWD))
+
 #
 # Process management
 #
@@ -441,3 +455,43 @@ def del_ietf_network_node_request(network: str, node: str, content: str):
         format_args = ('{}', 'operational', network, node)
     response = delete_request(url[RESTCONF_VERSION].format(*format_args))
     return response
+
+#
+# TransportPCE network utils operations
+#
+
+
+def connect_xpdr_to_rdm_request(payload: dict):
+    url = "{}/operations/transportpce-networkutils:init-xpdr-rdm-links"
+    payload_prefix = {'rfc8040': '', 'draft-bierman02': 'networkutils:'}
+    data = {
+        payload_prefix[RESTCONF_VERSION] + "input": {
+            payload_prefix[RESTCONF_VERSION] + "links-input": {
+                payload_prefix[RESTCONF_VERSION] + "xpdr-node": payload['xpdr-node'],
+                payload_prefix[RESTCONF_VERSION] + "xpdr-num": payload['xpdr-num'],
+                payload_prefix[RESTCONF_VERSION] + "network-num": payload['network-num'],
+                payload_prefix[RESTCONF_VERSION] + "rdm-node": payload['rdm-node'],
+                payload_prefix[RESTCONF_VERSION] + "srg-num": payload['srg-num'],
+                payload_prefix[RESTCONF_VERSION] + "termination-point-num": payload['termination-point-num']
+            }
+        }
+    }
+    return post_request(url, data)
+
+
+def connect_rdm_to_xpdr_request(payload: dict):
+    url = "{}/operations/transportpce-networkutils:init-rdm-xpdr-links"
+    payload_prefix = {'rfc8040': '', 'draft-bierman02': 'networkutils:'}
+    data = {
+        payload_prefix[RESTCONF_VERSION] + "input": {
+            payload_prefix[RESTCONF_VERSION] + "links-input": {
+                payload_prefix[RESTCONF_VERSION] + "xpdr-node": payload['xpdr-node'],
+                payload_prefix[RESTCONF_VERSION] + "xpdr-num": payload['xpdr-num'],
+                payload_prefix[RESTCONF_VERSION] + "network-num": payload['network-num'],
+                payload_prefix[RESTCONF_VERSION] + "rdm-node": payload['rdm-node'],
+                payload_prefix[RESTCONF_VERSION] + "srg-num": payload['srg-num'],
+                payload_prefix[RESTCONF_VERSION] + "termination-point-num": payload['termination-point-num']
+            }
+        }
+    }
+    return post_request(url, data)