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, #wait_for

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



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

def destroy
  requires :id

  connection.delete_server(@id)
  true
end

#imagesObject



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

def images
  requires :id

  connection.images(:server => self)
end

#reboot(type = 'SOFT') ⇒ Object



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

def reboot(type = 'SOFT')
  requires :id

  connection.reboot_server(@id, type)
  true
end

#saveObject



40
41
42
43
44
45
46
47
# File 'lib/fog/rackspace/models/servers/server.rb', line 40

def save
  requires :flavor_id, :image_id, :name
  options = { 'metadata' => @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