#### Global IP Address examples These examples all assume you have `~/.fog` which contains the following: ```yaml default: softlayer_username: example-username softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1 ``` ##### Create a connection to SoftLayer network ```ruby require 'fog/softlayer' @sl = Fog::Network[:softlayer] ``` Global IP addresses are accessed through the `Fog::Network::Softlayer::Ip` model. Unlike "normal" IP addresses they can be specifically created and destroyed (non-global IP addresses are created/destroyed via a subnet). ```ruby global_ips = @network.ips.select { |ip| ip.global? } # => [ , # , # note=nil, # assigned_to=nil # > # ] ``` Route an unrouted global IP to a specific server: ```ruby global_ip = @network.ips.select { |ip| ip.global? && !ip.routed? }.first # => global_ip.routed? # => false @compute = Fog::Compute[:softlayer] dest_server = @compute.servers.tagged_with(['production', 'frontend', 'hkg']).first # => dest_ip = @network.ips.by_address(dest_server.public_ip_address) # => global_ip.route(dest_ip) # => true global_ip.reload # => , # note=nil, # assigned_to=nil # > global_ip.routed? # => true ``` That same address to a different server: ```ruby global_ip = @network.ips.by_address('203.0.113.5') global_ip.destination.address # => 203.0.113.8 london_server = @compute.servers.tagged_with(['production', 'frontend', 'lon']).first # => dest_ip = @network.ips.by_address(london_server.public_ip_address) # => global_ip.route(dest_ip) # => true global_ip.reload # => global_ip.destination.address # => 203.0.113.9 ``` Unroute the same address: ```ruby global_ip = @network.ips.by_address('203.0.113.5') global_ip.routed? # => true global_ip.unroute # => true global_ip.reload # => global_ip.routed? # => false ``` Create new IPv4: *Note:* these methods are blocking and can take several seconds to respond. ```ruby @network.create_new_global_ipv4 # => ``` Create new IPv6: ```ruby @network.create_new_global_ipv6 # => ``` Destroy a global IP address: ```ruby ip = @network.ips.by_address('203.0.113.5') ip.global? # => true ip.destroy # => true ```