forked from plume-design/opensync-qa-lib-testbed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
222 lines (209 loc) · 7.13 KB
/
__init__.py
File metadata and controls
222 lines (209 loc) · 7.13 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import enum
import ipaddress
DEFAULT_TAGGED_VLANS = ["4", "24", "35", "700"]
class TESTBED_SERVER_IPERF_ADDRESS:
"""
Testbed server addresses that can be used when running iperf to bind / connect to.
These addresses are reachable from all testbed namespaces and VLANs, so can be
safely used even for tests whose WAN VLAN is isolated from testbed's main namespace.
"""
IPv4 = ipaddress.IPv4Address("192.168.7.1")
IPv6 = ipaddress.IPv6Address("2001:ee2:1704:9807::1")
class WAN_VLAN(enum.IntEnum):
"""
Describes a testbed WAN VLAN
Attributes:
value (int): VLAN ID of the testbed WAN network
name (str): Name of the testbed WAN network
ipv4_subnet (IPv4Network): IPv4 subnet used on this WAN VLAN, or '0.0.0.0/32' if not used
ipv4_gateway (IPv4Address): IPv4 address of default gateway, or '0.0.0.0' if not used
ipv4_nameserver (IPv4Address): IPv4 address of DNS name server, or '0.0.0.0' if not used
ipv4_mapped (IPv4Network): IPv4 subnet used for MAP-E/T on this WAN VLAN, or '0.0.0.0/32' if not used
ipv6_subnet (IPv6Network): IPv6 subnet used on this WAN VLAN, or '::/128' if not used
ipv6_gateway (IPv6Address): IPv6 address of default gateway, or '::' if not used
ipv6_nameserver (IPv6Address): IPv6 address of DNS name server, or '::' if not used
ipv6_delegated (IPv6Network): IPv6 subnet from which prefixes are delegated on this WAN VLAN.
Same as ipv6_subnet when prefix delegation is not in use.
ipv6_multicast (IPv6Network): IPv6 multicast transient and site-local address prefix that gets
routed over this WAN VLAN, or '::/128' if not used
wano_config (dict): WAN Orchestrator settings needed to connect to this network
tagged_wano_config (dict): WANO settings needed when this network is delivered as tagged VLAN
"""
IPv4 = 200, "192.168.200.0/24", "::/128", "::/128", "::/128"
IPv6_STATEFUL = (
201,
"192.168.201.0/24",
"2001:ee2:1704:9901::/64",
"2001:ee2:1704:99f0::/60",
"ff15:0:9901::/48",
)
IPv6_STATELESS = (
202,
"192.168.202.0/24",
"2001:ee2:1704:9902::/64",
"2001:ee2:1704:9902::/64",
"ff15:0:9902::/48",
)
IPv6_SLAAC = (
203,
"192.168.203.0/24",
"2001:ee2:1704:9903::/64",
"2001:ee2:1704:9903::/64",
"ff15:0:9903::/48",
)
IPv6_ONLY_STATEFUL = (
204,
"0.0.0.0/32",
"2001:ee2:1704:9904::/64",
"2001:ee2:1704:99d0::/60",
"ff15:0:9904::/48",
)
IPv6_ONLY_STATELESS = (
205,
"0.0.0.0/32",
"2001:ee2:1704:9905::/64",
"2001:ee2:1704:9905::/64",
"ff15:0:9905::/48",
)
IPv6_ONLY_SLAAC = (
206,
"0.0.0.0/32",
"2001:ee2:1704:9906::/64",
"2001:ee2:1704:9906::/64",
"ff15:0:9906::/48",
)
IPTV_BRIDGED = (
207,
"192.168.207.0/24",
"2001:ee2:1704:9907::/64",
"2001:ee2:1704:99a0::/60",
"ff15:0:9907::/48",
)
IPTV_ROUTED = (
208,
"192.168.208.0/24",
"2001:ee2:1704:9908::/64",
"2001:ee2:1704:99b0::/60",
"ff15:0:9908::/48",
)
IPv4_PUBLIC = 210, "99.99.210.0/24", "::/128", "::/128", "::/128"
IPv6_ONLY_UNNUMBERED = (
218,
"0.0.0.0/32",
"2001:ee2:1704:9918::/64",
"2001:ee2:1704:9960::/61",
"ff15:0:9918::/48",
)
IPv6_UNNUMBERED = (
219,
"99.99.219.0/24",
"2001:ee2:1704:9919::/64",
"2001:ee2:1704:9968::/61",
"ff15:0:9919::/48",
)
IPv4_STATIC = 220, "192.168.220.0/24", "::/128", "::/128", "::/128"
MAP_T_DHCP = (
221,
"0.0.0.0/32",
"2001:ee2:1704:9921::/64",
"2001:ee2:1704:99c0::/61",
"::/128",
)
MAP_E_DHCP = (
222,
"0.0.0.0/32",
"2001:ee2:1704:9922::/64",
"2001:ee2:1704:99c8::/61",
"::/128",
)
MAP_E_OPT3 = (
223,
"192.168.23.0/24",
"2001:ee2:1704:99e0::/64",
"2001:ee2:1704:99e0::/61",
"::/128",
)
MAP_E_OPT4 = (
224,
"192.168.24.0/24",
"2001:ee2:1704:99e8::/64",
"2001:ee2:1704:99e8::/64",
"::/128",
)
MAP_E_OPT5 = (
225,
"0.0.0.0/32",
"2001:ee2:1704:9925::/64",
"2001:ee2:1704:9970::/61",
"::/128",
)
MAP_E_OPT6 = (
226,
"0.0.0.0/32",
"2001:ee2:1704:9978::/64",
"2001:ee2:1704:9978::/64",
"::/128",
)
IPv4_PPPoE_CHAP = 230, "99.99.230.0/24", "::/128", "::/128", "::/128"
IPv4_PPPoE_PAP = 231, "192.168.231.0/24", "::/128", "::/128", "::/128"
IPv6_PPPoE_CHAP = (
232,
"192.168.232.0/24",
"2001:ee2:1704:9932::/64",
"2001:ee2:1704:9990::/60",
"ff15:0:9932::/48",
)
IPv6_PPPoE_PAP = (
233,
"192.168.233.0/24",
"2001:ee2:1704:9933::/64",
"2001:ee2:1704:9980::/60",
"ff15:0:9933::/48",
)
MAX_VLAN = 4094, "192.168.94.0/24", "::/128", "::/128", "::/128"
def __new__(cls, value, ipv4_subnet, ipv6_subnet, ipv6_delegated, ipv6_multicast):
# super() or enum.IntEnum.__new__() can't be used for some obscure Enum specific reason
self = int.__new__(cls, value)
self._value_ = value
self.ipv4_subnet = ipaddress.IPv4Network(ipv4_subnet)
self.ipv6_subnet = ipaddress.IPv6Network(ipv6_subnet)
self.ipv6_delegated = ipaddress.IPv6Network(ipv6_delegated)
self.ipv4_gateway = self.ipv4_nameserver = next(iter(self.ipv4_subnet.hosts()))
self.ipv6_gateway = self.ipv6_nameserver = next(iter(self.ipv6_subnet.hosts()))
self.ipv6_multicast = ipaddress.IPv6Network(ipv6_multicast)
return self
@property
def ipv4_mapped(self):
if self.name.startswith("MAP_"):
return ipaddress.IPv4Network(f"192.168.{self.value}.4/31")
return ipaddress.IPv4Network("0.0.0.0/32")
@property
def wano_config(self):
config = {"wanConnectionType": "dynamic"}
if "PPPoE" in self.name:
config["PPPoE"] = {"enabled": True}
if "CHAP" in self.name:
config["PPPoE"]["username"] = "plumechap"
config["PPPoE"]["password"] = "12testchap"
elif "PAP" in self.name:
config["PPPoE"]["username"] = "plumepap"
config["PPPoE"]["password"] = "12testpap"
elif self.name == "IPv4_STATIC":
config["staticIPv4"] = {
"enabled": True,
"ip": "192.168.220.42",
"gateway": "192.168.220.1",
"subnet": "255.255.255.0", # Misspelt netmask is by the spec
"primaryDns": "8.8.8.8",
"secondaryDns": "8.8.8.4",
}
return config
@property
def tagged_wano_config(self):
config = self.wano_config
config["DataService"] = {
"enabled": True,
"VLAN": self.value,
"QoS": 0,
}
return config