ce6da1da515e42fa795176544f4cbee7fb67d17c
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test08_otn_sh_renderer.py
1 #!/usr/bin/env python
2
3 ##############################################################################
4 # Copyright (c) 2020 Orange, Inc. and others.  All rights reserved.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # pylint: disable=no-member
13 # pylint: disable=too-many-public-methods
14
15 import unittest
16 import time
17 import requests
18 # pylint: disable=wrong-import-order
19 import sys
20 sys.path.append('transportpce_tests/common/')
21 # pylint: disable=wrong-import-position
22 # pylint: disable=import-error
23 import test_utils_rfc8040  # nopep8
24
25
26 class TransportPCEtesting(unittest.TestCase):
27
28     processes = None
29     NODE_VERSION = '2.2.1'
30
31     @classmethod
32     def setUpClass(cls):
33         cls.processes = test_utils_rfc8040.start_tpce()
34         cls.processes = test_utils_rfc8040.start_sims([('spdra', cls.NODE_VERSION),
35                                                        ('spdrc', cls.NODE_VERSION)])
36
37     @classmethod
38     def tearDownClass(cls):
39         # pylint: disable=not-an-iterable
40         for process in cls.processes:
41             test_utils_rfc8040.shutdown_process(process)
42         print("all processes killed")
43
44     def setUp(self):
45         time.sleep(5)
46
47     def test_01_connect_SPDR_SA1(self):
48         response = test_utils_rfc8040.mount_device("SPDR-SA1", ('spdra', self.NODE_VERSION))
49         self.assertEqual(response.status_code, requests.codes.created,
50                          test_utils_rfc8040.CODE_SHOULD_BE_201)
51         time.sleep(10)
52
53         response = test_utils_rfc8040.check_device_connection("SPDR-SA1")
54         self.assertEqual(response['status_code'], requests.codes.ok)
55         self.assertEqual(response['connection-status'], 'connected')
56
57     def test_02_connect_SPDR_SC1(self):
58         response = test_utils_rfc8040.mount_device("SPDR-SC1", ('spdrc', self.NODE_VERSION))
59         self.assertEqual(response.status_code, requests.codes.created,
60                          test_utils_rfc8040.CODE_SHOULD_BE_201)
61         time.sleep(10)
62
63         response = test_utils_rfc8040.check_device_connection("SPDR-SC1")
64         self.assertEqual(response['status_code'], requests.codes.ok)
65         self.assertEqual(response['connection-status'], 'connected')
66
67     def test_03_service_create_OTU4(self):
68         response = test_utils_rfc8040.renderer_service_implementation_request(
69             {
70                 'service-name': 'SPDRA-SPDRC-OTU4-ODU4',
71                 'connection-type': 'infrastructure',
72                 'service-handler-header': {
73                     'request-id': 'abcd12-efgh34'
74                 },
75                 'service-a-end': {
76                     'service-format': 'OTU',
77                     'otu-service-rate': 'org-openroadm-otn-common-types:OTU4',
78                     'clli': 'nodeSA',
79                     'node-id': 'SPDR-SA1'
80
81                 },
82                 'service-z-end': {
83                     'service-format': 'OTU',
84                     'otu-service-rate': 'org-openroadm-otn-common-types:OTU4',
85                     'clli': 'nodeSC',
86                     'node-id': 'SPDR-SC1'
87                 },
88                 'path-description': {
89                     'aToZ-direction': {
90                         'rate': 100,
91                         'modulation-format': 'dp-qpsk',
92                         'aToZ-wavelength-number': 1,
93                         'aToZ': [
94                             {
95                                 'id': '0',
96                                 'resource': {
97                                     'tp-node-id': 'SPDR-SA1-XPDR1',
98                                     'tp-id': ''
99                                 }
100                             },
101                             {
102                                 'id': '1',
103                                 'resource': {
104                                     'tp-node-id': 'SPDR-SA1-XPDR1',
105                                     'tp-id': 'XPDR1-NETWORK1'
106                                 }
107                             },
108                             {
109                                 'id': '2',
110                                 'resource': {
111                                     'tp-node-id': 'SPDR-SC1-XPDR1',
112                                     'tp-id': 'XPDR1-NETWORK1'
113                                 }
114                             },
115                             {
116                                 'id': '3',
117                                 'resource': {
118                                     'tp-node-id': 'SPDR-SC1-XPDR1',
119                                     'tp-id': ''
120                                 }
121                             }
122                         ],
123                         'aToZ-min-frequency': 196.075,
124                         'aToZ-max-frequency': 196.125
125                     },
126                     'zToA-direction': {
127                         'zToA-wavelength-number': '1',
128                         'rate': '100',
129                         'modulation-format': 'dp-qpsk',
130                         'zToA': [
131                             {
132                                 'id': '0',
133                                 'resource': {
134                                     'tp-node-id': 'SPDR-SC1-XPDR1',
135                                     'tp-id': ''
136                                 }
137                             },
138                             {
139                                 'id': '1',
140                                 'resource': {
141                                     'tp-node-id': 'SPDR-SC1-XPDR1',
142                                     'tp-id': 'XPDR1-NETWORK1'
143                                 }
144                             },
145                             {
146                                 'id': '2',
147                                 'resource': {
148                                     'tp-node-id': 'SPDR-SA1-XPDR1',
149                                     'tp-id': 'XPDR1-NETWORK1'
150                                 }
151                             },
152                             {
153                                 'id': '3',
154                                 'resource': {
155                                     'tp-node-id': 'SPDR-SA1-XPDR1',
156                                     'tp-id': ''
157                                 }
158                             }
159                         ],
160                         'zToA-min-frequency': 196.075,
161                         'zToA-max-frequency': 196.125
162                     }
163                 }
164             })
165         self.assertEqual(response['status_code'], requests.codes.ok)
166         self.assertIn('Operation Successful',
167                       response['output']['configuration-response-common']['response-message'])
168
169     # Test OCH-OTU interfaces on SPDR-A1
170     def test_04_check_interface_och(self):
171         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SA1", "interface", "XPDR1-NETWORK1-761:768")
172         self.assertEqual(response['status_code'], requests.codes.ok)
173         self.assertDictEqual(dict({'name': 'XPDR1-NETWORK1-761:768',
174                                    'administrative-state': 'inService',
175                                    'supporting-circuit-pack-name': 'CP1-CFP0',
176                                    'type': 'org-openroadm-interfaces:opticalChannel',
177                                    'supporting-port': 'CP1-CFP0-P1'
178                                    }, **response['interface'][0]),
179                              response['interface'][0])
180         self.assertIn(
181             response['interface'][0]['org-openroadm-optical-channel-interfaces:och'],
182             [{'frequency': '196.1000', 'rate': 'org-openroadm-common-types:R100G',
183               'transmit-power': '-5', 'modulation-format': 'dp-qpsk'},
184              {'frequency': 196.1, 'rate': 'org-openroadm-common-types:R100G',
185               'transmit-power': -5, 'modulation-format': 'dp-qpsk'}])
186
187     def test_05_check_interface_OTU(self):
188         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SA1", "interface", "XPDR1-NETWORK1-OTU")
189         self.assertEqual(response['status_code'], requests.codes.ok)
190         input_dict_1 = {'name': 'XPDR1-NETWORK1-OTU',
191                         'administrative-state': 'inService',
192                         'supporting-circuit-pack-name': 'CP1-CFP0',
193                         'supporting-interface': 'XPDR1-NETWORK1-1',
194                         'type': 'org-openroadm-interfaces:otnOtu',
195                         'supporting-port': 'CP1-CFP0-P1'
196                         }
197         input_dict_2 = {'tx-dapi': 'AMf1n5hK6Xkk',
198                         'expected-sapi': 'AMf1n5hK6Xkk',
199                         'tx-sapi': 'H/OelLynehI=',
200                         'expected-dapi': 'H/OelLynehI=',
201                         'rate': 'org-openroadm-otn-common-types:OTU4',
202                         'fec': 'scfec'
203                         }
204         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
205                              response['interface'][0])
206         self.assertDictEqual(dict(input_dict_2, **response['interface'][0]['org-openroadm-otn-otu-interfaces:otu']),
207                              response['interface'][0]['org-openroadm-otn-otu-interfaces:otu'])
208
209     # Test OCH-OTU interfaces on SPDR-C1
210     def test_06_check_interface_och(self):
211         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SC1", "interface", "XPDR1-NETWORK1-761:768")
212         self.assertEqual(response['status_code'], requests.codes.ok)
213         self.assertDictEqual(dict({'name': 'XPDR1-NETWORK1-1',
214                                    'administrative-state': 'inService',
215                                    'supporting-circuit-pack-name': 'CP1-CFP0',
216                                    'type': 'org-openroadm-interfaces:opticalChannel',
217                                    'supporting-port': 'CP1-CFP0-P1'
218                                    }, **response['interface'][0]),
219                              response['interface'][0])
220         self.assertIn(
221             response['interface'][0]['org-openroadm-optical-channel-interfaces:och'],
222             [{'frequency': '196.1000', 'rate': 'org-openroadm-common-types:R100G',
223               'transmit-power': '-5', 'modulation-format': 'dp-qpsk'},
224              {'frequency': 196.1, 'rate': 'org-openroadm-common-types:R100G',
225               'transmit-power': -5, 'modulation-format': 'dp-qpsk'}])
226
227     def test_07_check_interface_OTU(self):
228         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SC1", "interface", "XPDR1-NETWORK1-OTU")
229         self.assertEqual(response['status_code'], requests.codes.ok)
230         input_dict_1 = {'name': 'XPDR1-NETWORK1-OTU',
231                         'administrative-state': 'inService',
232                         'supporting-circuit-pack-name': 'CP1-CFP0',
233                         'supporting-interface': 'XPDR1-NETWORK1-1',
234                         'type': 'org-openroadm-interfaces:otnOtu',
235                         'supporting-port': 'CP1-CFP0-P1'
236                         }
237         input_dict_2 = {'tx-dapi': 'H/OelLynehI=',
238                         'expected-sapi': 'H/OelLynehI=',
239                         'tx-sapi': 'AMf1n5hK6Xkk',
240                         'expected-dapi': 'AMf1n5hK6Xkk',
241                         'rate': 'org-openroadm-otn-common-types:OTU4',
242                         'fec': 'scfec'
243                         }
244         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
245                              response['interface'][0])
246         self.assertDictEqual(dict(input_dict_2, **response['interface'][0]['org-openroadm-otn-otu-interfaces:otu']),
247                              response['interface'][0]['org-openroadm-otn-otu-interfaces:otu'])
248
249     # Test creation of ODU4 service
250     def test_08_service_create_ODU4(self):
251         response = test_utils_rfc8040.renderer_service_implementation_request(
252             {
253                 'service-name':
254                 'SPDRA-SPDRC-OTU4-ODU4',
255                 'connection-type': 'infrastructure',
256                 'service-handler-header': {
257                     'request-id': 'abcd12-efgh34'
258                 },
259                 'service-a-end': {
260                     'service-format': 'ODU',
261                     'odu-service-rate':
262                     'org-openroadm-otn-common-types:ODU4',
263                     'clli': 'nodeSA',
264                     'node-id': 'SPDR-SA1'
265
266                 },
267                 'service-z-end': {
268                     'service-format': 'ODU',
269                     'odu-service-rate':
270                     'org-openroadm-otn-common-types:ODU4',
271                     'clli': 'nodeSC',
272                     'node-id': 'SPDR-SC1'
273                 },
274                 'path-description': {
275                     'aToZ-direction': {
276                         'rate': 100,
277                         'aToZ': [
278                             {
279                                 'id': '0',
280                                 'resource': {
281                                     'tp-node-id': 'SPDR-SA1-XPDR1',
282                                     'tp-id': ''
283                                 }
284                             },
285                             {
286                                 'id': '1',
287                                 'resource': {
288                                     'tp-node-id': 'SPDR-SA1-XPDR1',
289                                     'tp-id': 'XPDR1-NETWORK1'
290                                 }
291                             },
292                             {
293                                 'id': '2',
294                                 'resource': {
295                                     'tp-node-id': 'SPDR-SC1-XPDR1',
296                                     'tp-id': 'XPDR1-NETWORK1'
297                                 }
298                             },
299                             {
300                                 'id': '3',
301                                 'resource': {
302                                     'tp-node-id': 'SPDR-SC1-XPDR1',
303                                     'tp-id': ''
304                                 }
305                             }
306                         ]
307                     },
308                     'zToA-direction': {
309                         'rate': '100',
310                         'zToA': [
311                             {
312                                 'id': '0',
313                                 'resource': {
314                                     'tp-node-id': 'SPDR-SC1-XPDR1',
315                                     'tp-id': ''
316                                 }
317                             },
318                             {
319                                 'id': '1',
320                                 'resource': {
321                                     'tp-node-id': 'SPDR-SC1-XPDR1',
322                                     'tp-id': 'XPDR1-NETWORK1'
323                                 }
324                             },
325                             {
326                                 'id': '2',
327                                 'resource': {
328                                     'tp-node-id': 'SPDR-SA1-XPDR1',
329                                     'tp-id': 'XPDR1-NETWORK1'
330                                 }
331                             },
332                             {
333                                 'id': '3',
334                                 'resource': {
335                                     'tp-node-id': 'SPDR-SA1-XPDR1',
336                                     'tp-id': ''
337                                 }
338                             }
339                         ]
340                     }
341                 }
342             })
343         self.assertEqual(response['status_code'], requests.codes.ok)
344         self.assertIn('Operation Successful',
345                       response['output']['configuration-response-common']['response-message'])
346
347     # Test ODU4 interfaces on SPDR-A1 and SPDR-C1
348     def test_09_check_interface_ODU4(self):
349         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SA1", "interface", "XPDR1-NETWORK1-ODU4")
350         self.assertEqual(response['status_code'], requests.codes.ok)
351         input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU4',
352                         'administrative-state': 'inService',
353                         'supporting-circuit-pack-name': 'CP1-CFP0',
354                         'supporting-interface': 'XPDR1-NETWORK1-OTU',
355                         'type': 'org-openroadm-interfaces:otnOdu',
356                         'supporting-port': 'CP1-CFP0-P1'}
357         # SAPI/DAPI are added in the Otu4 renderer
358         input_dict_2 = {'odu-function': 'org-openroadm-otn-common-types:ODU-TTP',
359                         'rate': 'org-openroadm-otn-common-types:ODU4',
360                         'expected-dapi': 'H/OelLynehI=',
361                         'expected-sapi': 'AMf1n5hK6Xkk',
362                         'tx-dapi': 'AMf1n5hK6Xkk',
363                         'tx-sapi': 'H/OelLynehI='}
364
365         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
366                              response['interface'][0])
367         self.assertDictEqual(dict(response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'],
368                                   **input_dict_2),
369                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']
370                              )
371         self.assertDictEqual(
372             {'payload-type': '21', 'exp-payload-type': '21'},
373             response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
374
375     def test_10_check_interface_ODU4(self):
376         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SC1", "interface", "XPDR1-NETWORK1-ODU4")
377         self.assertEqual(response['status_code'], requests.codes.ok)
378         input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU4',
379                         'administrative-state': 'inService',
380                         'supporting-circuit-pack-name': 'CP1-CFP0',
381                         'supporting-interface': 'XPDR1-NETWORK1-OTU',
382                         'type': 'org-openroadm-interfaces:otnOdu',
383                         'supporting-port': 'CP1-CFP0-P1'}
384         # SAPI/DAPI are added in the Otu4 renderer
385         input_dict_2 = {'odu-function': 'org-openroadm-otn-common-types:ODU-TTP',
386                         'rate': 'org-openroadm-otn-common-types:ODU4',
387                         'tx-sapi': 'AMf1n5hK6Xkk',
388                         'tx-dapi': 'H/OelLynehI=',
389                         'expected-sapi': 'H/OelLynehI=',
390                         'expected-dapi': 'AMf1n5hK6Xkk'
391                         }
392         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
393                              response['interface'][0])
394         self.assertDictEqual(dict(response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'],
395                                   **input_dict_2),
396                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']
397                              )
398         self.assertDictEqual(
399             {'payload-type': '21', 'exp-payload-type': '21'},
400             response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
401
402     # Test creation of 10G service
403     def test_11_service_create_10GE(self):
404         response = test_utils_rfc8040.renderer_service_implementation_request(
405             {
406                 'service-name': 'SPDRA-SPDRC-10G',
407                 'connection-type': 'service',
408                 'service-handler-header': {
409                     'request-id': 'abcd12-efgh34'
410                 },
411                 'service-a-end': {
412                     'service-format': 'Ethernet',
413                     'service-rate': '10',
414                     'clli': 'nodeSA',
415                     'node-id': 'SPDR-SA1'
416                 },
417                 'service-z-end': {
418                     'service-format': 'Ethernet',
419                     'service-rate': '10',
420                     'clli': 'nodeSC',
421                     'node-id': 'SPDR-SC1'
422                 },
423                 'path-description': {
424                     'aToZ-direction': {
425                         'rate': 10,
426                         'min-trib-slot': '1.1',
427                         'max-trib-slot': '1.8',
428                         'aToZ': [
429                             {
430                                 'id': '0',
431                                 'resource': {
432                                     'tp-node-id': 'SPDR-SA1-XPDR1',
433                                     'tp-id': 'XPDR1-CLIENT1'
434
435                                 }
436                             },
437                             {
438                                 'id': '1',
439                                 'resource': {
440                                     'tp-node-id': 'SPDR-SA1-XPDR1',
441                                     'tp-id': 'XPDR1-NETWORK1'
442                                 }
443                             },
444                             {
445                                 'id': '2',
446                                 'resource': {
447                                     'tp-node-id': 'SPDR-SC1-XPDR1',
448                                     'tp-id': 'XPDR1-NETWORK1'
449                                 }
450                             },
451                             {
452                                 'id': '3',
453                                 'resource': {
454                                     'tp-node-id': 'SPDR-SC1-XPDR1',
455                                     'tp-id': 'XPDR1-CLIENT1'
456                                 }
457                             }
458                         ]
459                     },
460                     'zToA-direction': {
461                         'rate': '10',
462                         'min-trib-slot': '1.1',
463                         'max-trib-slot': '1.8',
464                         'zToA': [
465                             {
466                                 'id': '0',
467                                 'resource': {
468                                     'tp-node-id': 'SPDR-SC1-XPDR1',
469                                     'tp-id': 'XPDR1-CLIENT1'
470                                 }
471                             },
472                             {
473                                 'id': '1',
474                                 'resource': {
475                                     'tp-node-id': 'SPDR-SC1-XPDR1',
476                                     'tp-id': 'XPDR1-NETWORK1'
477                                 }
478                             },
479                             {
480                                 'id': '2',
481                                 'resource': {
482                                     'tp-node-id': 'SPDR-SA1-XPDR1',
483                                     'tp-id': 'XPDR1-NETWORK1'
484                                 }
485                             },
486                             {
487                                 'id': '3',
488                                 'resource': {
489                                     'tp-node-id': 'SPDR-SA1-XPDR1',
490                                     'tp-id': 'XPDR1-CLIENT1'
491
492                                 }
493                             }
494                         ]
495                     }
496                 }
497             })
498         self.assertEqual(response['status_code'], requests.codes.ok)
499         self.assertIn('Operation Successful',
500                       response['output']['configuration-response-common']['response-message'])
501
502     # Test the interfaces on SPDR-A1
503     def test_12_check_interface_10GE_CLIENT(self):
504         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SA1", "interface", "XPDR1-CLIENT1-ETHERNET10G")
505         self.assertEqual(response['status_code'], requests.codes.ok)
506         input_dict = {'name': 'XPDR1-CLIENT1-ETHERNET10G',
507                       'administrative-state': 'inService',
508                       'supporting-circuit-pack-name': 'CP1-SFP4',
509                       'type': 'org-openroadm-interfaces:ethernetCsmacd',
510                       'supporting-port': 'CP1-SFP4-P1'
511                       }
512         self.assertDictEqual(dict(input_dict, **response['interface'][0]),
513                              response['interface'][0])
514         self.assertEqual(response['interface'][0]['org-openroadm-ethernet-interfaces:ethernet']['speed'], 10000)
515
516     def test_13_check_interface_ODU2E_CLIENT(self):
517         response = test_utils_rfc8040.check_node_attribute_request(
518             "SPDR-SA1", "interface", "XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G")
519         self.assertEqual(response['status_code'], requests.codes.ok)
520         input_dict_1 = {'name': 'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G',
521                         'administrative-state': 'inService',
522                         'supporting-circuit-pack-name': 'CP1-SFP4',
523                         'supporting-interface': 'XPDR1-CLIENT1-ETHERNET10G',
524                         'type': 'org-openroadm-interfaces:otnOdu',
525                         'supporting-port': 'CP1-SFP4-P1'}
526         input_dict_2 = {
527             'odu-function': 'org-openroadm-otn-common-types:ODU-TTP-CTP',
528             'rate': 'org-openroadm-otn-common-types:ODU2e',
529             'monitoring-mode': 'terminated'}
530
531         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
532                              response['interface'][0])
533         self.assertDictEqual(dict(input_dict_2,
534                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
535                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
536         self.assertDictEqual(
537             {'payload-type': '03', 'exp-payload-type': '03'},
538             response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
539
540     def test_14_check_ODU2E_connection(self):
541         response = test_utils_rfc8040.check_node_attribute_request(
542             "SPDR-SA1",
543             "odu-connection", "XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G-x-XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G")
544         self.assertEqual(response['status_code'], requests.codes.ok)
545         input_dict_1 = {
546             'connection-name':
547             'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G-x-XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G',
548             'direction': 'bidirectional'
549         }
550         self.assertDictEqual(dict(input_dict_1, **response['odu-connection'][0]),
551                              response['odu-connection'][0])
552         self.assertDictEqual({'dst-if': 'XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G'},
553                              response['odu-connection'][0]['destination'])
554         self.assertDictEqual({'src-if': 'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G'},
555                              response['odu-connection'][0]['source'])
556
557     def test_15_check_interface_ODU2E_NETWORK(self):
558         response = test_utils_rfc8040.check_node_attribute_request(
559             "SPDR-SA1", "interface", "XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G")
560         self.assertEqual(response['status_code'], requests.codes.ok)
561         input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G',
562                         'administrative-state': 'inService',
563                         'supporting-circuit-pack-name': 'CP1-CFP0',
564                         'supporting-interface': 'XPDR1-NETWORK1-ODU4',
565                         'type': 'org-openroadm-interfaces:otnOdu',
566                         'supporting-port': 'CP1-CFP0-P1'}
567         input_dict_2 = {
568             'odu-function': 'org-openroadm-otn-common-types:ODU-CTP',
569             'rate': 'org-openroadm-otn-common-types:ODU2e',
570             'monitoring-mode': 'monitored'}
571         input_dict_3 = {'trib-port-number': 1}
572         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
573                              response['interface'][0])
574         self.assertDictEqual(dict(input_dict_2,
575                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
576                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
577         self.assertDictEqual(dict(input_dict_3,
578                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
579                                       'parent-odu-allocation']),
580                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
581             'parent-odu-allocation'])
582         self.assertIn(1,
583                       response['interface'][0][
584                           'org-openroadm-otn-odu-interfaces:odu'][
585                           'parent-odu-allocation']['trib-slots'])
586
587     # Test the interfaces on SPDR-C1
588     def test_16_check_interface_ODU2E_NETWORK(self):
589         response = test_utils_rfc8040.check_node_attribute_request(
590             "SPDR-SC1", "interface", "XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G")
591         self.assertEqual(response['status_code'], requests.codes.ok)
592         input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G',
593                         'administrative-state': 'inService',
594                         'supporting-circuit-pack-name': 'CP1-CFP0',
595                         'supporting-interface': 'XPDR1-NETWORK1-ODU4',
596                         'type': 'org-openroadm-interfaces:otnOdu',
597                         'supporting-port': 'CP1-CFP0-P1'}
598         input_dict_2 = {
599             'odu-function': 'org-openroadm-otn-common-types:ODU-CTP',
600             'rate': 'org-openroadm-otn-common-types:ODU2e',
601             'monitoring-mode': 'monitored'}
602         input_dict_3 = {'trib-port-number': 1}
603         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
604                              response['interface'][0])
605         self.assertDictEqual(dict(input_dict_2,
606                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
607                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
608         self.assertDictEqual(dict(input_dict_3,
609                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
610                                       'parent-odu-allocation']),
611                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
612             'parent-odu-allocation'])
613         self.assertIn(1,
614                       response['interface'][0][
615                           'org-openroadm-otn-odu-interfaces:odu'][
616                           'parent-odu-allocation']['trib-slots'])
617
618     def test_17_check_interface_10GE_CLIENT(self):
619         response = test_utils_rfc8040.check_node_attribute_request("SPDR-SC1", "interface", "XPDR1-CLIENT1-ETHERNET10G")
620         self.assertEqual(response['status_code'], requests.codes.ok)
621         input_dict = {'name': 'XPDR1-CLIENT1-ETHERNET10G',
622                       'administrative-state': 'inService',
623                       'supporting-circuit-pack-name': 'CP1-SFP4',
624                       'type': 'org-openroadm-interfaces:ethernetCsmacd',
625                       'supporting-port': 'CP1-SFP4-P1'
626                       }
627         self.assertDictEqual(dict(input_dict, **response['interface'][0]),
628                              response['interface'][0])
629         self.assertEqual(response['interface'][0]['org-openroadm-ethernet-interfaces:ethernet']['speed'], 10000)
630
631     def test_18_check_interface_ODU2E_CLIENT(self):
632         response = test_utils_rfc8040.check_node_attribute_request(
633             "SPDR-SC1", "interface", "XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G")
634         self.assertEqual(response['status_code'], requests.codes.ok)
635         input_dict_1 = {'name': 'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G',
636                         'administrative-state': 'inService',
637                         'supporting-circuit-pack-name': 'CP1-SFP4',
638                         'supporting-interface': 'XPDR1-CLIENT1-ETHERNET10G',
639                         'type': 'org-openroadm-interfaces:otnOdu',
640                         'supporting-port': 'CP1-SFP4-P1'}
641         input_dict_2 = {
642             'odu-function': 'org-openroadm-otn-common-types:ODU-TTP-CTP',
643             'rate': 'org-openroadm-otn-common-types:ODU2e',
644             'monitoring-mode': 'terminated'}
645         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
646                              response['interface'][0])
647         self.assertDictEqual(dict(input_dict_2,
648                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
649                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
650         self.assertDictEqual(
651             {'payload-type': '03', 'exp-payload-type': '03'},
652             response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
653
654     def test_19_check_ODU2E_connection(self):
655         response = test_utils_rfc8040.check_node_attribute_request(
656             "SPDR-SC1",
657             "odu-connection", "XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G-x-XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G")
658         self.assertEqual(response['status_code'], requests.codes.ok)
659         input_dict_1 = {
660             'connection-name':
661             'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G-x-XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G',
662             'direction': 'bidirectional'
663         }
664         self.assertDictEqual(dict(input_dict_1, **response['odu-connection'][0]),
665                              response['odu-connection'][0])
666         self.assertDictEqual({'dst-if': 'XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G'},
667                              response['odu-connection'][0]['destination'])
668         self.assertDictEqual({'src-if': 'XPDR1-CLIENT1-ODU2e-SPDRA-SPDRC-10G'},
669                              response['odu-connection'][0]['source'])
670
671     def test_20_check_interface_ODU2E_NETWORK(self):
672         response = test_utils_rfc8040.check_node_attribute_request(
673             "SPDR-SC1", "interface", "XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G")
674         self.assertEqual(response['status_code'], requests.codes.ok)
675         input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU2e-SPDRA-SPDRC-10G',
676                         'administrative-state': 'inService',
677                         'supporting-circuit-pack-name': 'CP1-CFP0',
678                         'supporting-interface': 'XPDR1-NETWORK1-ODU4',
679                         'type': 'org-openroadm-interfaces:otnOdu',
680                         'supporting-port': 'CP1-CFP0-P1'}
681         input_dict_2 = {
682             'odu-function': 'org-openroadm-otn-common-types:ODU-CTP',
683             'rate': 'org-openroadm-otn-common-types:ODU2e',
684             'monitoring-mode': 'monitored'}
685
686         input_dict_3 = {'trib-port-number': 1}
687
688         self.assertDictEqual(dict(input_dict_1, **response['interface'][0]),
689                              response['interface'][0])
690         self.assertDictEqual(dict(input_dict_2,
691                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu']),
692                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'])
693         self.assertDictEqual(dict(input_dict_3,
694                                   **response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
695                                       'parent-odu-allocation']),
696                              response['interface'][0]['org-openroadm-otn-odu-interfaces:odu'][
697             'parent-odu-allocation'])
698         self.assertIn(1,
699                       response['interface'][0][
700                           'org-openroadm-otn-odu-interfaces:odu'][
701                           'parent-odu-allocation']['trib-slots'])
702
703     # TODO: Delete the services (OTU, ODU, LO-ODU)
704     # TODO: Delete interfaces (SPDR-A1, SPDR-C1)
705
706     def test_21_disconnect_SPDR_SA1(self):
707         response = test_utils_rfc8040.unmount_device("SPDR-SA1")
708         self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
709
710     def test_22_disconnect_SPDR_SC1(self):
711         response = test_utils_rfc8040.unmount_device("SPDR-SC1")
712         self.assertIn(response.status_code, (requests.codes.ok, requests.codes.no_content))
713
714
715 if __name__ == "__main__":
716     unittest.main(verbosity=2)