Lighty support in Magnesium
[transportpce.git] / tests / transportpce_tests / 1.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", "1.2.1", "honeynode-simulator", "honeycomb-tpce")
7 samples_directory = os.path.join(
8     os.path.dirname(os.path.realpath(__file__)),
9     "..", "..", "sample_configs", "openroadm", "1.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, "17830", os.path.join(samples_directory, "oper-XPDRA.xml")],
17                 stdout=outfile, stderr=outfile)
18
19
20 def start_roadma_full_honeynode():
21     if os.path.isfile(honeynode_executable):
22         with open('honeynode2.log', 'w') as outfile:
23             return subprocess.Popen(
24                 [honeynode_executable, "17821", os.path.join(samples_directory, "oper-ROADMA-full.xml")],
25                 stdout=outfile, stderr=outfile)
26
27
28 def start_roadma_honeynode():
29     if os.path.isfile(honeynode_executable):
30         with open('honeynode2.log', 'w') as outfile:
31             return subprocess.Popen(
32                 [honeynode_executable, "17831", os.path.join(samples_directory, "oper-ROADMA.xml")],
33                 stdout=outfile, stderr=outfile)
34
35
36 def start_roadmb_honeynode():
37     if os.path.isfile(honeynode_executable):
38         with open('honeynode3.log', 'w') as outfile:
39             return subprocess.Popen(
40                 [honeynode_executable, "17832", os.path.join(samples_directory, "oper-ROADMB.xml")],
41                 stdout=outfile, stderr=outfile)
42
43
44 def start_roadmc_full_honeynode():
45     if os.path.isfile(honeynode_executable):
46         with open('honeynode3.log', 'w') as outfile:
47             return subprocess.Popen(
48                 [honeynode_executable, "17823", os.path.join(samples_directory, "oper-ROADMC-full.xml")],
49                 stdout=outfile, stderr=outfile)
50
51
52 def start_roadmc_honeynode():
53     if os.path.isfile(honeynode_executable):
54         with open('honeynode4.log', 'w') as outfile:
55             return subprocess.Popen(
56                 [honeynode_executable, "17833", os.path.join(samples_directory, "oper-ROADMC.xml")],
57                 stdout=outfile, stderr=outfile)
58
59
60 def start_xpdrc_honeynode():
61     if os.path.isfile(honeynode_executable):
62         with open('honeynode4.log', 'w') as outfile:
63             return subprocess.Popen(
64                 [honeynode_executable, "17834", os.path.join(samples_directory, "oper-XPDRC.xml")],
65                 stdout=outfile, stderr=outfile)
66
67
68 def start_tpce():
69     if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True':
70         print("starting LIGHTY.IO TransportPCE build...")
71         executable = os.path.join(
72             os.path.dirname(os.path.realpath(__file__)),
73             "..", "..", "..", "lighty", "target", "tpce",
74             "clean-start-controller.sh")
75         with open('odl.log', 'w') as outfile:
76             return subprocess.Popen(
77                 ["sh", executable], stdout=outfile, stderr=outfile,
78                 stdin=open(os.devnull))
79     else:
80         print("starting KARAF TransportPCE build...")
81         executable = os.path.join(
82             os.path.dirname(os.path.realpath(__file__)),
83             "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf")
84         with open('odl.log', 'w') as outfile:
85             return subprocess.Popen(
86                 ["sh", executable, "server"], stdout=outfile, stderr=outfile,
87                 stdin=open(os.devnull))