Class: Fog::Rackspace::Servers::Server

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/servers/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, #to_json, #wait_for

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject


22
23
24
25
26
# File 'lib/fog/rackspace/models/servers/server.rb', line 22

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

#flavorObject


28
29
30
31
# File 'lib/fog/rackspace/models/servers/server.rb', line 28

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

#imageObject


33
34
35
36
# File 'lib/fog/rackspace/models/servers/server.rb', line 33

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

#imagesObject


38
39
40
41
# File 'lib/fog/rackspace/models/servers/server.rb', line 38

def images
  requires :id
  connection.images(:server => self)
end

#ready?Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/fog/rackspace/models/servers/server.rb', line 43

def ready?
  @status == 'ACTIVE'
end

#reboot(type = 'SOFT') ⇒ Object


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

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

#saveObject


53
54
55
56
57
58
59
60
# File 'lib/fog/rackspace/models/servers/server.rb', line 53

def save
  requires :flavor_id, :image_id, :name
  options = { 'metadata' => , 'personality' => @personality }
  options = options.reject {|key, value| value.nil?}
  data = connection.create_server(@flavor_id, @image_id, @name, options)
  merge_attributes(data.body['server'])
  true
end