1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/requests/compute/resize_server.rb
2010-11-29 19:36:23 -08:00

80 lines
2.2 KiB
Ruby

module Fog
module Rackspace
class Compute
class Real
# Reboot an existing server
#
# ==== Parameters
# * server_id<~Integer> - Id of server to resize
# * size<~String> - new size. call list_flavors to get available flavors
#
def resize_server(server_id, flavor_id)
body = { 'resize' => { 'flavorId' => flavor_id }}
action(server_id, body)
end
# Confirm resizing
#
# ==== Parameters
# * server_id<~Integer> - Id of server to confirm
#
def confirm_resize(server_id)
body = { 'confirmResize' => nil }
action(server_id, body, 204)
end
# Revert resizing
#
# ==== Parameters
# * server_id<~Integer> - Id of server to revert
#
def revert_resize(server_id)
body = { 'revertResize' => nil }
action(server_id, body)
end
end
class Mock
def resize_server(server_id, flavor_id)
response = Excon::Response.new
response.status = 202
#I know this is weird... but I got to keep track of it
@data[:servers][server_id]['old_flavorId'] = @data[:servers][server_id]['flavorId']
@data[:servers][server_id]['flavorId'] = flavor_id
@data[:last_modified][:servers][server_id] = Time.now
@data[:servers][server_id]['status'] = 'VERIFY_RESIZE'
response
end
def confirm_resize(server_id)
response = Excon::Response.new
response.status = 204
@data[:last_modified][:servers][server_id] = Time.now
@data[:servers][server_id]['status'] = 'ACTIVE'
response
end
def revert_resize(server_id)
response = Excon::Response.new
response.status = 202
@data[:servers][server_id]['flavorId'] = @data[:servers][server_id]['old_flavorId']
@data[:servers][server_id].delete('old_flavorId')
@data[:last_modified][:servers][server_id] = Time.now
@data[:servers][server_id]['status'] = 'ACTIVE'
response
end
end
end
end
end