~niedbalski/charms/trusty/ceilometer/fix-lp-1473222

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/neutron.py

  • Committer: james.page at ubuntu
  • Date: 2015-06-09 09:52:34 UTC
  • mfrom: (71.1.16 ceilometer)
  • Revision ID: james.page@ubuntu.com-20150609095234-4lh9wjhjjso5bszo
Add support for leader-election

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
def parse_mappings(mappings):
257
257
    parsed = {}
258
258
    if mappings:
259
 
        mappings = mappings.split(' ')
 
259
        mappings = mappings.split()
260
260
        for m in mappings:
261
261
            p = m.partition(':')
262
 
            if p[1] == ':':
263
 
                parsed[p[0].strip()] = p[2].strip()
 
262
            key = p[0].strip()
 
263
            if p[1]:
 
264
                parsed[key] = p[2].strip()
 
265
            else:
 
266
                parsed[key] = ''
264
267
 
265
268
    return parsed
266
269
 
283
286
    Returns dict of the form {bridge:port}.
284
287
    """
285
288
    _mappings = parse_mappings(mappings)
286
 
    if not _mappings:
 
289
    if not _mappings or list(_mappings.values()) == ['']:
287
290
        if not mappings:
288
291
            return {}
289
292
 
290
293
        # For backwards-compatibility we need to support port-only provided in
291
294
        # config.
292
 
        _mappings = {default_bridge: mappings.split(' ')[0]}
 
295
        _mappings = {default_bridge: mappings.split()[0]}
293
296
 
294
297
    bridges = _mappings.keys()
295
298
    ports = _mappings.values()
309
312
 
310
313
    Mappings must be a space-delimited list of provider:start:end mappings.
311
314
 
 
315
    The start:end range is optional and may be omitted.
 
316
 
312
317
    Returns dict of the form {provider: (start, end)}.
313
318
    """
314
319
    _mappings = parse_mappings(mappings)