Sha256: a030500ebe6b57fb6058df3f6357f80920d6b5d267d4c09126d984a0f0ab755b

Contents?: true

Size: 1.47 KB

Versions: 92

Compression:

Stored size: 1.47 KB

Contents

module Fog
  module Compute
    class Ecloud
      class Real
        basic_request :get_servers
      end
      class Mock
        def get_servers(uri)
          if uri =~ /layoutgroups/i
            group_id        = id_from_uri(uri)
            group           = self.data[:groups][group_id]
            servers         = group[:VirtualMachines][:VirtualMachine]
            compute_pool_id = servers.first[:compute_pool_id] unless servers.empty?
            compute_pool    = self.data[:compute_pools][compute_pool_id] unless compute_pool_id.nil?
          elsif uri =~ /computepool/i
            compute_pool_id = id_from_uri(uri)
            compute_pool    = self.data[:compute_pools][compute_pool_id]
            servers = self.data[:servers].values.select{|cp| cp[:compute_pool_id] == compute_pool_id}
            servers = servers.map{|server| Fog::Ecloud.slice(server, :id, :compute_pool_id)}
          end

          links = if compute_pool.nil?
                    []
                  else
                    [Fog::Ecloud.keep(compute_pool, :name, :href, :type),]
                  end

          server_response = {:VirtualMachine => (servers.size > 1 ? servers : servers.first)} # GAH
          body = {
            :href  => uri,
            :type  => "application/vnd.tmrk.cloud.virtualMachine; type=collection",
            :Links => {
              :Link => links
            }
          }.merge(server_response)

          response(:body => body)
        end
      end
    end
  end
end

Version data entries

92 entries across 90 versions & 11 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/get_servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/get_servers.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/get_servers.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/requests/get_servers.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/ecloud/requests/compute/get_servers.rb
fog-ecloud-0.1.1 lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.1.0 lib/fog/compute/ecloud/requests/get_servers.rb
fog-ecloud-0.0.2 lib/fog/ecloud/requests/compute/get_servers.rb
fog-ecloud-0.0.1 lib/fog/ecloud/requests/compute/get_servers.rb
fog-1.25.0 lib/fog/ecloud/requests/compute/get_servers.rb
nsidc-fog-1.24.1 lib/fog/ecloud/requests/compute/get_servers.rb
fog-1.24.0 lib/fog/ecloud/requests/compute/get_servers.rb
ns-fog-1.22.11 lib/fog/ecloud/requests/compute/get_servers.rb
ns-fog-1.22.10 lib/fog/ecloud/requests/compute/get_servers.rb
ns-fog-1.22.9 lib/fog/ecloud/requests/compute/get_servers.rb
ns-fog-1.22.8 lib/fog/ecloud/requests/compute/get_servers.rb