Sha256: 828ccc5b25cc77c0df8e81fb01c9374a9de6cf88382e36cf6f28682563739587

Contents?: true

Size: 1.42 KB

Versions: 10

Compression:

Stored size: 1.42 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class EC2

        # Reboot specified instances
        #
        # ==== Parameters
        # * instance_id<~Array> - Ids of instances to reboot
        #
        # ==== Returns
        # # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'return'<~Boolean> - success?
        def reboot_instances(instance_id = [])
          params = indexed_params('InstanceId', instance_id)
          request({
            'Action' => 'RebootInstances'
          }.merge!(params), Fog::Parsers::AWS::EC2::Basic.new)
        end

      end
    end
  end

else

  module Fog
    module AWS
      class EC2

        def reboot_instances(instance_id = [])
          response = Excon::Response.new
          instance_id = [*instance_id]
          if (Fog::AWS::EC2.data[:instances].keys & instance_id).length == instance_id.length
            for instance_id in instance_id
              Fog::AWS::EC2.data[:instances][instance_id]['status'] = 'rebooting'
            end
            response.status = 200
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id,
              'return'    => true
            }
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-0.0.41 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.40 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.39 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.38 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.37 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.36 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.35 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.34 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.33 lib/fog/aws/requests/ec2/reboot_instances.rb
fog-0.0.32 lib/fog/aws/requests/ec2/reboot_instances.rb