Class: Fog::Network::OpenStack::Real
- Inherits:
-
Object
- Object
- Fog::Network::OpenStack::Real
- Defined in:
- lib/fog/openstack/network.rb,
lib/fog/openstack/requests/network/get_port.rb,
lib/fog/openstack/requests/network/get_quota.rb,
lib/fog/openstack/requests/network/get_lb_vip.rb,
lib/fog/openstack/requests/network/get_quotas.rb,
lib/fog/openstack/requests/network/get_router.rb,
lib/fog/openstack/requests/network/get_subnet.rb,
lib/fog/openstack/requests/network/list_ports.rb,
lib/fog/openstack/requests/network/set_tenant.rb,
lib/fog/openstack/requests/network/create_port.rb,
lib/fog/openstack/requests/network/delete_port.rb,
lib/fog/openstack/requests/network/get_lb_pool.rb,
lib/fog/openstack/requests/network/get_network.rb,
lib/fog/openstack/requests/network/update_port.rb,
lib/fog/openstack/requests/network/delete_quota.rb,
lib/fog/openstack/requests/network/list_lb_vips.rb,
lib/fog/openstack/requests/network/list_routers.rb,
lib/fog/openstack/requests/network/list_subnets.rb,
lib/fog/openstack/requests/network/update_quota.rb,
lib/fog/openstack/requests/network/create_lb_vip.rb,
lib/fog/openstack/requests/network/create_router.rb,
lib/fog/openstack/requests/network/create_subnet.rb,
lib/fog/openstack/requests/network/delete_lb_vip.rb,
lib/fog/openstack/requests/network/delete_router.rb,
lib/fog/openstack/requests/network/delete_subnet.rb,
lib/fog/openstack/requests/network/get_lb_member.rb,
lib/fog/openstack/requests/network/list_lb_pools.rb,
lib/fog/openstack/requests/network/list_networks.rb,
lib/fog/openstack/requests/network/update_lb_vip.rb,
lib/fog/openstack/requests/network/update_router.rb,
lib/fog/openstack/requests/network/update_subnet.rb,
lib/fog/openstack/requests/network/create_lb_pool.rb,
lib/fog/openstack/requests/network/create_network.rb,
lib/fog/openstack/requests/network/delete_lb_pool.rb,
lib/fog/openstack/requests/network/delete_network.rb,
lib/fog/openstack/requests/network/update_lb_pool.rb,
lib/fog/openstack/requests/network/update_network.rb,
lib/fog/openstack/requests/network/get_floating_ip.rb,
lib/fog/openstack/requests/network/list_lb_members.rb,
lib/fog/openstack/requests/network/create_lb_member.rb,
lib/fog/openstack/requests/network/delete_lb_member.rb,
lib/fog/openstack/requests/network/update_lb_member.rb,
lib/fog/openstack/requests/network/get_lb_pool_stats.rb,
lib/fog/openstack/requests/network/list_floating_ips.rb,
lib/fog/openstack/requests/network/create_floating_ip.rb,
lib/fog/openstack/requests/network/delete_floating_ip.rb,
lib/fog/openstack/requests/network/get_security_group.rb,
lib/fog/openstack/requests/network/add_router_interface.rb,
lib/fog/openstack/requests/network/list_security_groups.rb,
lib/fog/openstack/requests/network/associate_floating_ip.rb,
lib/fog/openstack/requests/network/create_security_group.rb,
lib/fog/openstack/requests/network/delete_security_group.rb,
lib/fog/openstack/requests/network/get_lb_health_monitor.rb,
lib/fog/openstack/requests/network/get_security_group_rule.rb,
lib/fog/openstack/requests/network/list_lb_health_monitors.rb,
lib/fog/openstack/requests/network/remove_router_interface.rb,
lib/fog/openstack/requests/network/create_lb_health_monitor.rb,
lib/fog/openstack/requests/network/delete_lb_health_monitor.rb,
lib/fog/openstack/requests/network/disassociate_floating_ip.rb,
lib/fog/openstack/requests/network/update_lb_health_monitor.rb,
lib/fog/openstack/requests/network/list_security_group_rules.rb,
lib/fog/openstack/requests/network/create_security_group_rule.rb,
lib/fog/openstack/requests/network/delete_security_group_rule.rb,
lib/fog/openstack/requests/network/associate_lb_health_monitor.rb,
lib/fog/openstack/requests/network/disassociate_lb_health_monitor.rb
Instance Attribute Summary collapse
-
#current_tenant ⇒ Object
readonly
Returns the value of attribute current_tenant.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
- #add_router_interface(router_id, subnet_id, options = {}) ⇒ Object
- #associate_floating_ip(floating_ip_id, port_id, options = {}) ⇒ Object
- #associate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object
- #create_floating_ip(floating_network_id, options = {}) ⇒ Object
- #create_lb_health_monitor(type, delay, timeout, max_retries, options = {}) ⇒ Object
- #create_lb_member(pool_id, address, protocol_port, weight, options = {}) ⇒ Object
- #create_lb_pool(subnet_id, protocol, lb_method, options = {}) ⇒ Object
- #create_lb_vip(subnet_id, pool_id, protocol, protocol_port, options = {}) ⇒ Object
- #create_network(options = {}) ⇒ Object
- #create_port(network_id, options = {}) ⇒ Object
- #create_router(name, options = {}) ⇒ Object
-
#create_security_group(options = {}) ⇒ Object
Create a new security group.
-
#create_security_group_rule(security_group_id, direction, options = {}) ⇒ Object
Create a new security group rule.
- #create_subnet(network_id, cidr, ip_version, options = {}) ⇒ Object
- #credentials ⇒ Object
- #delete_floating_ip(floating_ip_id) ⇒ Object
- #delete_lb_health_monitor(health_monitor_id) ⇒ Object
- #delete_lb_member(member_id) ⇒ Object
- #delete_lb_pool(pool_id) ⇒ Object
- #delete_lb_vip(vip_id) ⇒ Object
- #delete_network(network_id) ⇒ Object
- #delete_port(port_id) ⇒ Object
- #delete_quota(tenant_id) ⇒ Object
- #delete_router(router_id) ⇒ Object
-
#delete_security_group(security_group_id) ⇒ Object
Delete a security group.
-
#delete_security_group_rule(security_group_rule_id) ⇒ Object
Delete a security group rule.
- #delete_subnet(subnet_id) ⇒ Object
- #disassociate_floating_ip(floating_ip_id, options = {}) ⇒ Object
- #disassociate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object
- #get_floating_ip(floating_ip_id) ⇒ Object
- #get_lb_health_monitor(health_monitor_id) ⇒ Object
- #get_lb_member(member_id) ⇒ Object
- #get_lb_pool(pool_id) ⇒ Object
- #get_lb_pool_stats(pool_id) ⇒ Object
- #get_lb_vip(vip_id) ⇒ Object
- #get_network(network_id) ⇒ Object
- #get_port(port_id) ⇒ Object
- #get_quota(tenant_id) ⇒ Object
- #get_quotas ⇒ Object
- #get_router(router_id) ⇒ Object
-
#get_security_group(security_group_id) ⇒ Object
Get details about a security group.
-
#get_security_group_rule(security_group_rule_id) ⇒ Object
Get details about a security group rule.
- #get_subnet(subnet_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_floating_ips(filters = {}) ⇒ Object
- #list_lb_health_monitors(filters = {}) ⇒ Object
- #list_lb_members(filters = {}) ⇒ Object
- #list_lb_pools(filters = {}) ⇒ Object
- #list_lb_vips(filters = {}) ⇒ Object
- #list_networks(filters = {}) ⇒ Object
- #list_ports(filters = {}) ⇒ Object
- #list_routers(filters = {}) ⇒ Object
-
#list_security_group_rules(options = {}) ⇒ Object
List all security group rules.
-
#list_security_groups(options = {}) ⇒ Object
List all security groups.
- #list_subnets(filters = {}) ⇒ Object
- #reload ⇒ Object
- #remove_router_interface(router_id, subnet_id, options = {}) ⇒ Object
- #request(params) ⇒ Object
- #set_tenant(tenant) ⇒ Object
- #update_lb_health_monitor(health_monitor_id, options = {}) ⇒ Object
- #update_lb_member(member_id, options = {}) ⇒ Object
- #update_lb_pool(pool_id, options = {}) ⇒ Object
- #update_lb_vip(vip_id, options = {}) ⇒ Object
- #update_network(network_id, options = {}) ⇒ Object
- #update_port(port_id, options = {}) ⇒ Object
- #update_quota(tenant_id, options = {}) ⇒ Object
-
#update_router(router_id, options = {}) ⇒ Object
Update Router.
- #update_subnet(subnet_id, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/fog/openstack/network.rb', line 229 def initialize(={}) @openstack_auth_token = [:openstack_auth_token] unless @openstack_auth_token missing_credentials = Array.new @openstack_api_key = [:openstack_api_key] @openstack_username = [:openstack_username] missing_credentials << :openstack_api_key unless @openstack_api_key missing_credentials << :openstack_username unless @openstack_username raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty? end @openstack_tenant = [:openstack_tenant] @openstack_auth_uri = URI.parse([:openstack_auth_url]) @openstack_management_url = [:openstack_management_url] @openstack_must_reauthenticate = false @openstack_service_type = [:openstack_service_type] || ['network'] @openstack_service_name = [:openstack_service_name] @openstack_endpoint_type = [:openstack_endpoint_type] || 'publicURL' @openstack_region = [:openstack_region] @connection_options = [:connection_options] || {} @current_user = [:current_user] @current_tenant = [:current_tenant] authenticate @persistent = [:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Attribute Details
#current_tenant ⇒ Object (readonly)
Returns the value of attribute current_tenant.
227 228 229 |
# File 'lib/fog/openstack/network.rb', line 227 def current_tenant @current_tenant end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
226 227 228 |
# File 'lib/fog/openstack/network.rb', line 226 def current_user @current_user end |
Instance Method Details
#add_router_interface(router_id, subnet_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/network/add_router_interface.rb', line 5 def add_router_interface(router_id, subnet_id, = {}) data = { 'subnet_id' => subnet_id, } request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'PUT', :path => "routers/#{router_id}/add_router_interface" ) end |
#associate_floating_ip(floating_ip_id, port_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/openstack/requests/network/associate_floating_ip.rb', line 5 def associate_floating_ip(floating_ip_id, port_id, = {}) data = { 'floatingip' => { 'port_id' => port_id, } } = [:fixed_ip_address] .reject{ |o| [o].nil? }.each do |key| data['floatingip'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'PUT', :path => "floatingips/#{floating_ip_id}" ) end |
#associate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/openstack/requests/network/associate_lb_health_monitor.rb', line 5 def associate_lb_health_monitor(pool_id, health_monitor_id) data = { 'health_monitor' => { 'id' => health_monitor_id, } } request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => "lb/pools/#{pool_id}/health_monitors" ) end |
#create_floating_ip(floating_network_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/openstack/requests/network/create_floating_ip.rb', line 5 def create_floating_ip(floating_network_id, = {}) data = { 'floatingip' => { 'floating_network_id' => floating_network_id } } = [:port_id, :tenant_id, :fixed_ip_address ] .reject{ |o| [o].nil? }.each do |key| data['floatingip'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'floatingips' ) end |
#create_lb_health_monitor(type, delay, timeout, max_retries, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/requests/network/create_lb_health_monitor.rb', line 5 def create_lb_health_monitor(type, delay, timeout, max_retries, = {}) data = { 'health_monitor' => { 'type' => type, 'delay' => delay, 'timeout' => timeout, 'max_retries' => max_retries } } = [:http_method, :url_path, :expected_codes, :admin_state_up, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['health_monitor'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'lb/health_monitors' ) end |
#create_lb_member(pool_id, address, protocol_port, weight, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/requests/network/create_lb_member.rb', line 5 def create_lb_member(pool_id, address, protocol_port, weight, = {}) data = { 'member' => { 'pool_id' => pool_id, 'address' => address, 'protocol_port' => protocol_port, 'weight' => weight } } = [:admin_state_up, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['member'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'lb/members' ) end |
#create_lb_pool(subnet_id, protocol, lb_method, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/openstack/requests/network/create_lb_pool.rb', line 5 def create_lb_pool(subnet_id, protocol, lb_method, = {}) data = { 'pool' => { 'subnet_id' => subnet_id, 'protocol' => protocol, 'lb_method' => lb_method } } = [:name, :description, :admin_state_up, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['pool'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'lb/pools' ) end |
#create_lb_vip(subnet_id, pool_id, protocol, protocol_port, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/openstack/requests/network/create_lb_vip.rb', line 5 def create_lb_vip(subnet_id, pool_id, protocol, protocol_port, = {}) data = { 'vip' => { 'subnet_id' => subnet_id, 'pool_id' => pool_id, 'protocol' => protocol, 'protocol_port' => protocol_port } } = [:name, :description, :address, :session_persistence, :connection_limit, :admin_state_up, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['vip'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'lb/vips' ) end |
#create_network(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/openstack/requests/network/create_network.rb', line 5 def create_network( = {}) data = { 'network' => {} } = [ :name, :shared, :admin_state_up, :tenant_id ] .reject{ |o| [o].nil? }.each do |key| data['network'][key] = [key] end # Advanced Features through API Extensions # # Not strictly required but commonly found in OpenStack # installs with Quantum networking. # # @see http://docs.openstack.org/trunk/openstack-network/admin/content/provider_attributes.html = [ :router_external, :provider_network_type, :provider_segmentation_id, :provider_physical_network ] # Map Fog::Network::OpenStack::Network # model attributes to OpenStack provider attributes aliases = { :provider_network_type => 'provider:network_type', # Not applicable to the "local" or "gre" network types :provider_physical_network => 'provider:physical_network', :provider_segmentation_id => 'provider:segmentation_id', :router_external => 'router:external' } .reject{ |o| [o].nil? }.each do |key| aliased_key = aliases[key] || key data['network'][aliased_key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'networks' ) end |
#create_port(network_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/openstack/requests/network/create_port.rb', line 5 def create_port(network_id, = {}) data = { 'port' => { 'network_id' => network_id, } } = [:name, :fixed_ips, :mac_address, :admin_state_up, :device_owner, :device_id, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['port'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'ports' ) end |
#create_router(name, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/openstack/requests/network/create_router.rb', line 5 def create_router(name, = {}) data = { 'router' => { 'name' => name, } } = [ :admin_state_up, :tenant_id, :network_id, :status, :subnet_id ] .reject{ |o| [o].nil? }.each do |key| data['router'][key] = [key] end # remove this in a future egi = [:external_gateway_info] if egi if egi.is_a?(Fog::Network::OpenStack::Network) Fog::Logger.deprecation "Passing a model objects into options[:external_gateway_info] is deprecated. \ Please pass external external gateway as follows options[:external_gateway_info] = { :network_id => NETWORK_ID }]" data['router'][:external_gateway_info] = { :network_id => egi.id } elsif egi.is_a?(Hash) && egi[:network_id] data['router'][:external_gateway_info] = egi else raise ArgumentError.new('Invalid external_gateway_info attribute') end end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'routers' ) end |
#create_security_group(options = {}) ⇒ Object
Create a new security group
Parameters
-
options<~Hash>:
-
‘name’<~String> - Name of the security group
-
‘description’<~String> - Description of the security group
-
‘tenant_id’<~String> - TenantId different than the current user, that should own the security group. Only allowed if user has ‘admin’ role.
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_groups’<~Array>:
-
‘id’<~String> - UUID of the security group
-
‘name’<~String> - Name of the security group
-
‘description’<~String> - Description of the security group
-
‘tenant_id’<~String> - Tenant id that owns the security group
-
‘security_group_rules’<~Array>: - Array of security group rules
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
-
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/openstack/requests/network/create_security_group.rb', line 32 def create_security_group( = {}) data = {"security_group" => {}} = [:name, :description, :tenant_id] = .select{|o| [o]} .each { |key| data["security_group"][key] = [key] } request( :body => Fog::JSON.encode(data), :expects => 201, :method => "POST", :path => "security-groups" ) end |
#create_security_group_rule(security_group_id, direction, options = {}) ⇒ Object
Create a new security group rule
Parameters
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
options<~Hash>:
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - TenantId different than the current user, that should own the security group. Only allowed if user has ‘admin’ role.
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_group_rule’<~Hash>:
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~String> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~String> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the source security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/openstack/requests/network/create_security_group_rule.rb', line 33 def create_security_group_rule(security_group_id, direction, = {}) data = {"security_group_rule" => {"security_group_id" => security_group_id, "direction" => direction}} = [ :port_range_min, :port_range_max, :protocol, :ethertype, :remote_group_id, :remote_ip_prefix, :tenant_id ] = .select{ |o| [o] } .each { |key| data["security_group_rule"][key] = [key] } request( :body => Fog::JSON.encode(data), :expects => 201, :method => "POST", :path => "security-group-rules" ) end |
#create_subnet(network_id, cidr, ip_version, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/openstack/requests/network/create_subnet.rb', line 5 def create_subnet(network_id, cidr, ip_version, = {}) data = { 'subnet' => { 'network_id' => network_id, 'cidr' => cidr, 'ip_version' => ip_version, } } = [:name, :gateway_ip, :allocation_pools, :dns_nameservers, :host_routes, :enable_dhcp, :tenant_id] .reject{ |o| [o].nil? }.each do |key| data['subnet'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [201], :method => 'POST', :path => 'subnets' ) end |
#credentials ⇒ Object
262 263 264 265 266 267 268 269 270 |
# File 'lib/fog/openstack/network.rb', line 262 def credentials { :provider => 'openstack', :openstack_auth_url => @openstack_auth_uri.to_s, :openstack_auth_token => @auth_token, :openstack_management_url => @openstack_management_url, :current_user => @current_user, :current_tenant => @current_tenant, :openstack_region => @openstack_region } end |
#delete_floating_ip(floating_ip_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_floating_ip.rb', line 5 def delete_floating_ip(floating_ip_id) request( :expects => 204, :method => 'DELETE', :path => "floatingips/#{floating_ip_id}" ) end |
#delete_lb_health_monitor(health_monitor_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_lb_health_monitor.rb', line 5 def delete_lb_health_monitor(health_monitor_id) request( :expects => 204, :method => 'DELETE', :path => "lb/health_monitors/#{health_monitor_id}" ) end |
#delete_lb_member(member_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_lb_member.rb', line 5 def delete_lb_member(member_id) request( :expects => 204, :method => 'DELETE', :path => "lb/members/#{member_id}" ) end |
#delete_lb_pool(pool_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_lb_pool.rb', line 5 def delete_lb_pool(pool_id) request( :expects => 204, :method => 'DELETE', :path => "lb/pools/#{pool_id}" ) end |
#delete_lb_vip(vip_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_lb_vip.rb', line 5 def delete_lb_vip(vip_id) request( :expects => 204, :method => 'DELETE', :path => "lb/vips/#{vip_id}" ) end |
#delete_network(network_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_network.rb', line 5 def delete_network(network_id) request( :expects => 204, :method => 'DELETE', :path => "networks/#{network_id}" ) end |
#delete_port(port_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_port.rb', line 5 def delete_port(port_id) request( :expects => 204, :method => 'DELETE', :path => "ports/#{port_id}" ) end |
#delete_quota(tenant_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_quota.rb', line 5 def delete_quota(tenant_id) request( :expects => 204, :method => 'DELETE', :path => "/quotas/#{tenant_id}" ) end |
#delete_router(router_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_router.rb', line 5 def delete_router(router_id) request( :expects => 204, :method => 'DELETE', :path => "routers/#{router_id}" ) end |
#delete_security_group(security_group_id) ⇒ Object
Delete a security group
Parameters
-
‘security_group_id’<~String> - UUID of the security group to delete
9 10 11 12 13 14 15 |
# File 'lib/fog/openstack/requests/network/delete_security_group.rb', line 9 def delete_security_group(security_group_id) request( :expects => 204, :method => 'DELETE', :path => "security-groups/#{security_group_id}" ) end |
#delete_security_group_rule(security_group_rule_id) ⇒ Object
Delete a security group rule
Parameters
-
‘security_group_rule_id’<~String> - UUID of the security group rule to delete
9 10 11 12 13 14 15 |
# File 'lib/fog/openstack/requests/network/delete_security_group_rule.rb', line 9 def delete_security_group_rule(security_group_rule_id) request( :expects => 204, :method => "DELETE", :path => "security-group-rules/#{security_group_rule_id}" ) end |
#delete_subnet(subnet_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/delete_subnet.rb', line 5 def delete_subnet(subnet_id) request( :expects => 204, :method => 'DELETE', :path => "subnets/#{subnet_id}" ) end |
#disassociate_floating_ip(floating_ip_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/openstack/requests/network/disassociate_floating_ip.rb', line 5 def disassociate_floating_ip(floating_ip_id, = {}) data = { 'floatingip' => { 'port_id' => nil, } } = [:fixed_ip_address] .reject{ |o| [o].nil? }.each do |key| data['floatingip'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'PUT', :path => "floatingips/#{floating_ip_id}" ) end |
#disassociate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/disassociate_lb_health_monitor.rb', line 5 def disassociate_lb_health_monitor(pool_id, health_monitor_id) request( :expects => [204], :method => 'DELETE', :path => "lb/pools/#{pool_id}/health_monitors/#{health_monitor_id}" ) end |
#get_floating_ip(floating_ip_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_floating_ip.rb', line 5 def get_floating_ip(floating_ip_id) request( :expects => [200], :method => 'GET', :path => "floatingips/#{floating_ip_id}" ) end |
#get_lb_health_monitor(health_monitor_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_lb_health_monitor.rb', line 5 def get_lb_health_monitor(health_monitor_id) request( :expects => [200], :method => 'GET', :path => "lb/health_monitors/#{health_monitor_id}" ) end |
#get_lb_member(member_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_lb_member.rb', line 5 def get_lb_member(member_id) request( :expects => [200], :method => 'GET', :path => "lb/members/#{member_id}" ) end |
#get_lb_pool(pool_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_lb_pool.rb', line 5 def get_lb_pool(pool_id) request( :expects => [200], :method => 'GET', :path => "lb/pools/#{pool_id}" ) end |
#get_lb_pool_stats(pool_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_lb_pool_stats.rb', line 5 def get_lb_pool_stats(pool_id) request( :expects => [200], :method => 'GET', :path => "lb/pools/#{pool_id}/stats" ) end |
#get_lb_vip(vip_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_lb_vip.rb', line 5 def get_lb_vip(vip_id) request( :expects => [200], :method => 'GET', :path => "lb/vips/#{vip_id}" ) end |
#get_network(network_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_network.rb', line 5 def get_network(network_id) request( :expects => [200], :method => 'GET', :path => "networks/#{network_id}" ) end |
#get_port(port_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_port.rb', line 5 def get_port(port_id) request( :expects => [200], :method => 'GET', :path => "ports/#{port_id}" ) end |
#get_quota(tenant_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_quota.rb', line 5 def get_quota(tenant_id) request( :expects => 200, :method => 'GET', :path => "/quotas/#{tenant_id}" ) end |
#get_quotas ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_quotas.rb', line 5 def get_quotas request( :expects => 200, :method => 'GET', :path => "/quotas" ) end |
#get_router(router_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_router.rb', line 5 def get_router(router_id) request( :expects => [200], :method => 'GET', :path => "routers/#{router_id}" ) end |
#get_security_group(security_group_id) ⇒ Object
Get details about a security group
Parameters
-
‘security_group_id’<~String> - UUID of the security group
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_group’<~Array>:
-
‘id’<~String> - UUID of the security group
-
‘name’<~String> - Name of the security group
-
‘description’<~String> - Description of the security group
-
‘tenant_id’<~String> - Tenant id that owns the security group
-
‘security_group_rules’<~Array>: - Array of security group rules
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
-
29 30 31 32 33 34 35 |
# File 'lib/fog/openstack/requests/network/get_security_group.rb', line 29 def get_security_group(security_group_id) request( :expects => 200, :method => "GET", :path => "security-groups/#{security_group_id}" ) end |
#get_security_group_rule(security_group_rule_id) ⇒ Object
Get details about a security group rule
Parameters
-
‘security_group_rule_id’<~String> - UUID of the security group rule
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_group_rule’<~Hash>:
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
24 25 26 27 28 29 30 |
# File 'lib/fog/openstack/requests/network/get_security_group_rule.rb', line 24 def get_security_group_rule(security_group_rule_id) request( :expects => 200, :method => "GET", :path => "security-group-rules/#{security_group_rule_id}" ) end |
#get_subnet(subnet_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/openstack/requests/network/get_subnet.rb', line 5 def get_subnet(subnet_id) request( :expects => [200], :method => 'GET', :path => "subnets/#{subnet_id}" ) end |
#list_floating_ips(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_floating_ips.rb', line 5 def list_floating_ips(filters = {}) request( :expects => 200, :method => 'GET', :path => 'floatingips', :query => filters ) end |
#list_lb_health_monitors(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_lb_health_monitors.rb', line 5 def list_lb_health_monitors(filters = {}) request( :expects => 200, :method => 'GET', :path => 'lb/health_monitors', :query => filters ) end |
#list_lb_members(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_lb_members.rb', line 5 def list_lb_members(filters = {}) request( :expects => 200, :method => 'GET', :path => 'lb/members', :query => filters ) end |
#list_lb_pools(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_lb_pools.rb', line 5 def list_lb_pools(filters = {}) request( :expects => 200, :method => 'GET', :path => 'lb/pools', :query => filters ) end |
#list_lb_vips(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_lb_vips.rb', line 5 def list_lb_vips(filters = {}) request( :expects => 200, :method => 'GET', :path => 'lb/vips', :query => filters ) end |
#list_networks(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_networks.rb', line 5 def list_networks(filters = {}) request( :expects => 200, :method => 'GET', :path => 'networks', :query => filters ) end |
#list_ports(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_ports.rb', line 5 def list_ports(filters = {}) request( :expects => 200, :method => 'GET', :path => 'ports', :query => filters ) end |
#list_routers(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_routers.rb', line 5 def list_routers(filters = {}) request( :expects => 200, :method => 'GET', :path => 'routers', :query => filters ) end |
#list_security_group_rules(options = {}) ⇒ Object
List all security group rules
Parameters
-
options<~Hash>:
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_group_rules’<~Array>:
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
24 25 26 27 28 29 30 31 |
# File 'lib/fog/openstack/requests/network/list_security_group_rules.rb', line 24 def list_security_group_rules( = {}) request( :expects => 200, :method => 'GET', :path => 'security-group-rules', :query => ) end |
#list_security_groups(options = {}) ⇒ Object
List all security groups
Parameters
-
options<~Hash>:
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘security_groups’<~Array>:
-
‘id’<~String> - UUID of the security group
-
‘name’<~String> - Name of the security group
-
‘description’<~String> - Description of the security group
-
‘tenant_id’<~String> - Tenant id that owns the security group
-
‘security_group_rules’<~Array>: - Array of security group rules
-
‘id’<~String> - UUID of the security group rule
-
‘direction’<~String> - Direction of traffic, must be in [‘ingress’, ‘egress’]
-
‘port_range_min’<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘port_range_max’<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
‘protocol’<~String> - IP protocol for rule, must be in [‘tcp’, ‘udp’, ‘icmp’]
-
‘ethertype’<~String> - Type of ethernet support, must be in [‘IPv4’, ‘IPv6’]
-
‘security_group_id’<~String> - UUID of the parent security group
-
‘remote_group_id’<~String> - UUID of the remote security group
-
‘remote_ip_prefix’<~String> - IP cidr range address i.e. ‘0.0.0.0/0’
-
‘tenant_id’<~String> - Tenant id that owns the security group rule
-
-
-
29 30 31 32 33 34 35 36 |
# File 'lib/fog/openstack/requests/network/list_security_groups.rb', line 29 def list_security_groups( = {}) request( :expects => 200, :method => 'GET', :path => 'security-groups', :query => ) end |
#list_subnets(filters = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/list_subnets.rb', line 5 def list_subnets(filters = {}) request( :expects => 200, :method => 'GET', :path => 'subnets', :query => filters ) end |
#reload ⇒ Object
272 273 274 |
# File 'lib/fog/openstack/network.rb', line 272 def reload @connection.reset end |
#remove_router_interface(router_id, subnet_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/openstack/requests/network/remove_router_interface.rb', line 5 def remove_router_interface(router_id, subnet_id, = {}) data = { 'subnet_id' => subnet_id, } request( :body => Fog::JSON.encode(data), :expects => [200], :method => 'PUT', :path => "routers/#{router_id}/remove_router_interface" ) end |
#request(params) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/fog/openstack/network.rb', line 276 def request(params) begin response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :path => "#{@path}/#{params[:path]}"#, })) rescue Excon::Errors::Unauthorized => error if error.response.body != 'Bad username or password' # token expiration @openstack_must_reauthenticate = true authenticate retry else # bad credentials raise error end rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Network::OpenStack::NotFound.slurp(error) else error end end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end |
#set_tenant(tenant) ⇒ Object
5 6 7 8 9 |
# File 'lib/fog/openstack/requests/network/set_tenant.rb', line 5 def set_tenant(tenant) @openstack_must_reauthenticate = true @openstack_tenant = tenant.to_s authenticate end |
#update_lb_health_monitor(health_monitor_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/network/update_lb_health_monitor.rb', line 5 def update_lb_health_monitor(health_monitor_id, = {}) data = { 'health_monitor' => {} } = [:delay, :timeout, :max_retries, :http_method, :url_path, :expected_codes, :admin_state_up] .select{ |o| .key?(o) }.each do |key| data['health_monitor'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "lb/health_monitors/#{health_monitor_id}" ) end |
#update_lb_member(member_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/network/update_lb_member.rb', line 5 def update_lb_member(member_id, = {}) data = { 'member' => {} } = [:pool_id, :weight, :admin_state_up] .select{ |o| .key?(o) }.each do |key| data['member'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "lb/members/#{member_id}" ) end |
#update_lb_pool(pool_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/network/update_lb_pool.rb', line 5 def update_lb_pool(pool_id, = {}) data = { 'pool' => {} } = [:name, :description, :lb_method, :admin_state_up] .select{ |o| .key?(o) }.each do |key| data['pool'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "lb/pools/#{pool_id}" ) end |
#update_lb_vip(vip_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/network/update_lb_vip.rb', line 5 def update_lb_vip(vip_id, = {}) data = { 'vip' => {} } = [:pool_id, :name, :description, :session_persistence, :connection_limit, :admin_state_up] .select{ |o| .key?(o) }.each do |key| data['vip'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "lb/vips/#{vip_id}" ) end |
#update_network(network_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/openstack/requests/network/update_network.rb', line 5 def update_network(network_id, = {}) data = { 'network' => {} } = [:name, :shared, :admin_state_up] .select{ |o| .key?(o) }.each do |key| data['network'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "networks/#{network_id}.json" ) end |
#update_port(port_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/requests/network/update_port.rb', line 5 def update_port(port_id, = {}) data = { 'port' => {} } = [:name, :fixed_ips, :admin_state_up, :device_owner, :device_id] .select{ |o| .key?(o) }.each do |key| data['port'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "ports/#{port_id}.json" ) end |
#update_quota(tenant_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/openstack/requests/network/update_quota.rb', line 5 def update_quota(tenant_id, = {}) request( :body => Fog::JSON.encode({ 'quota' => } ), :expects => 200, :method => 'PUT', :path => "/quotas/#{tenant_id}" ) end |
#update_router(router_id, options = {}) ⇒ Object
Update Router
Beyond the name and the administrative state, the only parameter which can be updated with this operation is the external gateway.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/openstack/requests/network/update_router.rb', line 11 def update_router(router_id, = {}) data = { 'router' => {} } [:name, :admin_state_up].each do |key| data['router'][key] = [key] if [key] end # remove this in a future egi = [:external_gateway_info] if egi if egi.is_a?(Fog::Network::OpenStack::Network) Fog::Logger.deprecation "Passing a model objects into options[:external_gateway_info] is deprecated. \ Please pass external external gateway as follows options[:external_gateway_info] = { :network_id => NETWORK_ID }]" data['router'][:external_gateway_info] = { :network_id => egi.id } elsif egi.is_a?(Hash) and egi[:network_id] data['router'][:external_gateway_info] = egi else raise ArgumentError.new('Invalid external_gateway_info attribute') end end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "routers/#{router_id}.json" ) end |
#update_subnet(subnet_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fog/openstack/requests/network/update_subnet.rb', line 5 def update_subnet(subnet_id, = {}) data = { 'subnet' => {} } = [:name, :gateway_ip, :dns_nameservers, :host_routes, :enable_dhcp] .select{ |o| .key?(o) }.each do |key| data['subnet'][key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "subnets/#{subnet_id}" ) end |