Skip to content

Commit

Permalink
Fix neutron subnets with empty values.
Browse files Browse the repository at this point in the history
Subnet was expended with ability to set and update parameters like
specifing dns servers, allocation pools and also specific host routes.
Sadly it introduced issue when calling neutron_subnet without specifying
values for these parameters.
Closes-Bug: #1312628

Change-Id: Id1207ab793fc65c43c10afcfe2271e2c02a912d3
  • Loading branch information
xbezdick committed Apr 25, 2014
1 parent f9b3d18 commit 78428c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/puppet/provider/neutron_subnet/neutron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def self.prefetch(resources)

def self.parse_allocation_pool(values)
allocation_pools = []
return [] if values.empty?
for value in Array(values)
matchdata = /\{\s*"start"\s*:\s*"(.*)"\s*,\s*"end"\s*:\s*"(.*)"\s*\}/.match(value)
start_ip = matchdata[1]
Expand All @@ -61,6 +62,7 @@ def self.parse_allocation_pool(values)

def self.parse_host_routes(values)
host_routes = []
return [] if values.empty?
for value in Array(values)
matchdata = /\{\s*"destination"\s*:\s*"(.*)"\s*,\s*"nexthop"\s*:\s*"(.*)"\s*\}/.match(value)
destination = matchdata[1]
Expand Down Expand Up @@ -164,19 +166,23 @@ def enable_dhcp=(value)
end

def dns_nameservers=(values)
opts = ["#{name}", "--dns-nameservers", "list=true"]
for value in values
opts << value
unless values.empty?
opts = ["#{name}", "--dns-nameservers", "list=true"]
for value in values
opts << value
end
auth_neutron('subnet-update', opts)
end
auth_neutron('subnet-update', opts)
end

def host_routes=(values)
opts = ["#{name}", "--host-routes", "type=dict", "list=true"]
for value in values
opts << value
unless values.empty?
opts = ["#{name}", "--host-routes", "type=dict", "list=true"]
for value in values
opts << value
end
auth_neutron('subnet-update', opts)
end
auth_neutron('subnet-update', opts)
end

[
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/provider/neutron_subnet/neutron_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
'destination=12.0.0.0/24,nexthop=10.0.0.2'])
provider.host_routes=(['destination=12.0.0.0/24,nexthop=10.0.0.2'])
end

it 'should not update if dns_nameservers are empty' do
provider.dns_nameservers=('')
end

it 'should not update if host_routes are empty' do
provider.host_routes=('')
end
end

end

0 comments on commit 78428c8

Please sign in to comment.