mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ibm] Flesh out modify_instance and modify_key for different modes
This commit is contained in:
parent
fa5777c833
commit
81344bd96a
2 changed files with 29 additions and 28 deletions
|
@ -36,34 +36,31 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def modify_instance(instance_id, options={})
|
||||
def modify_instance(instance_id, params={})
|
||||
response = Excon::Response.new
|
||||
if params['state'] == 'restart'
|
||||
if instance_exists? instance_id
|
||||
if instance_exists? instance_id
|
||||
if params['state'] == 'restart'
|
||||
self.data[:instances][instance_id]["status"] = "8"
|
||||
self.data[:instances][instance_id]["keyName"] = key_name
|
||||
response.status = 200
|
||||
response.body = { "success" => true }
|
||||
else
|
||||
response.status = 404
|
||||
end
|
||||
elsif params['type'] == 'attach' || params['type'] == 'detach'
|
||||
if (instance_exists?(instance_id) && Fog::Storage[:ibm].volume_exists?(volume_id))
|
||||
# TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly.
|
||||
response.status = 415
|
||||
else
|
||||
response.status = 404
|
||||
end
|
||||
elsif params['name']
|
||||
if instance_exists?(instance_id)
|
||||
self.data[:instances][instance_id]["name"] = name
|
||||
elsif params['type'] == 'attach' || params['type'] == 'detach'
|
||||
if Fog::Storage[:ibm].volume_exists?(params['volume_id'])
|
||||
# TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly.
|
||||
response.status = 415
|
||||
else
|
||||
response.status = 404
|
||||
end
|
||||
elsif params['name']
|
||||
self.data[:instances][instance_id]["name"] = params['name']
|
||||
response.status = 200
|
||||
response.body = { "success" => true }
|
||||
elsif params['expirationTime']
|
||||
self.data[:instances][instance_id]["expirationTime"] = params['expirationTime']
|
||||
response.status = 200
|
||||
response.body = { "success" => true }
|
||||
else
|
||||
response.status = 404
|
||||
end
|
||||
else
|
||||
Fog::Mock.not_implemented
|
||||
response.status = 404
|
||||
end
|
||||
response
|
||||
end
|
||||
|
|
|
@ -27,17 +27,21 @@ module Fog
|
|||
|
||||
def modify_key(key_name, params={})
|
||||
response = Excon::Response.new
|
||||
if params['public_key']
|
||||
if key_exists? key_name
|
||||
if key_exists? key_name
|
||||
if params['public_key']
|
||||
self.data[:keys][key_name]['keyMaterial'] = public_key
|
||||
self.data[:keys][key_name]['lastModifiedTime'] = Fog::IBM::Mock.launch_time,
|
||||
response.status = 200
|
||||
response.body = {"success"=>true}
|
||||
else
|
||||
response.status = 404
|
||||
self.data[:keys][key_name]['lastModifiedTime'] = Fog::IBM::Mock.launch_time
|
||||
end
|
||||
if params['default']
|
||||
self.data[:keys].values.each do |key|
|
||||
key['default'] = false
|
||||
end
|
||||
self.data[:keys][key_name]['default'] = true
|
||||
end
|
||||
response.status = 200
|
||||
response.body = {"success"=>true}
|
||||
else
|
||||
Fog::Mock.not_implemented
|
||||
response.status = 404
|
||||
end
|
||||
response
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue