Sha256: 488021cd378dfb8a825364723268ac1c076923e6609983d159441b00ca4d061a

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

require 'fog/core/model'

module Fog
  module GoGrid
    class Compute

      class BlockInstantiationError < StandardError; end

      class Server < Fog::Model

        identity :id

        attribute :name
        attribute :image_id        # id or name
        attribute :ip
        attribute :memory       # server.ram
        attribute :state
        attribute :description  # Optional
        attribute :sandbox      # Optional. Default: False

        def initialize(attributes={})
          super
        end

        def destroy
          requires :id
          connection.grid_server_destroy(id)
          true
        end

        def image
          requires :image_id
          connection.grid_image_get(image_id)
        end

        def ready?
          @state == 'On'
        end

        def save
          raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
          requires :name, :image_id, :ip, :memory
          options['isSandbox'] = sandbox if sandbox
          options['server.ram'] = memory
          options['image'] = image_id
          data = connection.grid_server_add(name, image, ip, options)
          merge_attributes(data.body)
          true
        end

      end

    end

  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
phpfog-fog-0.4.1.1 lib/fog/compute/models/go_grid/server.rb
phpfog-fog-0.4.1 lib/fog/compute/models/go_grid/server.rb
fog-0.4.1 lib/fog/compute/models/go_grid/server.rb
fog-0.4.0 lib/fog/go_grid/models/compute/server.rb
fog-0.3.34 lib/fog/go_grid/models/compute/server.rb
fog-0.3.33 lib/fog/go_grid/models/compute/server.rb
fog-0.3.32 lib/fog/go_grid/models/compute/server.rb
fog-0.3.31 lib/fog/go_grid/models/compute/server.rb
fog-0.3.30 lib/fog/go_grid/models/compute/server.rb
fog-0.3.29 lib/fog/go_grid/models/compute/server.rb
fog-0.3.28 lib/fog/go_grid/models/compute/server.rb
fog-0.3.27 lib/fog/go_grid/models/compute/server.rb
fog-0.3.26 lib/fog/go_grid/models/compute/server.rb
fog-0.3.25 lib/fog/go_grid/models/compute/server.rb
fog-0.3.24 lib/fog/go_grid/models/compute/server.rb
bbcloud-0.8.1 lib/bbcloud/vendor/fog-0.3.23/lib/fog/go_grid/models/compute/server.rb
fog-0.3.23 lib/fog/go_grid/models/compute/server.rb