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