b66ea72adc02ecf160b0dedc5399dbcdd0147fe0
[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 def start_xpdra_honeynode():
12     if os.path.isfile(honeynode_executable):
13         with open('honeynode1.log', 'w') as outfile:
14             return subprocess.Popen(
15                 [honeynode_executable, "17830", os.path.join(samples_directory,"oper-XPDRA.xml")],
16                 stdout=outfile, stderr=outfile)
17
18 def start_roadma_full_honeynode():
19     if os.path.isfile(honeynode_executable):
20         with open('honeynode2.log', 'w') as outfile:
21             return subprocess.Popen(
22                 [honeynode_executable, "17821", os.path.join(samples_directory,"oper-ROADMA-full.xml")],
23                 stdout=outfile, stderr=outfile)
24
25 def start_roadma_honeynode():
26     if os.path.isfile(honeynode_executable):
27         with open('honeynode2.log', 'w') as outfile:
28             return subprocess.Popen(
29                 [honeynode_executable, "17831", os.path.join(samples_directory,"oper-ROADMA.xml")],
30                 stdout=outfile, stderr=outfile)
31
32 def start_roadmb_honeynode():
33     if os.path.isfile(honeynode_executable):
34         with open('honeynode3.log', 'w') as outfile:
35             return subprocess.Popen(
36                 [honeynode_executable, "17832", os.path.join(samples_directory,"oper-ROADMB.xml")],
37                 stdout=outfile, stderr=outfile)
38
39 def start_roadmc_full_honeynode():
40     if os.path.isfile(honeynode_executable):
41         with open('honeynode3.log', 'w') as outfile:
42             return subprocess.Popen(
43                 [honeynode_executable, "17823", os.path.join(samples_directory,"oper-ROADMC-full.xml")],
44                 stdout=outfile, stderr=outfile)
45
46 def start_roadmc_honeynode():
47     if os.path.isfile(honeynode_executable):
48         with open('honeynode4.log', 'w') as outfile:
49             return subprocess.Popen(
50                 [honeynode_executable, "17833", os.path.join(samples_directory,"oper-ROADMC.xml")],
51                 stdout=outfile, stderr=outfile)
52
53 def start_xpdrc_honeynode():
54     if os.path.isfile(honeynode_executable):
55         with open('honeynode4.log', 'w') as outfile:
56             return subprocess.Popen(
57                 [honeynode_executable, "17834", os.path.join(samples_directory,"oper-XPDRC.xml")],
58                 stdout=outfile, stderr=outfile)
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", "lighty-transportpce-12.0.0-SNAPSHOT",
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))