This commit is contained in:
Edward Hope-Morley 2015-03-03 14:06:48 +08:00
parent 44d2c1e462
commit 9c7a35104d

View File

@ -239,10 +239,10 @@ def network_manager():
return 'neutron'
def parse_mappings(mappings):
def parse_mappings(mappings, delimiter=' '):
parsed = {}
if mappings:
mappings = mappings.split(' ')
mappings = mappings.split(delimiter)
for m in mappings:
p = m.partition(':')
if p[1] == ':':
@ -280,3 +280,18 @@ def parse_data_port_mappings(mappings):
"on more than one bridge")
return mappings
def parse_vlan_range_mappings(mappings):
"""Parse vlan range mappings.
Mappings must be a space-delimited list of provider:start:end mappings.
Returns dict of the form {provider: (start, end)}.
"""
_mappings = parse_mappings(mappings)
mappings = {}
for p, r in _mappings.iteritems():
mappings[p] = tuple(r.split(':'))
return mappings