-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_l1patch.py
36 lines (33 loc) · 993 Bytes
/
run_l1patch.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
#!/usr/bin/python
import json
import argparse
import patch_flowgen
if __name__ == "__main__":
# parse options
arg_parser = argparse.ArgumentParser(
description="Create L1patch Flow Rule (REST json)"
)
arg_parser.add_argument(
'-p', '--physical',
required=True,
type=str, metavar='JSON',
help="Physical topology information file"
)
arg_parser.add_argument(
'-l', '--logical',
required=True,
type=str, metavar='JSON',
help="Logical topology (wire) information file"
)
arg_parser.add_argument(
'-m', '--mode',
required=True,
nargs=1, choices=['all', 'exclusive', 'shared']
)
args = arg_parser.parse_args()
# generate flow rules for OFC REST
flow_rule_generator = patch_flowgen.FlowRuleGenerator(
args.physical, args.logical
)
flow_rule = flow_rule_generator.generate_flow_rule(args.mode[0])
print json.dumps(flow_rule, indent=2)