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