import simulators
SIMS = simulators.SIMS
-HONEYNODE_EXECUTABLE = simulators.HONEYNODE_EXECUTABLE
-SAMPLES_DIRECTORY = simulators.SAMPLES_DIRECTORY
HONEYNODE_OK_START_MSG = "Netconf SSH endpoint started successfully at 0.0.0.0"
KARAF_OK_START_MSG = re.escape(
URL_CONFIG_ORDM_NET = "{}/config/ietf-network:networks/network/openroadm-network/"
URL_PORTMAPPING = "{}/config/transportpce-portmapping:network/nodes/"
URL_OPER_SERV_LIST = "{}/operational/org-openroadm-service:service-list/"
+URL_GET_NBINOTIFICATIONS_SERV = "{}/operations/nbi-notifications:get-notifications-service/"
URL_SERV_CREATE = "{}/operations/org-openroadm-service:service-create"
URL_SERV_DELETE = "{}/operations/org-openroadm-service:service-delete"
URL_SERVICE_PATH = "{}/operations/transportpce-device-renderer:service-path"
CODE_SHOULD_BE_200 = 'Http status code should be 200'
CODE_SHOULD_BE_201 = 'Http status code should be 201'
-LOG_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
-
+SIM_LOG_DIRECTORY = os.path.join(os.path.dirname(os.path.realpath(__file__)), "log")
KARAF_LOG = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "..", "karaf", "target", "assembly", "data", "log", "karaf.log")
def start_sims(sims_list):
for sim in sims_list:
- print("starting simulator for " + sim + "...")
- log_file = os.path.join(LOG_DIRECTORY, SIMS[sim]['logfile'])
- process = start_honeynode(log_file, SIMS[sim]['port'], SIMS[sim]['configfile'])
+ print("starting simulator " + sim[0] + " in OpenROADM device version " + sim[1] + "...")
+ log_file = os.path.join(SIM_LOG_DIRECTORY, SIMS[sim]['logfile'])
+ process = start_honeynode(log_file, sim)
if wait_until_log_contains(log_file, HONEYNODE_OK_START_MSG, 100):
- print("simulator for " + sim + " started")
+ print("simulator for " + sim[0] + " started")
else:
- print("simulator for " + sim + " failed to start")
+ print("simulator for " + sim[0] + " failed to start")
shutdown_process(process)
for pid in process_list:
shutdown_process(pid)
else:
process = start_karaf()
start_msg = KARAF_OK_START_MSG
- if wait_until_log_contains(TPCE_LOG, start_msg, time_to_wait=60):
+ if wait_until_log_contains(TPCE_LOG, start_msg, time_to_wait=120):
print("OpenDaylight started !")
else:
print("OpenDaylight failed to start !")
os.path.dirname(os.path.realpath(__file__)),
"..", "..", "..", "karaf", "target", "assembly", "bin", "client")
return subprocess.run([executable],
- input='feature:install ' + feature_name + '\n feature:list | grep tapi \n logout \n',
+ input='feature:install ' + feature_name + '\n feature:list | grep '
+ + feature_name + ' \n logout \n',
universal_newlines=True, check=False)
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_XML,
auth=(ODL_LOGIN, ODL_PWD))
+def put_jsonrequest(url, data):
+ return requests.request(
+ "PUT", url.format(RESTCONF_BASE_URL),
+ data=data,
+ headers=TYPE_APPLICATION_JSON,
+ auth=(ODL_LOGIN, ODL_PWD))
def rawput_request(url, data):
return requests.request(
return get_request(url)
+def get_notifications_service_request(attr):
+ return post_request(URL_GET_NBINOTIFICATIONS_SERV, attr)
+
+
def get_service_list_request(suffix: str):
url = URL_OPER_SERV_LIST + suffix
return get_request(url)
return post_request(URL_SERV_DELETE, attr)
-def service_path_request(operation: str, servicename: str, wavenumber: str, nodes):
+def service_path_request(operation: str, servicename: str, wavenumber: str, nodes, centerfreq: str,
+ slotwidth: int, minfreq: float, maxfreq: float, lowerslotnumber: int,
+ higherslotnumber: int):
attr = {"renderer:input": {
"renderer:service-name": servicename,
"renderer:wave-number": wavenumber,
- "renderer:modulation-format": "qpsk",
+ "renderer:modulation-format": "dp-qpsk",
"renderer:operation": operation,
- "renderer:nodes": nodes}}
+ "renderer:nodes": nodes,
+ "renderer:center-freq": centerfreq,
+ "renderer:width": slotwidth,
+ "renderer:min-freq": minfreq,
+ "renderer:max-freq": maxfreq,
+ "renderer:lower-spectral-slot-number": lowerslotnumber,
+ "renderer:higher-spectral-slot-number": higherslotnumber}}
return post_request(URL_SERVICE_PATH, attr)
process.send_signal(signal.SIGINT)
-def start_honeynode(log_file: str, node_port: str, node_config_file_name: str):
- if os.path.isfile(HONEYNODE_EXECUTABLE):
+def start_honeynode(log_file: str, sim):
+ executable = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "honeynode", sim[1], "honeynode-simulator", "honeycomb-tpce")
+ sample_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "sample_configs", "openroadm", sim[1])
+ if os.path.isfile(executable):
with open(log_file, 'w') as outfile:
return subprocess.Popen(
- [HONEYNODE_EXECUTABLE, node_port, os.path.join(SAMPLES_DIRECTORY, node_config_file_name)],
+ [executable, SIMS[sim]['port'], os.path.join(sample_directory, SIMS[sim]['configfile'])],
stdout=outfile, stderr=outfile)
return None
def __exit__(self, type, value, traceback):
# pylint: disable=W0622
signal.alarm(0)
-