Sha256: ec82c74f53443a1ec91815412cc403dff02f60461f1072b289e0045b395f6b9e

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

#
# Author:: Matheus Francisco Barra Mina (<mfbmina@gmail.com>)
# © Copyright IBM Corporation 2015.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
module Fog
  module Compute
    class Softlayer
      class Mock
        def get_bare_metal_server_by_ip(ip_address)
          response = Excon::Response.new
          response.body = @bare_metal_servers.map {|vm| vm if vm['primaryIpAddress'] == ip_address.to_s }.compact.first || {}
          response.status = response.body.empty? ? 404 : 200
          if response.status == 404
            response.body = {
              "error"=>"Unable to find object with ip of '#{ip_address}'.",
              "code"=>"SoftLayer_Exception_ObjectNotFound"
            }
          end
          response
        end
      end

      class Real
        def get_bare_metal_server_by_ip(ip_address)
          request(:hardware_server, :findByIpAddress, :body => "#{ip_address}", :http_method => :POST, :query => 'objectMask=mask[datacenter,tagReferences,memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents]')
        end
      end
    end
  end
end

Version data entries

19 entries across 17 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.1.4 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.1.3 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.1.2 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.1.1 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.1.0 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.0.3 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.0.2 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.0.1 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-1.0.0 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.7 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.6 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.5 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.4 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.3 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb
fog-softlayer-0.4.2 lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb