-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_cloudlet_membership.py
42 lines (40 loc) · 1.44 KB
/
create_cloudlet_membership.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import argparse
import os.path
import sys
from utils import savePlot, isfloat, load_Topology, associateWithCloudlets
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Generate Topology")
parser.add_argument('--path', help='path to topology csv')
parser.add_argument('--name', help='naming of the topology output files')
parser.add_argument('--width', help='cloudlet width in km')
parser.add_argument('--height', help='cloudlet height in km')
args = parser.parse_args()
if args.width is None:
print("Please set --width!")
sys.exit()
if args.height is None:
print("Please set --height!")
sys.exit()
if not isfloat(args.width):
print("width must be type: float!")
sys.exit()
if not isfloat(args.height):
print("height must be type: float!")
sys.exit()
if args.path is None:
print("Please set --path!")
sys.exit()
if args.name is None:
print("Please set --name!")
sys.exit()
if os.path.isfile(args.path):
if not args.path.endswith('.csv'):
print("File must has a csv extension!")
else:
df = load_Topology(args.path)
# savePlot(df, "output", args.name)
df = associateWithCloudlets(df, float(args.width), float(args.height))
savePlot(df, "output", args.name)
else:
print("File does not exist!")
sys.exit()