[hp|compute_v2] Update rebuild method of the server model.

This commit is contained in:
Rupak Ganguly 2013-05-17 16:18:00 -04:00
parent 4aac8c6f5b
commit 6a97d92cc1
2 changed files with 4 additions and 11 deletions

View File

@ -186,9 +186,9 @@ module Fog
true
end
def rebuild(image_id, name, admin_pass=nil, options={})
def rebuild(image_id, name, options={})
requires :id
service.rebuild_server(id, image_id, name, admin_pass, options)
service.rebuild_server(id, image_id, name, options)
true
end
@ -210,11 +210,6 @@ module Fog
# true
#end
#def create_image(name, metadata={})
# requires :id
# service.create_image(id, name, metadata)
#end
def create_image(name, metadata = {})
requires :id
response = service.create_image(id, name, metadata)

View File

@ -18,13 +18,12 @@ module Fog
# * 'file'<~Hash>:
# * 'contents'<~String> - Contents of file (10kb total of contents)
# * 'path'<~String> - Path to file (255 bytes total of path strings)
def rebuild_server(server_id, image_id, name, admin_pass=nil, options={})
def rebuild_server(server_id, image_id, name, options={})
body = { 'rebuild' => {
'imageRef' => image_id,
'name' => name
}}
body['rebuild']['adminPass'] = admin_pass if admin_pass
l_options = ['metadata', 'accessIPv4', 'accessIPv6']
l_options.select{|o| options[o]}.each do |key|
body['rebuild'][key] = options[key]
@ -45,14 +44,13 @@ module Fog
class Mock
def rebuild_server(server_id, image_id, name, admin_pass=nil, options={})
def rebuild_server(server_id, image_id, name, options={})
if image = list_images_detail.body['images'].detect {|_| _['id'] == image_id}
if response = get_server_details(server_id)
response.body['server']['name'] = name
response.body['server']['image']['id'] = image_id
response.body['server']['image']['name'] = image['name']
response.body['server']['image']['links'] = image['links']
response.body['server']['adminPass'] = admin_pass
response.body['server']['status'] = 'REBUILD'
l_options = ['metadata', 'accessIPv4', 'accessIPv6']
l_options.select{|o| options[o]}.each do |key|