4 from subprocess import *
5 from subprocess import STDOUT
10 parser = argparse.ArgumentParser()
13 help='Bootstrapping the system',
18 help='Trigger one single VES event from each simulator',
23 help='IP of the VES collector',
28 help='Visible IP of the file server (SFTP/FTPS) to be included in the VES event',
33 help='IP address range beginning',
39 help='Cleaning work-dirs',
44 help='Starting instances',
54 help='Stopping instances',
57 args = parser.parse_args()
59 if args.bootstrap and args.ipstart and args.ipves:
64 for i in range(int(args.bootstrap)):
65 print("PNF simulator instance: " + str(i) + ".")
67 ip_subnet = ipaddress.ip_address(args.ipstart) + int(0 + (i * 16))
68 print("\tIp Subnet:" + str(ip_subnet))
69 # The IP ranges are in distance of 16 compared to each other.
70 # This is matching the /28 subnet mask used in the dockerfile inside.
72 ip_gw = ipaddress.ip_address(args.ipstart) + int(1 + (i * 16))
73 print("\tIP Gateway:" + str(ip_gw))
75 IpPnfSim = ipaddress.ip_address(args.ipstart) + int(2 + (i * 16))
76 print("\tIp Pnf SIM:" + str(IpPnfSim))
78 IpFileServer = args.ipfileserver
81 PortSftp=start_port +1
82 PortFtps=start_port +2
84 IpFtps = ipaddress.ip_address(args.ipstart) + int(3 + (i * 16))
85 print("\tIp Ftps: " + str(IpFtps))
87 IpSftp = ipaddress.ip_address(args.ipstart) + int(4 + (i * 16))
88 print("\tIp Sftp:" + str(IpSftp))
90 foldername = "pnf-sim-lw-" + str(i)
91 completed = subprocess.run('mkdir ' + foldername, shell=True)
92 print('\tCreating folder:', completed.stdout)
93 completed = subprocess.run(
94 'cp -r pnf-sim-lightweight/* ' +
97 print('\tCloning folder:', completed.stdout)
99 composercmd = "./simulator.sh compose " +\
101 str(ip_subnet) + " " +\
103 str(args.ipves) + " " +\
104 str(IpPnfSim) + " " +\
105 str(IpFileServer) + " " +\
106 str(PortSftp) + " " +\
107 str(PortFtps) + " " +\
111 completed = subprocess.run(
117 print('Cloning:', completed.stdout)
122 completed = subprocess.run('rm -rf ./pnf-sim-lw-*', shell=True)
123 print('Deleting:', completed.stdout)
128 for i in range(int(args.start)):
129 foldername = "pnf-sim-lw-" + str(i)
131 completed = subprocess.run(
134 "; bash -x ./simulator.sh start",
136 print('Starting:', completed.stdout)
142 for i in range(int(args.status)):
143 foldername = "pnf-sim-lw-" + str(i)
145 completed = subprocess.run(
148 "; ./simulator.sh status",
150 print('Status:', completed.stdout)
153 for i in range(int(args.stop)):
154 foldername = "pnf-sim-lw-" + str(i)
156 completed = subprocess.run(
159 "; ./simulator.sh stop " + str(i),
161 print('Stopping:', completed.stdout)
165 print("Triggering VES sending:")
167 for i in range(int(args.trigger)):
168 foldername = "pnf-sim-lw-" + str(i)
170 completed = subprocess.run(
173 "; ./simulator.sh trigger-simulator",
175 print('Status:', completed.stdout)
178 print("No instruction was defined")