Lighty support in Magnesium
[transportpce.git] / tests / transportpce_tests / 2.2.1 / test_utils.py
1 import os
2 import subprocess
3
4 honeynode_executable = os.path.join(
5     os.path.dirname(os.path.realpath(__file__)),
6     "..", "..", "honeynode", "2.2.1", "honeynode-simulator", "honeycomb-tpce")
7 samples_directory = os.path.join(
8     os.path.dirname(os.path.realpath(__file__)),
9     "..", "..", "sample_configs", "openroadm", "2.2.1")
10
11
12 def start_xpdra_honeynode():
13     if os.path.isfile(honeynode_executable):
14         with open('honeynode1.log', 'w') as outfile:
15             return subprocess.Popen(
16                 [honeynode_executable, "17840", os.path.join(samples_directory, "oper-XPDRA.xml")],
17                 stdout=outfile, stderr=outfile)
18
19
20 def start_roadma_honeynode():
21     if os.path.isfile(honeynode_executable):
22         with open('honeynode2.log', 'w') as outfile:
23             return subprocess.Popen(
24                 [honeynode_executable, "17841", os.path.join(samples_directory, "oper-ROADMA.xml")],
25                 stdout=outfile, stderr=outfile)
26
27
28 def start_roadmb_honeynode():
29     if os.path.isfile(honeynode_executable):
30         with open('honeynode5.log', 'w') as outfile:
31             return subprocess.Popen(
32                 [honeynode_executable, "17842", os.path.join(samples_directory, "oper-ROADMB.xml")],
33                 stdout=outfile, stderr=outfile)
34
35
36 def start_roadmc_honeynode():
37     if os.path.isfile(honeynode_executable):
38         with open('honeynode3.log', 'w') as outfile:
39             return subprocess.Popen(
40                 [honeynode_executable, "17843", os.path.join(samples_directory, "oper-ROADMC.xml")],
41                 stdout=outfile, stderr=outfile)
42
43
44 def start_xpdrc_honeynode():
45     if os.path.isfile(honeynode_executable):
46         with open('honeynode4.log', 'w') as outfile:
47             return subprocess.Popen(
48                 [honeynode_executable, "17844", os.path.join(samples_directory, "oper-XPDRC.xml")],
49                 stdout=outfile, stderr=outfile)
50
51
52 def start_spdra_honeynode():
53     if os.path.isfile(honeynode_executable):
54         with open('honeynode6.log', 'w') as outfile:
55             return subprocess.Popen(
56                 [honeynode_executable, "17845", os.path.join(samples_directory, "oper-SPDRAv2.xml")],
57                 stdout=outfile, stderr=outfile)
58
59
60 def start_tpce():
61     if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True':
62         print("starting LIGHTY.IO TransportPCE build...")
63         executable = os.path.join(
64             os.path.dirname(os.path.realpath(__file__)),
65             "..", "..", "..", "lighty", "target", "tpce",
66             "clean-start-controller.sh")
67         with open('odl.log', 'w') as outfile:
68             return subprocess.Popen(
69                 ["sh", executable], stdout=outfile, stderr=outfile,
70                 stdin=open(os.devnull))
71     else:
72         print("starting KARAF TransportPCE build...")
73         executable = os.path.join(
74             os.path.dirname(os.path.realpath(__file__)),
75             "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf")
76         with open('odl.log', 'w') as outfile:
77             return subprocess.Popen(
78                 ["sh", executable, "server"], stdout=outfile, stderr=outfile,
79                 stdin=open(os.devnull))