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

Mock aws compute start_instances

This commit is contained in:
Edward Muller 2012-05-30 21:43:28 -07:00
parent cc669ef68d
commit 65f933e7bf

View file

@ -27,6 +27,33 @@ module Fog
end
end
class Mock
def start_instances(instance_id)
instance_ids = Array(instance_id)
instance_set = self.data[:instances].values
instance_set = apply_tag_filters(instance_set, {'instance_id' => instance_ids}, 'instanceId')
if instance_set.empty?
raise Fog::Compute::AWS::NotFound.new("The instance ID '#{instance_ids.first}' does not exist")
else
response = Excon::Response.new
response.status = 200
response.body = {
'instancesSet' => instance_set.inject([]) do |ia, instance|
ia << {'currentState' => { 'code' => 0, 'name' => 'pending' },
'previousState' => instance['instanceState'],
'instanceId' => instance['instanceId'] }
instance['instanceState'] = {'code'=>0, 'name'=>'pending'}
ia
end
}
response
end
end
end
end
end
end