# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import unittest
import json
-import os
-import psutil
-import requests
-import signal
-import shutil
-import subprocess
import time
-import unittest
-import logging
-import test_utils
+import requests
+from common import test_utils
def extract_a_from_b(a, b):
class TransportPCEtesting(unittest.TestCase):
processes = None
- restconf_baseurl = "http://localhost:8181/restconf"
@classmethod
def setUpClass(cls):
time.sleep(5)
def test_01_connect_SPDR_SA1(self):
- url = ("{}/config/network-topology:"
- "network-topology/topology/topology-netconf/node/SPDR-SA1"
- .format(self.restconf_baseurl))
- data = {"node": [{
- "node-id": "SPDR-SA1",
- "netconf-node-topology:username": "admin",
- "netconf-node-topology:password": "admin",
- "netconf-node-topology:host": "127.0.0.1",
- "netconf-node-topology:port": test_utils.sims['spdrav2']['port'],
- "netconf-node-topology:tcp-only": "false",
- "netconf-node-topology:pass-through": {}}]}
- headers = {'content-type': 'application/json'}
- response = requests.request(
- "PUT", url, data=json.dumps(data), headers=headers,
- auth=('admin', 'admin'))
- self.assertEqual(response.status_code, requests.codes.created)
+ response = test_utils.mount_device("SPDR-SA1", 'spdrav2')
+ self.assertEqual(response.status_code, requests.codes.created, test_utils.CODE_SHOULD_BE_201)
time.sleep(10)
+
url = ("{}/operational/network-topology:"
"network-topology/topology/topology-netconf/node/SPDR-SA1"
- .format(self.restconf_baseurl))
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
self.assertEqual(
def test_02_get_portmapping_CLIENT1(self):
url = ("{}/config/transportpce-portmapping:network/"
"nodes/SPDR-SA1/mapping/XPDR1-CLIENT1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
self.assertIn(
'logical-connection-point': 'XPDR1-CLIENT1',
'port-direction': 'bidirectional',
'port-qual': 'xpdr-client',
- 'lcp-hash-val': '8b3efff522736722500b5e68fb6e696e'},
+ 'lcp-hash-val': 'AIg960BwzGKe'},
res['mapping'])
def test_03_get_portmapping_NETWORK1(self):
url = ("{}/config/transportpce-portmapping:network/"
"nodes/SPDR-SA1/mapping/XPDR1-NETWORK1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
self.assertIn(
"port-qual": "xpdr-network",
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
- 'lcp-hash-val': '1021db8d2affe7386705c438c67ea21f'},
+ 'lcp-hash-val': 'AM7VlW5NpPm3'},
res['mapping'])
def test_04_service_path_create_OCH_OTU4(self):
- url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service_ODU4",
"wave-number": "1",
"nodes": [
{"node-id": "SPDR-SA1",
"dest-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
def test_05_get_portmapping_NETWORK1(self):
url = ("{}/config/transportpce-portmapping:network/"
"nodes/SPDR-SA1/mapping/XPDR1-NETWORK1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
self.assertIn(
"port-qual": "xpdr-network",
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
- "lcp-hash-val": "1021db8d2affe7386705c438c67ea21f"},
+ "lcp-hash-val": "AM7VlW5NpPm3"},
res['mapping'])
def test_06_check_interface_och(self):
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-OTU"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
input_dict = {'name': 'XPDR1-NETWORK1-OTU',
res['interface'][0]['org-openroadm-otn-otu-interfaces:otu'])
def test_08_otn_service_path_create_ODU4(self):
- url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service_ODU4",
"operation": "create",
"nodes": [
{"node-id": "SPDR-SA1",
"network-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
def test_09_get_portmapping_NETWORK1(self):
url = ("{}/config/transportpce-portmapping:network/"
"nodes/SPDR-SA1/mapping/XPDR1-NETWORK1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
self.assertIn(
"supporting-circuit-pack-name": "CP1-CFP0",
"xponder-type": "mpdr",
"supporting-odu4": "XPDR1-NETWORK1-ODU4",
- "lcp-hash-val": "1021db8d2affe7386705c438c67ea21f"
+ "lcp-hash-val": "AM7VlW5NpPm3"
},
res['mapping'])
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-ODU4"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU4', 'administrative-state': 'inService',
res['interface'][0]['org-openroadm-otn-odu-interfaces:odu']['opu'])
def test_11_otn_service_path_create_10GE(self):
- url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service1",
"operation": "create",
{"node-id": "SPDR-SA1",
"client-tp": "XPDR1-CLIENT1",
"network-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-CLIENT1-ETHERNET10G"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
input_dict = {'name': 'XPDR1-CLIENT1-ETHERNET10G',
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-CLIENT1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
input_dict_1 = {'name': 'XPDR1-NETWORK1-ODU2e-service1', 'administrative-state': 'inService',
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"odu-connection/XPDR1-CLIENT1-ODU2e-service1-x-XPDR1-NETWORK1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
input_dict_1 = {
res['odu-connection'][0]['source'])
def test_16_otn_service_path_delete_10GE(self):
- url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service1",
"operation": "delete",
{"node-id": "SPDR-SA1",
"client-tp": "XPDR1-CLIENT1",
"network-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"odu-connection/XPDR1-CLIENT1-ODU2e-service1-x-XPDR1-NETWORK1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_18_check_no_interface_ODU2E_NETWORK(self):
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_19_check_no_interface_ODU2E_CLIENT(self):
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-CLIENT1-ODU2e-service1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_20_check_no_interface_10GE_CLIENT(self):
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-CLIENT1-ETHERNET10G"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_21_otn_service_path_delete_ODU4(self):
- url = "{}/operations/transportpce-device-renderer:otn-service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:otn-service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service_ODU4",
"operation": "delete",
"nodes": [
{"node-id": "SPDR-SA1",
"network-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-ODU4"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_23_service_path_delete_OCH_OTU4(self):
- url = "{}/operations/transportpce-device-renderer:service-path".format(self.restconf_baseurl)
+ url = "{}/operations/transportpce-device-renderer:service-path".format(test_utils.RESTCONF_BASE_URL)
data = {"renderer:input": {
"service-name": "service_OTU4",
"wave-number": "1",
"nodes": [
{"node-id": "SPDR-SA1",
"dest-tp": "XPDR1-NETWORK1"}]}}
- headers = {'content-type': 'application/json'}
response = requests.request(
"POST", url, data=json.dumps(data),
- headers=headers, auth=('admin', 'admin'))
+ headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
time.sleep(3)
self.assertEqual(response.status_code, requests.codes.ok)
res = response.json()
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-OTU"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_25_check_no_interface_OCH(self):
url = ("{}/config/network-topology:network-topology/topology/topology-netconf/"
"node/SPDR-SA1/yang-ext:mount/org-openroadm-device:org-openroadm-device/"
"interface/XPDR1-NETWORK1-1"
- .format(self.restconf_baseurl))
- headers = {'content-type': 'application/json'}
+ .format(test_utils.RESTCONF_BASE_URL))
response = requests.request(
- "GET", url, headers=headers, auth=('admin', 'admin'))
+ "GET", url, headers=test_utils.TYPE_APPLICATION_JSON, auth=(test_utils.ODL_LOGIN, test_utils.ODL_PWD))
self.assertEqual(response.status_code, requests.codes.not_found)
def test_26_disconnect_SPDR_SA1(self):
- url = ("{}/config/network-topology:"
- "network-topology/topology/topology-netconf/node/SPDR-SA1"
- .format(self.restconf_baseurl))
- data = {}
- headers = {'content-type': 'application/json'}
- response = requests.request(
- "DELETE", url, data=json.dumps(data), headers=headers,
- auth=('admin', 'admin'))
- self.assertEqual(response.status_code, requests.codes.ok)
+ response = test_utils.unmount_device("SPDR-SA1")
+ self.assertEqual(response.status_code, requests.codes.ok, test_utils.CODE_SHOULD_BE_200)
if __name__ == "__main__":