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_v2/update_server.rb
2013-01-14 13:51:29 -06:00

32 lines
1.1 KiB
Ruby

module Fog
module Compute
class RackspaceV2
class Real
def update_server(server_id, options={})
data = options.is_a?(Hash) ? options : { 'name' => options } #LEGACY - second parameter was previously server name
request(
:body => Fog::JSON.encode('server' => data),
:expects => [200],
:method => 'PUT',
:path => "servers/#{server_id}"
)
end
end
class Mock
def update_server(server_id, name)
server = self.data[:servers][server_id]
name.each_pair {|k,v| server[k] = v } if name.is_a?(Hash)
server['name'] = name if name.is_a?(String)
server_response = Fog::Rackspace::MockData.keep(server, 'id', 'name', 'hostId', 'created', 'updated', 'status', 'progress', 'user_id', 'tenant_id', 'links', 'metadata', 'accessIPv4', 'accessIPv6', 'OS-DCF:diskConfig', 'rax-bandwidth:bandwidth', 'addresses', 'flavor', 'links', 'image')
response(
:status => 200,
:body => {'server' => server_response}
)
end
end
end
end
end