From 41778e3bf38e4e015199b7fcb9017d462cc197dc Mon Sep 17 00:00:00 2001 From: Hugh Saunders Date: Fri, 8 Apr 2016 10:54:39 +0100 Subject: [PATCH] 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 --- library/neutron | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/neutron b/library/neutron index d2bd4b8d..e08e2871 100644 --- a/library/neutron +++ b/library/neutron @@ -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(