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:
parent
cc669ef68d
commit
65f933e7bf
1 changed files with 27 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue