4 from subprocess import *
5 from subprocess import STDOUT
10 parser = argparse.ArgumentParser()
13 help='Bootstrapping the system',
18 help='IP of the VES collector',
23 help='IP address range beginning',
29 help='Cleaning work-dirs',
34 help='Starting instances',
44 help='Stopping instances',
47 args = parser.parse_args()
49 if args.bootstrap and args.ipstart and args.ipves:
52 for i in range(int(args.bootstrap)):
53 print("PNF simulator instance: " + str(i) + ".")
55 ip_subnet = ipaddress.ip_address(args.ipstart) + int(0 + (i * 16))
56 print("\tIp Subnet:" + str(ip_subnet))
57 # The IP ranges are in distance of 16 compared to each other.
58 # This is matching the /28 subnet mask used in the dockerfile inside.
60 ip_gw = ipaddress.ip_address(args.ipstart) + int(1 + (i * 16))
61 print("\tIP Gateway:" + str(ip_gw))
63 IpPnfSim = ipaddress.ip_address(args.ipstart) + int(2 + (i * 16))
64 print("\tIp Pnf SIM:" + str(IpPnfSim))
66 IpFtps = ipaddress.ip_address(args.ipstart) + int(3 + (i * 16))
67 print("\tIp Ftps: " + str(IpFtps))
69 IpSftp = ipaddress.ip_address(args.ipstart) + int(4 + (i * 16))
70 print("\tIp Sftp:" + str(IpSftp))
72 foldername = "pnf-sim-lw-" + str(i)
73 completed = subprocess.run('mkdir ' + foldername, shell=True)
74 print('\tCreating folder:', completed.stdout)
75 completed = subprocess.run(
76 'cp -r pnf-sim-lightweight/* ' +
79 print('\tCloning folder:', completed.stdout)
81 composercmd = "./simulator.sh compose " +\
83 str(ip_subnet) + " " +\
85 str(args.ipves) + " " +\
86 str(IpPnfSim) + " " +\
90 completed = subprocess.run(
96 print('Cloning:', completed.stdout)
101 completed = subprocess.run('rm -rf ./pnf-sim-lw-*', shell=True)
102 print('Deleting:', completed.stdout)
107 for i in range(int(args.start)):
108 foldername = "pnf-sim-lw-" + str(i)
110 completed = subprocess.run(
113 "; bash -x ./simulator.sh start",
115 print('Starting:', completed.stdout)
121 for i in range(int(args.status)):
122 foldername = "pnf-sim-lw-" + str(i)
124 completed = subprocess.run(
127 "; ./simulator.sh status",
129 print('Status:', completed.stdout)
132 for i in range(int(args.stop)):
133 foldername = "pnf-sim-lw-" + str(i)
135 completed = subprocess.run(
138 "; ./simulator.sh stop " + str(i),
140 print('Stopping:', completed.stdout)
143 print("No instruction was defined")