--- /dev/null
+#!/bin/sh
+
+#set -x
+
+#check if curl exists
+if ! [ -x "$(command -v curl)" ];then
+ echo "curl is not installed." >&2
+ exit 1
+fi
+#check if unzip exists
+if ! [ -x "$(command -v unzip)" ];then
+ echo "unzip is not installed." >&2
+ exit 1
+fi
+
+PLUGIN_VERSION=18.1.0.7
+TARGET_DIR=$(dirname $0)/lightynode
+INSTALL_DIR=$TARGET_DIR/lightynode-openroadm-device
+ARTIFACT_ZIPFILE=$TARGET_DIR/artifact.zip
+TARGET_URL="https://gitlab.com/api/v4/projects/36076125/packages/maven/io/lighty/transportpce/netconf/device/lighty-openroadm-device/$PLUGIN_VERSION/lighty-openroadm-device-$PLUGIN_VERSION-bin.zip"
+
+#clean lightynode install directory
+if [ -d "$INSTALL_DIR" ];then
+ echo "Removing $INSTALL_DIR directory"
+ rm -rf $INSTALL_DIR
+fi
+
+#download lightynode and install it
+#complete source code can be found at https://gitlab.com/Orange-OpenSource/lfn/odl/lightynode-simulator.git
+echo "Installing lightynode device to $INSTALL_DIR directory "
+curl --retry-delay 10 --retry 3 -sS --location --request GET $TARGET_URL -o $ARTIFACT_ZIPFILE || exit 2
+unzip -q $ARTIFACT_ZIPFILE -d $TARGET_DIR
+rm -f $ARTIFACT_ZIPFILE
+mv $TARGET_DIR/lighty-openroadm-device-$PLUGIN_VERSION $INSTALL_DIR
+
+#update 1.2.1 openroadm device configuration samples to be compliant with 1.2.1
+#device models ("multi-wavelegnth" instead of "multi-wavelength" whose typo has been solved with 2.2.1 device models)
+sed -i_ 's/multi-wavelength/multi-wavelegnth/g' $(dirname $0)/sample_configs/openroadm/1.2.1/oper-ROADM*.xml
SIMS = simulators.SIMS
HONEYNODE_OK_START_MSG = 'Netconf SSH endpoint started successfully at 0.0.0.0'
+LIGHTYNODE_OK_START_MSG = 'Data tree change listeners registered'
KARAF_OK_START_MSG = "Transportpce controller started"
LIGHTY_OK_START_MSG = re.escape("lighty.io and RESTCONF-NETCONF started")
#
+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', encoding='utf-8') as outfile:
+ return subprocess.Popen(
+ [executable, SIMS[sim]['port'], os.path.join(sample_directory, SIMS[sim]['configfile'])],
+ stdout=outfile, stderr=outfile)
+ return None
+
+
+def start_lightynode(log_file: str, sim):
+ executable = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ '..', '..', 'lightynode', 'lightynode-openroadm-device', 'start-device.sh')
+ 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', encoding='utf-8') as outfile:
+ return subprocess.Popen(
+ [executable, "-v" + sim[1], "-p" + SIMS[sim]['port'], "-f" + os.path.join(sample_directory,
+ SIMS[sim]['configfile'])],
+ stdout=outfile, stderr=outfile)
+ return None
+
+
def start_sims(sims_list):
+ if 'USE_SIMS' in os.environ:
+ sims_to_use = os.environ['USE_SIMS']
+ print(os.environ['USE_SIMS'] + ' ' + sims_to_use)
+ else:
+ sims_to_use = 'honeynode'
+ if sims_to_use == 'None':
+ return None
+ if sims_to_use == 'lightynode':
+ start_msg = LIGHTYNODE_OK_START_MSG
+ start_method = start_lightynode
+ print("lightynode used")
+ else:
+ start_msg = HONEYNODE_OK_START_MSG
+ start_method = start_honeynode
for sim in sims_list:
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):
+ process = start_method(log_file, sim)
+ if wait_until_log_contains(log_file, start_msg, 100):
print('simulator for ' + sim[0] + ' started')
else:
print('simulator for ' + sim[0] + ' failed to start')
process.send_signal(signal.SIGINT)
-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', encoding='utf-8') as outfile:
- return subprocess.Popen(
- [executable, SIMS[sim]['port'], os.path.join(sample_directory, SIMS[sim]['configfile'])],
- stdout=outfile, stderr=outfile)
- return None
-
-
def wait_until_log_contains(log_file, regexp, time_to_wait=60):
# pylint: disable=lost-exception
# pylint: disable=consider-using-with