Sha256: 816fdce2786869955c6d4578efbd83d31e6c39529bc87debb4bd8d7b29f85b88

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 KB

Contents

require 'fog/model'

module Fog
  module Slicehost

    class Server < Fog::Model

      identity :id

      attribute :addresses
      attribute :backup_id,     'backup-id'
      attribute :bandwidth_in,  'bw-in'
      attribute :bandwidth_out, 'bw-out'
      attribute :flavor_id,     'flavor-id'
      attribute :image_id,      'image-id'
      attribute :name
      attribute :password,      'root-password'
      attribute :progress
      attribute :status

      def initialize(attributes={})
        @flavor_id ||= 1
        super
      end

      def destroy
        requires :id
        connection.delete_slice(@id)
        true
      end

      def flavor
        requires :flavor_id
        connection.flavors.get(@flavor_id)
      end

      def image
        requires :image_id
        connection.images.get(@image_id)
      end

      def ready?
        @status == 'active'
      end

      def reboot(type = 'SOFT')
        requires :id
        connection.reboot_server(@id, type)
        true
      end

      def save
        requires :flavor_id, :image_id, :name
        data = connection.create_slice(@flavor_id, @image_id, @name)
        merge_attributes(data.body)
        true
      end

    end

  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/slicehost/models/server.rb
fog-0.2.28 lib/fog/slicehost/models/server.rb
fog-0.2.27 lib/fog/slicehost/models/server.rb
fog-0.2.26 lib/fog/slicehost/models/server.rb
fog-0.2.25 lib/fog/slicehost/models/server.rb
fog-0.2.24 lib/fog/slicehost/models/server.rb
tecnh-fog-0.2.23.vpc lib/fog/slicehost/models/server.rb
fog-0.2.23 lib/fog/slicehost/models/server.rb
fog-0.2.22 lib/fog/slicehost/models/server.rb
fog-0.2.21 lib/fog/slicehost/models/server.rb
fog-0.2.20 lib/fog/slicehost/models/server.rb
fog-0.2.19 lib/fog/slicehost/models/server.rb
fog-0.2.18 lib/fog/slicehost/models/server.rb
fog-0.2.17 lib/fog/slicehost/models/server.rb
fog-0.2.16 lib/fog/slicehost/models/server.rb