+ process = start_karaf()
+ if wait_until_log_contains(karaf_log, KARAF_OK_START_MSG, time_to_wait=60):
+ print("opendaylight started")
+ else:
+ print("opendaylight failed to start")
+ shutdown_process(process)
+ exit(1)
+ return process
+
+
+def start_karaf():
+ print("starting KARAF TransportPCE build...")
+ executable = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf")
+ with open('odl.log', 'w') as outfile:
+ return subprocess.Popen(
+ ["sh", executable, "server"], stdout=outfile, stderr=outfile, stdin=None)
+
+
+def start_lighty():
+ print("starting LIGHTY.IO TransportPCE build...")
+ executable = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "..", "lighty", "target", "tpce",
+ "clean-start-controller.sh")
+ with open('odl.log', 'w') as outfile:
+ return subprocess.Popen(
+ ["sh", executable], stdout=outfile, stderr=outfile, stdin=None)
+
+
+def install_karaf_feature(feature_name: str):
+ print("installing feature " + feature_name)
+ executable = os.path.join(
+ 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',
+ universal_newlines=True)
+
+
+def post_request(url, data, username, password):
+ return requests.request(
+ "POST", url, data=json.dumps(data),
+ headers=TYPE_APPLICATION_JSON, auth=(username, password))
+
+
+def put_request(url, data, username, password):
+ return requests.request(
+ "PUT", url, data=json.dumps(data), headers=TYPE_APPLICATION_JSON,
+ auth=(username, password))
+
+
+def delete_request(url, username, password):
+ return requests.request(
+ "DELETE", url, headers=TYPE_APPLICATION_JSON,
+ auth=(username, password))
+
+
+def generate_connect_data(node_id: str, node_port: str):
+ data = {"node": [{
+ "node-id": node_id,
+ "netconf-node-topology:username": "admin",
+ "netconf-node-topology:password": "admin",
+ "netconf-node-topology:host": "127.0.0.1",
+ "netconf-node-topology:port": node_port,
+ "netconf-node-topology:tcp-only": "false",
+ "netconf-node-topology:pass-through": {}}]}
+ return data
+
+
+def generate_link_data(xpdr_node: str, xpdr_num: str, network_num: str, rdm_node: str, srg_num: str,
+ termination_num: str):
+ data = {
+ "networkutils:input": {
+ "networkutils:links-input": {
+ "networkutils:xpdr-node": xpdr_node,
+ "networkutils:xpdr-num": xpdr_num,
+ "networkutils:network-num": network_num,
+ "networkutils:rdm-node": rdm_node,
+ "networkutils:srg-num": srg_num,
+ "networkutils:termination-point-num": termination_num
+ }
+ }
+ }
+ return data
+
+
+def shutdown_process(process):
+ if process is not None:
+ for child in psutil.Process(process.pid).children():
+ child.send_signal(signal.SIGINT)
+ child.wait()
+ 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):
+ with open(log_file, 'w') as outfile: