Sha256: 9ebd1d2558445eb38f4a65c9d9e1513c3601a6d7c55e171b636c1dbe066ef989

Contents?: true

Size: 1.26 KB

Versions: 29

Compression:

Stored size: 1.26 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
            check_href!(:parent => "Vdc")
            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

29 entries across 29 versions & 3 rubygems

Version Path
fog-0.5.3 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.5.2 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.5.1 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.5.0 lib/fog/vcloud/terremark/ecloud/models/servers.rb
phpfog-fog-0.4.1.3 lib/fog/vcloud/terremark/ecloud/models/servers.rb
phpfog-fog-0.4.1.2 lib/fog/vcloud/terremark/ecloud/models/servers.rb
phpfog-fog-0.4.1.1 lib/fog/vcloud/terremark/ecloud/models/servers.rb
phpfog-fog-0.4.1 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.4.1 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.4.0 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.34 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.33 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.32 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.31 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.30 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.29 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.28 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.27 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.26 lib/fog/vcloud/terremark/ecloud/models/servers.rb
fog-0.3.25 lib/fog/vcloud/terremark/ecloud/models/servers.rb