1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

fixes for rackspace mocks, update_server mocks

This commit is contained in:
Wesley Beary 2009-11-09 19:36:27 -08:00
parent fa1481e9f2
commit 44fb9f1064
4 changed files with 24 additions and 10 deletions

View file

@ -90,7 +90,7 @@ else
}
data['name'] = "slice#{data[:id]}"
data['adminPass'] = "#{data['name']}password"
Fog::Rackspace::Servers.data[:servers][data[:id]] = data
Fog::Rackspace::Servers.data[:servers][data['id']] = data
response.body = { 'server' => data }
response
end

View file

@ -9,11 +9,11 @@ unless Fog.mocking?
# ==== Parameters
# * id<~Integer> - Id of server to delete
#
def delete_server(id)
def delete_server(server_id)
request(
:expects => 202,
:method => 'DELETE',
:path => "servers/#{id}"
:path => "servers/#{server_id}"
)
end
@ -27,18 +27,19 @@ else
module Rackspace
class Servers
def delete_server(id)
def delete_server(server_id)
response = Fog::Response.new
if server = Fog::Rackspace::Servers.data[:servers][id]
if server = Fog::Rackspace::Servers.data[:servers][server_id]
if server['STATUS'] == 'BUILD'
response.status = 409
raise(Excon::Errors.status_error(200, 400, response))
raise(Excon::Errors.status_error(202, 400, response))
else
Fog::Rackspace::Servers.delete(id)
Fog::Rackspace::Servers.data.delete(server_id)
response.status = 202
end
else
response.status = 404
raise(Excon::Errors.status_error(202, 404, response))
end
response
end

View file

@ -9,9 +9,8 @@ unless Fog.mocking?
# ==== Parameters
# # server_id<~Integer> - Id of server to update
# * options<~Hash>:
# * name<~String> - New name for server
# * adminPass<~String> - New admin password for server
#
# * name<~String> - New name for server
def update_server(server_id, options = {})
request(
:body => options.to_json,
@ -31,7 +30,21 @@ else
module Rackspace
class Servers
def update_server
def update_server(server_id, options)
response = Fog::Response.new
if server = Fog::Rackspace::Servers.data[:servers][server_id]
if options['adminPass']
server['adminPass'] = options['adminPass']
end
if options['name']
server['name'] = options['name']
end
response.status = 204
else
response.status = 404
raise(Excon::Errors.status_error(202, 404, response))
end
response
end
end