238
239
# ensure accurate naming for all releases post-H
243
def parse_mappings(mappings):
246
mappings = mappings.split(' ')
250
parsed[p[0].strip()] = p[2].strip()
255
def parse_bridge_mappings(mappings):
256
"""Parse bridge mappings.
258
Mappings must be a space-delimited list of provider:bridge mappings.
260
Returns dict of the form {provider:bridge}.
262
return parse_mappings(mappings)
265
def parse_data_port_mappings(mappings, default_bridge='br-data'):
266
"""Parse data port mappings.
268
Mappings must be a space-delimited list of bridge:port mappings.
270
Returns dict of the form {bridge:port}.
272
_mappings = parse_mappings(mappings)
277
# For backwards-compatibility we need to support port-only provided in
279
_mappings = {default_bridge: mappings.split(' ')[0]}
281
bridges = _mappings.keys()
282
ports = _mappings.values()
283
if len(set(bridges)) != len(bridges):
284
raise Exception("It is not allowed to have more than one port "
285
"configured on the same bridge")
287
if len(set(ports)) != len(ports):
288
raise Exception("It is not allowed to have the same port configured "
289
"on more than one bridge")
294
def parse_vlan_range_mappings(mappings):
295
"""Parse vlan range mappings.
297
Mappings must be a space-delimited list of provider:start:end mappings.
299
Returns dict of the form {provider: (start, end)}.
301
_mappings = parse_mappings(mappings)
306
for p, r in six.iteritems(_mappings):
307
mappings[p] = tuple(r.split(':'))