forked from scionproto/scion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
executable file
·97 lines (90 loc) · 4.1 KB
/
generator.py
File metadata and controls
executable file
·97 lines (90 loc) · 4.1 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/python3
# Copyright 2014 ETH Zurich
# Copyright 2018 ETH Zurich, Anapaya Systems
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
:mod:`generator` --- SCION topology generator
=============================================
"""
# Stdlib
import argparse
# SCION
from lib.defines import (
DEFAULT_SEGMENT_TTL,
GEN_PATH,
)
from topology.config import (
ConfigGenerator,
ConfigGenArgs,
DEFAULT_BEACON_SERVER,
DEFAULT_CERTIFICATE_SERVER,
DEFAULT_PATH_POLICY_FILE,
DEFAULT_PATH_SERVER,
DEFAULT_SCIOND,
DEFAULT_TOPOLOGY_FILE,
GENERATE_BIND_ADDRESS,
)
def add_arguments(parser):
parser.add_argument('-6', '--ipv6', action='store_true',
help='Generate IPv6 addresses')
parser.add_argument('-c', '--topo-config', default=DEFAULT_TOPOLOGY_FILE,
help='Default topology config')
parser.add_argument('-p', '--path-policy', default=DEFAULT_PATH_POLICY_FILE,
help='Path policy file')
parser.add_argument('-d', '--docker', action='store_true',
help='Create a docker-compose configuration')
parser.add_argument('-n', '--network',
help='Network to create subnets in (E.g. "127.0.0.0/8"')
parser.add_argument('-o', '--output-dir', default=GEN_PATH,
help='Output directory')
parser.add_argument('-b', '--bind-addr', default=GENERATE_BIND_ADDRESS,
help='Generate bind addresses (E.g. "192.168.0.0/16"')
parser.add_argument('-t', '--trace', action='store_true',
help='Enable TRACE level file logging in Go services')
parser.add_argument('--pseg-ttl', type=int, default=DEFAULT_SEGMENT_TTL,
help='Path segment TTL (in seconds)')
parser.add_argument('-bs', '--beacon-server', default=DEFAULT_BEACON_SERVER,
help='Certificate Server implementation to use ("go" or "py")')
parser.add_argument('-cs', '--cert-server', default=DEFAULT_CERTIFICATE_SERVER,
help='Certificate Server implementation to use ("go" or "py")')
parser.add_argument('-sd', '--sciond', default=DEFAULT_SCIOND,
help='SCIOND implementation to use ("go" or "py")')
parser.add_argument('-ps', '--path-server', default=DEFAULT_PATH_SERVER,
help='Path Server implementation to use ("go or "py")')
parser.add_argument('-ds', '--discovery', action='store_true',
help='Generate discovery service')
parser.add_argument('-f', '--svcfrac', type=float, default=0.4,
help='Attempt SVC resolution in RPC calls for a fraction of\
available timeout')
parser.add_argument('--random-ifids', action='store_true',
help='Generate random IFIDs')
parser.add_argument('--in-docker', action='store_true',
help='Set if running in a docker container')
parser.add_argument('--docker-registry', help='Specify docker registry to pull images from')
parser.add_argument('--image-tag', help='Docker image tag')
parser.add_argument('--sig', action='store_true',
help='Generate a SIG per AS (only available with -d, the SIG image needs\
to be built manually e.g. when running acceptance tests)')
return parser
def main():
"""
Main function.
"""
parser = argparse.ArgumentParser()
add_arguments(parser)
args = ConfigGenArgs(parser.parse_args())
confgen = ConfigGenerator(args)
confgen.generate_all()
if __name__ == "__main__":
main()