mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #3648 from d063130/openstack_subnets
[OpenStack] subnets vanilla options fix
This commit is contained in:
commit
7b159fd99d
4 changed files with 12 additions and 11 deletions
|
@ -27,7 +27,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
requires :id, :network_id, :cidr, :ip_version
|
requires :id
|
||||||
merge_attributes(service.update_subnet(self.id,
|
merge_attributes(service.update_subnet(self.id,
|
||||||
self.attributes).body['subnet'])
|
self.attributes).body['subnet'])
|
||||||
self
|
self
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
||||||
vanilla_options = [:name, :gateway_ip, :allocation_pools,
|
vanilla_options = [:name, :gateway_ip, :allocation_pools,
|
||||||
:dns_nameservers, :host_routes, :enable_dhcp,
|
:dns_nameservers, :host_routes, :enable_dhcp,
|
||||||
:tenant_id]
|
:tenant_id]
|
||||||
vanilla_options.reject{ |o| options[o].nil? unless o == :gateway_ip }.each do |key|
|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
|
||||||
data['subnet'][key] = options[key]
|
data['subnet'][key] = options[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ module Fog
|
||||||
def update_subnet(subnet_id, options = {})
|
def update_subnet(subnet_id, options = {})
|
||||||
data = { 'subnet' => {} }
|
data = { 'subnet' => {} }
|
||||||
|
|
||||||
vanilla_options = [:name, :gateway_ip, :dns_nameservers,
|
vanilla_options = [:name, :gateway_ip, :allocation_pools,
|
||||||
:host_routes, :enable_dhcp]
|
:dns_nameservers, :host_routes, :enable_dhcp]
|
||||||
vanilla_options.select{ |o| options.key?(o) }.each do |key|
|
vanilla_options.select{ |o| options.key?(o) }.each do |key|
|
||||||
data['subnet'][key] = options[key]
|
data['subnet'][key] = options[key]
|
||||||
end
|
end
|
||||||
|
@ -24,11 +24,12 @@ module Fog
|
||||||
def update_subnet(subnet_id, options = {})
|
def update_subnet(subnet_id, options = {})
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
if subnet = list_subnets.body['subnets'].find { |_| _['id'] == subnet_id }
|
if subnet = list_subnets.body['subnets'].find { |_| _['id'] == subnet_id }
|
||||||
subnet['name'] = options[:name]
|
subnet['name'] = options[:name]
|
||||||
subnet['gateway_ip'] = options[:gateway_ip]
|
subnet['gateway_ip'] = options[:gateway_ip]
|
||||||
subnet['dns_nameservers'] = options[:dns_nameservers]
|
subnet['dns_nameservers'] = options[:dns_nameservers] || []
|
||||||
subnet['host_routes'] = options[:host_routes]
|
subnet['host_routes'] = options[:host_routes] || []
|
||||||
subnet['enable_dhcp'] = options[:enable_dhcp]
|
subnet['allocation_pools'] = options[:allocation_pools] || []
|
||||||
|
subnet['enable_dhcp'] = options[:enable_dhcp]
|
||||||
response.body = { 'subnet' => subnet }
|
response.body = { 'subnet' => subnet }
|
||||||
response.status = 200
|
response.status = 200
|
||||||
response
|
response
|
||||||
|
|
|
@ -38,8 +38,8 @@ Shindo.tests('Fog::Network[:openstack] | subnet requests', ['openstack']) do
|
||||||
tests('#update_subnet').formats({'subnet' => @subnet_format}) do
|
tests('#update_subnet').formats({'subnet' => @subnet_format}) do
|
||||||
subnet_id = Fog::Network[:openstack].subnets.all.first.id
|
subnet_id = Fog::Network[:openstack].subnets.all.first.id
|
||||||
attributes = {:name => 'subnet_name', :gateway_ip => '10.2.2.1',
|
attributes = {:name => 'subnet_name', :gateway_ip => '10.2.2.1',
|
||||||
:dns_nameservers => [], :host_routes => [],
|
:allocation_pools => [], :dns_nameservers => [],
|
||||||
:enable_dhcp => true}
|
:host_routes => [], :enable_dhcp => true}
|
||||||
Fog::Network[:openstack].update_subnet(subnet_id, attributes).body
|
Fog::Network[:openstack].update_subnet(subnet_id, attributes).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue