Sha256: d652af4f5e164e424a09bd73e4a09134c7ea27b9c9b195f273f81741d80f1960

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

require 'fog/vcloud/terremark/ecloud/models/server'

module Fog
  class Vcloud
    module Terremark
      class Ecloud

        class Servers < Fog::Vcloud::Collection

          undef_method :create

          model Fog::Vcloud::Terremark::Ecloud::Server

          attribute :href, :aliases => :Href

          def all
            load(_vapps)
          end

          def get(uri)
            if data = connection.get_vapp(uri)
              new(data.body)
            end
          rescue Fog::Errors::NotFound
            nil
          end

          def create( catalog_item_uri, options )
            options[:vdc_uri] = href
            options[:cpus] ||= 1
            options[:memory] ||= 512
            data = connection.instantiate_vapp_template( catalog_item_uri, options ).body
            object = new(data)
            object
          end

          private

          def _resource_entities
            connection.get_vdc(href).body[:ResourceEntities][:ResourceEntity]
          end

          def _vapps
            resource_entities = _resource_entities
            if resource_entities.nil?
              []
            else
              resource_entities
            end
          end

        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.3.16 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.15 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.14 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.13 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.12 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.11 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.10 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.9 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.8 lib/fog/vcloud/terremark/ecloud/models/servers.rb