Class: Fog::Slicehost::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/slicehost/models/server.rb

Instance Attribute Summary

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods inherited from Model

#collection, #initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



21
22
23
24
25
# File 'lib/fog/slicehost/models/server.rb', line 21

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

#flavorObject



27
28
29
30
# File 'lib/fog/slicehost/models/server.rb', line 27

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

#imageObject



32
33
34
35
# File 'lib/fog/slicehost/models/server.rb', line 32

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

#ready?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/fog/slicehost/models/server.rb', line 37

def ready?
  @status == 'active'
end

#reboot(type = 'SOFT') ⇒ Object



41
42
43
44
45
# File 'lib/fog/slicehost/models/server.rb', line 41

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

#saveObject



47
48
49
50
51
52
# File 'lib/fog/slicehost/models/server.rb', line 47

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