fix some minor issues
[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-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", "2.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, "17840", os.path.join(samples_directory, "oper-XPDRA.xml")],
18                 stdout=outfile, stderr=outfile)
19
20
21 def start_roadma_honeynode():
22     if os.path.isfile(honeynode_executable):
23         with open('honeynode2.log', 'w') as outfile:
24             return subprocess.Popen(
25                 [honeynode_executable, "17841", os.path.join(samples_directory, "oper-ROADMA.xml")],
26                 stdout=outfile, stderr=outfile)
27
28
29 def start_roadmb_honeynode():
30     if os.path.isfile(honeynode_executable):
31         with open('honeynode5.log', 'w') as outfile:
32             return subprocess.Popen(
33                 [honeynode_executable, "17842", os.path.join(samples_directory, "oper-ROADMB.xml")],
34                 stdout=outfile, stderr=outfile)
35
36
37 def start_roadmc_honeynode():
38     if os.path.isfile(honeynode_executable):
39         with open('honeynode3.log', 'w') as outfile:
40             return subprocess.Popen(
41                 [honeynode_executable, "17843", os.path.join(samples_directory, "oper-ROADMC.xml")],
42                 stdout=outfile, stderr=outfile)
43
44
45 def start_xpdrc_honeynode():
46     if os.path.isfile(honeynode_executable):
47         with open('honeynode4.log', 'w') as outfile:
48             return subprocess.Popen(
49                 [honeynode_executable, "17844", os.path.join(samples_directory, "oper-XPDRC.xml")],
50                 stdout=outfile, stderr=outfile)
51
52
53 def start_spdra_honeynode():
54     if os.path.isfile(honeynode_executable):
55         with open('honeynode6.log', 'w') as outfile:
56             return subprocess.Popen(
57                 [honeynode_executable, "17845", os.path.join(samples_directory, "oper-SPDRAv2.xml")],
58                 stdout=outfile, stderr=outfile)
59
60
61 def start_tpce():
62     if "USE_LIGHTY" in os.environ and os.environ['USE_LIGHTY'] == 'True':
63         print("starting LIGHTY.IO TransportPCE build...")
64         executable = os.path.join(
65             os.path.dirname(os.path.realpath(__file__)),
66             "..", "..", "..", "lighty", "target", "lighty-transportpce-12.0.0-SNAPSHOT",
67             "clean-start-controller.sh")
68         with open('odl.log', 'w') as outfile:
69             return subprocess.Popen(
70                 ["sh", executable], stdout=outfile, stderr=outfile,
71                 stdin=open(os.devnull))
72     else:
73         print("starting KARAF TransportPCE build...")
74         executable = os.path.join(
75             os.path.dirname(os.path.realpath(__file__)),
76             "..", "..", "..", "karaf", "target", "assembly", "bin", "karaf")
77         with open('odl.log', 'w') as outfile:
78             return subprocess.Popen(
79                 ["sh", executable, "server"], stdout=outfile, stderr=outfile,
80                 stdin=open(os.devnull))