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

#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #new_record?, #reload, #requires, #wait_for

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



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

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

#flavorObject



25
26
27
28
# File 'lib/fog/slicehost/models/server.rb', line 25

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

#imageObject



30
31
32
33
# File 'lib/fog/slicehost/models/server.rb', line 30

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

#ready?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fog/slicehost/models/server.rb', line 35

def ready?
  @status == 'active'
end

#reboot(type = 'SOFT') ⇒ Object



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

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

#saveObject



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

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