Fix NoneType with no subnet allocation ranges

When creating a subnet, we retrieve the allocation_ranges from the
variables dict with a default value of "". This should then be fine for
various string operations. The problems is that ansible defaults
varialbes that aren't supplied to None. This means they are present in
the variables dict so don't get the default value of "".

To fix this the code that parses allocation_ranges is wrapped in an
additional conditional.

Change-Id: Ie0310c3da050336ed9b5f5d8fc02e3a4d704491d
This commit is contained in:
Hugh Saunders 2016-04-08 10:54:39 +01:00
parent 0635876a5a
commit 41778e3bf3
1 changed files with 6 additions and 5 deletions

View File

@ -334,11 +334,12 @@ class ManageNeutron(object):
# startip-endip[,startip-endip]...
allocation_pools_str = variables_dict.get('allocation_pools', "")
allocation_pools = []
for ap in allocation_pools_str.split(','):
if "-" not in ap:
continue
start, end = ap.split('-')
allocation_pools.append({'start': start, 'end': end})
if allocation_pools_str:
for ap in allocation_pools_str.split(','):
if "-" not in ap:
continue
start, end = ap.split('-')
allocation_pools.append({'start': start, 'end': end})
if not network_id:
self.failure(