fix karaf launch error from tox
[transportpce.git] / tests / transportpce_tests / test_servicehandler.py
1 #!/usr/bin/env python
2 ##############################################################################
3 # Copyright (c) 2017 Orange, Inc. and others.  All rights reserved.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 import json
12 import os
13 import psutil
14 import requests
15 import signal
16 import shutil
17 import subprocess
18 import time
19 import unittest
20
21
22 class TransportPCEtesting(unittest.TestCase):
23
24     odl_process = None
25     honeynode_topology = None
26     restconf_baseurl = "http://localhost:8181/restconf"
27
28     @classmethod
29     def _get_file(cls):
30         honeynode_topology_file = "sample_configs/honeynode-topo.xml"
31         if os.path.isfile(honeynode_topology_file):
32             with open(honeynode_topology_file, 'r') as honeynode_file:
33                 cls.honeynode_topo = honeynode_file.read();
34
35     @classmethod
36     def __start_odl(cls):
37         executable = "../karaf/target/assembly/bin/karaf"
38         with open('odl.log', 'w') as outfile:
39             cls.odl_process = subprocess.Popen(
40                 ["bash", executable, "server"], stdout=outfile,
41                 stdin=open(os.devnull))
42
43     @classmethod
44     def setUpClass(cls):  # a class method called before tests in an individual class run.
45         cls._get_file()
46         cls.__start_odl()
47         time.sleep(90)
48
49     @classmethod
50     def tearDownClass(cls):
51         for child in psutil.Process(cls.odl_process.pid).children():
52             child.send_signal(signal.SIGINT)
53             child.wait()
54         cls.odl_process.send_signal(signal.SIGINT)
55         cls.odl_process.wait()
56
57     def setUp(self):  # instruction executed before each test method
58         print ("execution of {}".format(self.id().split(".")[-1]))
59
60     def test_01_restconfAPI(self):
61         url = ("{}/operational/network-topology:network-topology/topology/"
62         "topology-netconf/node/controller-config".format(self.restconf_baseurl))
63         headers = {'content-type': 'application/json'}
64         response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
65         self.assertEqual(response.status_code, requests.codes.ok)
66         res = response.json()
67         self.assertEqual(res['node'] [0] ['netconf-node-topology:connection-status'],
68                          'connected')
69         time.sleep(1)
70
71     # Load honeynode topology
72     def test_02_load_honeynode_topology(self):
73         url = ("{}/config/ietf-network:network/openroadm-topology"
74               .format(self.restconf_baseurl))
75         body = self.honeynode_topo
76         headers = {'content-type': 'application/xml',
77         "Accept": "application/json"}
78         response = requests.request(
79             "PUT", url, data=body, headers=headers,
80             auth=('admin', 'admin'))
81         self.assertEqual(response.status_code, requests.codes.ok)
82         time.sleep(2)
83
84     def test_03_check_link_xpdra_roadma(self):
85         url = ("{}/config/ietf-network:network/openroadm-topology/link/"
86                "XPDRA-XPDR1-XPDR1-NETWORK1toROADMA-SRG1-SRG1-PP1-TXRX".format(self.restconf_baseurl))
87         headers = {'content-type': 'application/json'}
88         response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
89         self.assertEqual(response.status_code, requests.codes.ok)
90         res = response.json()
91         time.sleep(1)
92
93     def test_04_check_link_xpdrc_roadmc(self):
94         url = ("{}/config/ietf-network:network/openroadm-topology/link/"
95                "XPDRC-XPDR1-XPDR1-NETWORK1toROADMC-SRG1-SRG1-PP1-TXRX".format(self.restconf_baseurl))
96         headers = {'content-type': 'application/json'}
97         response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
98         self.assertEqual(response.status_code, requests.codes.ok)
99         res = response.json()
100         time.sleep(1)
101
102     def test_05_check_link_roadma_xpdra(self):
103         url = ("{}/config/ietf-network:network/openroadm-topology/link/"
104                "ROADMA-SRG1-SRG1-PP1-TXRXtoXPDRA-XPDR1-XPDR1-NETWORK1".format(self.restconf_baseurl))
105         headers = {'content-type': 'application/json'}
106         response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
107         self.assertEqual(response.status_code, requests.codes.ok)
108         res = response.json()
109         time.sleep(1)
110
111     def test_06_check_link_roadmc_xpdrc(self):
112         url = ("{}/config/ietf-network:network/openroadm-topology/link/"
113                "ROADMC-SRG1-SRG1-PP1-TXRXtoXPDRC-XPDR1-XPDR1-NETWORK1".format(self.restconf_baseurl))
114         headers = {'content-type': 'application/json'}
115         response = requests.request("GET", url, headers=headers, auth=('admin', 'admin'))
116         self.assertEqual(response.status_code, requests.codes.ok)
117         res = response.json()
118         time.sleep(1)
119
120     # Create Service 'test' with correct parameters
121     def test_07_create_service(self):
122         url = ("{}/operations/org-openroadm-service:service-create"
123               .format(self.restconf_baseurl))
124         data = {"input": {
125                 "sdnc-request-header": {
126                     "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
127                     "rpc-action": "service-create",
128                     "request-system-id": "appname",
129                     "notification-url": "http://localhost:8585/NotificationServer/notify"
130                 },
131                 "service-name": "test",
132                 "common-id": "ASATT1234567",
133                 "connection-type": "infrastructure",
134                 "service-a-end": {
135                     "service-rate": "100",
136                     "node-id": "XPDRA",
137                     "service-format": "Ethernet",
138                     "clli": "SNJSCAMCJP8",
139                     "tx-direction": {
140                         "port": {
141                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
142                             "port-type": "router",
143                             "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
144                             "port-rack": "000000.00",
145                             "port-shelf": "00"
146                         },
147                         "lgx": {
148                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
149                             "lgx-port-name": "LGX Back.3",
150                             "lgx-port-rack": "000000.00",
151                             "lgx-port-shelf": "00"
152                         }
153                     },
154                     "rx-direction": {
155                         "port": {
156                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
157                             "port-type": "router",
158                             "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
159                             "port-rack": "000000.00",
160                             "port-shelf": "00"
161                         },
162                         "lgx": {
163                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
164                             "lgx-port-name": "LGX Back.4",
165                             "lgx-port-rack": "000000.00",
166                             "lgx-port-shelf": "00"
167                         }
168                     },
169                     "optic-type": "gray"
170                 },
171                 "service-z-end": {
172                     "service-rate": "100",
173                     "node-id": "XPDRC",
174                     "service-format": "Ethernet",
175                     "clli": "SNJSCAMCJT4",
176                     "tx-direction": {
177                         "port": {
178                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
179                             "port-type": "router",
180                             "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
181                             "port-rack": "000000.00",
182                             "port-shelf": "00"
183                         },
184                         "lgx": {
185                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
186                             "lgx-port-name": "LGX Back.29",
187                             "lgx-port-rack": "000000.00",
188                             "lgx-port-shelf": "00"
189                         }
190                     },
191                     "rx-direction": {
192                         "port": {
193                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
194                             "port-type": "router",
195                             "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
196                             "port-rack": "000000.00",
197                             "port-shelf": "00"
198                         },
199                         "lgx": {
200                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
201                             "lgx-port-name": "LGX Back.30",
202                             "lgx-port-rack": "000000.00",
203                             "lgx-port-shelf": "00"
204                         }
205                     },
206                     "optic-type": "gray"
207                 },
208                 "due-date": "2016-11-28T00:00:01Z",
209                 "operator-contact": "pw1234"
210             }
211         }
212         headers = {'content-type': 'application/json',
213         "Accept": "application/json"}
214         response = requests.request(
215             "POST", url, data=json.dumps(data), headers=headers,
216             auth=('admin', 'admin'))
217         self.assertEqual(response.status_code, requests.codes.ok)
218         res = response.json()
219         self.assertIn('Service rendered successfully !',
220             res['output']['configuration-response-common']['response-message'])
221         time.sleep(10)
222
223     # Create Service 'test' with not compliant parameter : no 'sdnc-request-header' parameter
224     def test_08_create_service(self):
225         url = ("{}/operations/org-openroadm-service:service-create"
226               .format(self.restconf_baseurl))
227         data = {"input": {
228                 "service-name": "test",
229                 "common-id": "ASATT1234567",
230                 "connection-type": "infrastructure",
231                 "service-a-end": {
232                     "service-rate": "100",
233                     "node-id": "XPDRA",
234                     "service-format": "Ethernet",
235                     "clli": "SNJSCAMCJP8",
236                     "tx-direction": {
237                         "port": {
238                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
239                             "port-type": "router",
240                             "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
241                             "port-rack": "000000.00",
242                             "port-shelf": "00"
243                         },
244                         "lgx": {
245                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
246                             "lgx-port-name": "LGX Back.3",
247                             "lgx-port-rack": "000000.00",
248                             "lgx-port-shelf": "00"
249                         }
250                     },
251                     "rx-direction": {
252                         "port": {
253                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
254                             "port-type": "router",
255                             "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
256                             "port-rack": "000000.00",
257                             "port-shelf": "00"
258                         },
259                         "lgx": {
260                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
261                             "lgx-port-name": "LGX Back.4",
262                             "lgx-port-rack": "000000.00",
263                             "lgx-port-shelf": "00"
264                         }
265                     },
266                     "optic-type": "gray"
267                 },
268                 "service-z-end": {
269                     "service-rate": "100",
270                     "node-id": "XPDRC",
271                     "service-format": "Ethernet",
272                     "clli": "SNJSCAMCJT4",
273                     "tx-direction": {
274                         "port": {
275                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
276                             "port-type": "router",
277                             "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
278                             "port-rack": "000000.00",
279                             "port-shelf": "00"
280                         },
281                         "lgx": {
282                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
283                             "lgx-port-name": "LGX Back.29",
284                             "lgx-port-rack": "000000.00",
285                             "lgx-port-shelf": "00"
286                         }
287                     },
288                     "rx-direction": {
289                         "port": {
290                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
291                             "port-type": "router",
292                             "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
293                             "port-rack": "000000.00",
294                             "port-shelf": "00"
295                         },
296                         "lgx": {
297                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
298                             "lgx-port-name": "LGX Back.30",
299                             "lgx-port-rack": "000000.00",
300                             "lgx-port-shelf": "00"
301                         }
302                     },
303                     "optic-type": "gray"
304                 },
305                 "due-date": "2016-11-28T00:00:01Z",
306                 "operator-contact": "pw1234"
307             }
308         }
309         headers = {'content-type': 'application/json',
310         "Accept": "application/json"}
311         response = requests.request(
312             "POST", url, data=json.dumps(data), headers=headers,
313             auth=('admin', 'admin'))
314         self.assertEqual(response.status_code, requests.codes.ok)
315         res = response.json()
316         self.assertIn('Service sndc-request-header is not set',
317             res['output']['configuration-response-common']['response-message'])
318         time.sleep(5)
319
320     # Create Service 'test' with not compliant parameter : no 'tx-direction' for serviceAEnd
321     def test_09_create_service(self):
322         url = ("{}/operations/org-openroadm-service:service-create"
323               .format(self.restconf_baseurl))
324         data = {"input": {
325                 "sdnc-request-header": {
326                     "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
327                     "rpc-action": "service-create",
328                     "request-system-id": "appname",
329                     "notification-url": "http://localhost:8585/NotificationServer/notify"
330                 },
331                 "service-name": "test",
332                 "common-id": "ASATT1234567",
333                 "connection-type": "infrastructure",
334                 "service-a-end": {
335                     "service-rate": "100",
336                     "node-id": "XPDRA",
337                     "service-format": "Ethernet",
338                     "clli": "SNJSCAMCJP8",
339                     "rx-direction": {
340                         "port": {
341                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
342                             "port-type": "router",
343                             "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
344                             "port-rack": "000000.00",
345                             "port-shelf": "00"
346                         },
347                         "lgx": {
348                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
349                             "lgx-port-name": "LGX Back.4",
350                             "lgx-port-rack": "000000.00",
351                             "lgx-port-shelf": "00"
352                         }
353                     },
354                     "optic-type": "gray"
355                 },
356                 "service-z-end": {
357                     "service-rate": "100",
358                     "node-id": "XPDRC",
359                     "service-format": "Ethernet",
360                     "clli": "SNJSCAMCJT4",
361                     "tx-direction": {
362                         "port": {
363                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
364                             "port-type": "router",
365                             "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
366                             "port-rack": "000000.00",
367                             "port-shelf": "00"
368                         },
369                         "lgx": {
370                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
371                             "lgx-port-name": "LGX Back.29",
372                             "lgx-port-rack": "000000.00",
373                             "lgx-port-shelf": "00"
374                         }
375                     },
376                     "rx-direction": {
377                         "port": {
378                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
379                             "port-type": "router",
380                             "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
381                             "port-rack": "000000.00",
382                             "port-shelf": "00"
383                         },
384                         "lgx": {
385                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
386                             "lgx-port-name": "LGX Back.30",
387                             "lgx-port-rack": "000000.00",
388                             "lgx-port-shelf": "00"
389                         }
390                     },
391                     "optic-type": "gray"
392                 },
393                 "due-date": "2016-11-28T00:00:01Z",
394                 "operator-contact": "pw1234"
395             }
396         }
397         headers = {'content-type': 'application/json',
398         "Accept": "application/json"}
399         response = requests.request(
400             "POST", url, data=json.dumps(data), headers=headers,
401             auth=('admin', 'admin'))
402         self.assertEqual(response.status_code, requests.codes.ok)
403         res = response.json()
404         self.assertIn('Service TxDirection is not correctly set',
405             res['output']['configuration-response-common']['response-message'])
406         time.sleep(5)
407
408     # Get 'test' service created
409     def test_10_get_service(self):
410         url = ("{}/operational/org-openroadm-service:service-list/services/test"
411               .format(self.restconf_baseurl))
412         headers = {'content-type': 'application/json',
413         "Accept": "application/json"}
414         response = requests.request(
415             "GET", url, headers=headers, auth=('admin', 'admin'))
416         self.assertEqual(response.status_code, requests.codes.ok)
417         res = response.json()
418         self.assertEqual(
419             res['services'][0]['administrative-state'],
420             'inService')
421         time.sleep(1)
422
423     # get non existing service
424     def test_11_get_service(self):
425         url = ("{}/operational/org-openroadm-service:service-list/services/test1"
426               .format(self.restconf_baseurl))
427         headers = {'content-type': 'application/json',
428         "Accept": "application/json"}
429         response = requests.request(
430             "GET", url, headers=headers, auth=('admin', 'admin'))
431         self.assertEqual(response.status_code, 404)
432         time.sleep(1)
433
434 # These tests is not available in this commit (cf commit message )
435 # reconfigure 'test' to be 'test-new'
436 #     def test_08_reconfigure_service(self):
437 #         url = ("{}/operations/org-openroadm-service:service-reconfigure"
438 #               .format(self.restconf_baseurl))
439 #         data = {"input": {
440 #                 "service-name": "test",
441 #                 "new-service-name": "test-new",
442 #                 "common-id": "ASATT1234567",
443 #                 "connection-type": "infrastructure",
444 #                 "service-a-end": {
445 #                     "service-rate": "100",
446 #                     "node-id": "XPDRA",
447 #                     "service-format": "Ethernet",
448 #                     "clli": "SNJSCAMCJP8",
449 #                     "tx-direction": {
450 #                         "port": {
451 #                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
452 #                             "port-type": "router",
453 #                             "port-name": "Gigabit Ethernet_Tx.ge-5/0/0.0",
454 #                             "port-rack": "000000.00",
455 #                             "port-shelf": "00"
456 #                         },
457 #                         "lgx": {
458 #                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
459 #                             "lgx-port-name": "LGX Back.3",
460 #                             "lgx-port-rack": "000000.00",
461 #                             "lgx-port-shelf": "00"
462 #                         }
463 #                     },
464 #                     "rx-direction": {
465 #                         "port": {
466 #                             "port-device-name": "ROUTER_SNJSCAMCJP8_000000.00_00",
467 #                             "port-type": "router",
468 #                             "port-name": "Gigabit Ethernet_Rx.ge-5/0/0.0",
469 #                             "port-rack": "000000.00",
470 #                             "port-shelf": "00"
471 #                         },
472 #                         "lgx": {
473 #                             "lgx-device-name": "LGX Panel_SNJSCAMCJP8_000000.00_00",
474 #                             "lgx-port-name": "LGX Back.4",
475 #                             "lgx-port-rack": "000000.00",
476 #                             "lgx-port-shelf": "00"
477 #                         }
478 #                     },
479 #                     "optic-type": "gray"
480 #                 },
481 #                 "service-z-end": {
482 #                     "service-rate": "100",
483 #                     "node-id": "XPDRC",
484 #                     "service-format": "Ethernet",
485 #                     "clli": "SNJSCAMCJT4",
486 #                     "tx-direction": {
487 #                         "port": {
488 #                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
489 #                             "port-type": "router",
490 #                             "port-name": "Gigabit Ethernet_Tx.ge-1/0/0.0",
491 #                             "port-rack": "000000.00",
492 #                             "port-shelf": "00"
493 #                         },
494 #                         "lgx": {
495 #                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
496 #                             "lgx-port-name": "LGX Back.29",
497 #                             "lgx-port-rack": "000000.00",
498 #                             "lgx-port-shelf": "00"
499 #                         }
500 #                     },
501 #                     "rx-direction": {
502 #                         "port": {
503 #                             "port-device-name": "ROUTER_SNJSCAMCJT4_000000.00_00",
504 #                             "port-type": "router",
505 #                             "port-name": "Gigabit Ethernet_Rx.ge-1/0/0.0",
506 #                             "port-rack": "000000.00",
507 #                             "port-shelf": "00"
508 #                         },
509 #                         "lgx": {
510 #                             "lgx-device-name": "LGX Panel_SNJSCAMCJT4_000000.00_00",
511 #                             "lgx-port-name": "LGX Back.30",
512 #                             "lgx-port-rack": "000000.00",
513 #                             "lgx-port-shelf": "00"
514 #                         }
515 #                     },
516 #                     "optic-type": "gray"
517 #                 },
518 #                 "hard-constraints": {
519 #                     "diversity": {
520 #                         "existing-service": [
521 #                             "104/GE100/SNJSCAMCJP8/SNJSCAMCJT4"
522 #                         ],
523 #                         "existing-service-applicability": {
524 #                             "node": "true"
525 #                         }
526 #                     },
527 #                     "exclude": {
528 #                         "fiber-bundle": [
529 #                             "l(string)"
530 #                         ],
531 #                         "node-id": [
532 #                             "SNJSCAMCJP8_000000.00"
533 #                         ]
534 #                     },
535 #                     "latency": {
536 #                         "max-latency": "30"
537 #                     }
538 #                 }
539 #             }
540 #         }
541 #         headers = {'content-type': 'application/json',
542 #         "Accept": "application/json"}
543 #         response = requests.request(
544 #             "POST", url, data=json.dumps(data), headers=headers,
545 #             auth=('admin', 'admin'))
546 #         self.assertEqual(response.status_code, requests.codes.ok)
547 #         res = response.json()
548 #         self.assertIn('in progress',
549 #             res['output']['status-message'])
550 #         time.sleep(30)
551 #
552 #     # get new service 'test-new'
553 #     def test_09_get_service(self):
554 #         url = ("{}/operational/org-openroadm-service:service-list/services/test-new"
555 #               .format(self.restconf_baseurl))
556 #         headers = {'content-type': 'application/json',
557 #         "Accept": "application/json"}
558 #         response = requests.request(
559 #             "GET", url, headers=headers, auth=('admin', 'admin'))
560 #         res = response.json()
561 #         self.assertEqual(
562 #             res['services'][0]['operational-state'],
563 #             'inService')
564 #         time.sleep(1)
565 #
566 #     # Modify 'test-new' state
567 #     def test_10_modify_service_state(self):
568 #         url = ("{}/operations/servicehandler:service-state-modify"
569 #               .format(self.restconf_baseurl))
570 #         data = {"input": {
571 #                 "service-name": "test-new",
572 #                 "operational-state": "outOfService"
573 #             }
574 #         }
575 #         headers = {'content-type': 'application/json'}
576 #         response = requests.request(
577 #             "POST", url, data=json.dumps(data), headers=headers,
578 #             auth=('admin', 'admin'))
579 #         res = response.json()
580 #         self.assertIn('Service state modified',
581 #             res['output']['configuration-response-common']['response-message'])
582 #         time.sleep(5)
583 #
584 #     # get new service 'test-new' state
585 #     def test_11_get_service(self):
586 #         url = ("{}/operational/org-openroadm-service:service-list/services/test-new"
587 #               .format(self.restconf_baseurl))
588 #         headers = {'content-type': 'application/json',
589 #         "Accept": "application/json"}
590 #         response = requests.request(
591 #             "GET", url, headers=headers, auth=('admin', 'admin'))
592 #         res = response.json()
593 #         self.assertEqual(
594 #             res['services'][0]['operational-state'],
595 #             'outOfService')
596 #         time.sleep(1)
597 #
598 #     # restore service 'test-new'
599 #     def test_12_restore_service(self):
600 #         url = ("{}/operations/org-openroadm-service:service-restoration"
601 #               .format(self.restconf_baseurl))
602 #         data = {"input": {
603 #                 "service-name": "test-new",
604 #                 "option": "permanent"
605 #             }
606 #         }
607 #         headers = {'content-type': 'application/json'}
608 #         response = requests.request(
609 #             "POST", url, data=json.dumps(data), headers=headers,
610 #             auth=('admin', 'admin'))
611 #         res = response.json()
612 #         self.assertIn('in progress',
613 #             res['output']['status-message'])
614 #         time.sleep(60)
615 #
616 #     # get new service 'test-new' state
617 #     def test_13_get_service(self):
618 #         url = ("{}/operational/org-openroadm-service:service-list/services/test-new"
619 #               .format(self.restconf_baseurl))
620 #         headers = {'content-type': 'application/json',
621 #         "Accept": "application/json"}
622 #         response = requests.request(
623 #             "GET", url, headers=headers, auth=('admin', 'admin'))
624 #         res = response.json()
625 #         self.assertEqual(
626 #             res['services'][0]['operational-state'],
627 #             'inService')
628 #         time.sleep(1)
629
630     # Delete non existing service
631     def test_12_delete_service(self):
632         url = ("{}/operations/org-openroadm-service:service-delete"
633               .format(self.restconf_baseurl))
634         data = {"input": {
635                 "sdnc-request-header": {
636                     "request-id": "e3028bae-a90f-4ddd-a83f-cf224eba0e58",
637                     "rpc-action": "service-delete",
638                     "request-system-id": "appname",
639                     "notification-url": "http://localhost:8585/NotificationServer/notify"
640                 },
641                 "service-delete-req-info": {
642                     "service-name": "test",
643                     "due-date": "2016-11-28T00:00:01Z",
644                     "tail-retention": "no"
645                 }
646             }
647         }
648         headers = {'content-type': 'application/json'}
649         response = requests.request(
650             "POST", url, data=json.dumps(data), headers=headers,
651             auth=('admin', 'admin'))
652         self.assertEqual(response.status_code, requests.codes.ok)
653         res = response.json()
654         self.assertIn('Service delete was successful!',
655             res['output']['configuration-response-common']['response-message'])
656         time.sleep(1)
657
658     # Verify 'test' service deleted
659     def test_13_get_service(self):
660         url = ("{}/operational/org-openroadm-service:service-list/services/test-new"
661               .format(self.restconf_baseurl))
662         headers = {'content-type': 'application/json',
663         "Accept": "application/json"}
664         response = requests.request(
665             "GET", url, headers=headers, auth=('admin', 'admin'))
666         self.assertEqual(response.status_code, 404)
667         time.sleep(1)
668
669
670 if __name__ == "__main__":
671     unittest.main(verbosity=2)