Class: RackspaceCloud::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rackspace_cloud/server.rb

Constant Summary collapse

STATUS_VALUES =
%w{ACTIVE BUILD REBUILD SUSPENDED QUEUE_RESIZE PREP_RESIZE VERIFY_RESIZE PASSWORD RESCUE REBOOT HARD_REBOOT SHARE_IP SHARE_IP_NO_CONFIG DELETE_IP UNKNOWN}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_json) ⇒ Server

Returns a new instance of Server.



9
10
11
# File 'lib/rackspace_cloud/server.rb', line 9

def initialize(server_json)
  populate(server_json)
end

Instance Attribute Details

#adminPassObject (readonly)

Returns the value of attribute adminPass.



5
6
7
# File 'lib/rackspace_cloud/server.rb', line 5

def adminPass
  @adminPass
end

#flavorObject (readonly)

Returns the value of attribute flavor.



3
4
5
# File 'lib/rackspace_cloud/server.rb', line 3

def flavor
  @flavor
end

#host_idObject (readonly)

Returns the value of attribute host_id.



4
5
6
# File 'lib/rackspace_cloud/server.rb', line 4

def host_id
  @host_id
end

#imageObject (readonly)

Returns the value of attribute image.



3
4
5
# File 'lib/rackspace_cloud/server.rb', line 3

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rackspace_cloud/server.rb', line 3

def name
  @name
end

#private_ipsObject (readonly)

Returns the value of attribute private_ips.



5
6
7
# File 'lib/rackspace_cloud/server.rb', line 5

def private_ips
  @private_ips
end

#progressObject (readonly)

Returns the value of attribute progress.



4
5
6
# File 'lib/rackspace_cloud/server.rb', line 4

def progress
  @progress
end

#public_ipsObject (readonly)

Returns the value of attribute public_ips.



5
6
7
# File 'lib/rackspace_cloud/server.rb', line 5

def public_ips
  @public_ips
end

#rackspace_idObject (readonly)

Returns the value of attribute rackspace_id.



4
5
6
# File 'lib/rackspace_cloud/server.rb', line 4

def rackspace_id
  @rackspace_id
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/rackspace_cloud/server.rb', line 3

def status
  @status
end

Instance Method Details

#confirm_resizeObject



33
34
35
# File 'lib/rackspace_cloud/server.rb', line 33

def confirm_resize
  action_request('confirmResize' => nil)
end

#deleteObject



41
42
43
# File 'lib/rackspace_cloud/server.rb', line 41

def delete
  RackspaceCloud.request("/servers/#{@rackspace_id}", :method => :delete)
end

#hard_rebootObject



21
22
23
# File 'lib/rackspace_cloud/server.rb', line 21

def hard_reboot
  action_request('reboot' => {'type' => 'HARD'})      
end

#ready?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rackspace_cloud/server.rb', line 13

def ready?
  @status == 'ACTIVE'
end

#rebootObject



17
18
19
# File 'lib/rackspace_cloud/server.rb', line 17

def reboot
  action_request('reboot' => {'type' => 'SOFT'})
end

#rebuild(new_image = nil) ⇒ Object



25
26
27
# File 'lib/rackspace_cloud/server.rb', line 25

def rebuild(new_image=nil)
  action_request('rebuild' => {'imageId' => new_image ? new_image.to_i : image.to_i})      
end

#refreshObject

update this server’s status and progress by calling /servers/<id>



46
47
48
49
# File 'lib/rackspace_cloud/server.rb', line 46

def refresh
  populate(RackspaceCloud.request("/servers/#{@rackspace_id}")['server'])
  self
end

#resize(new_flavor) ⇒ Object



29
30
31
# File 'lib/rackspace_cloud/server.rb', line 29

def resize(new_flavor)
  action_request('resize' => {'flavorId' => new_flavor.to_i})
end

#revert_resizeObject



37
38
39
# File 'lib/rackspace_cloud/server.rb', line 37

def revert_resize
  action_request('revertResize' => nil)
end