diff --git a/lib/fog/aws/requests/compute/start_instances.rb b/lib/fog/aws/requests/compute/start_instances.rb index f478affa9..102f6ea3d 100644 --- a/lib/fog/aws/requests/compute/start_instances.rb +++ b/lib/fog/aws/requests/compute/start_instances.rb @@ -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