Sha256: 4f60f60fa89faae5078330315a8c434690d98e33e0b1445ece20e82aa5cf68d2

Contents?: true

Size: 1.74 KB

Versions: 37

Compression:

Stored size: 1.74 KB

Contents

module Fog
  module AWS
    class Compute
      class Real
        require 'fog/aws/parsers/compute/get_console_output'

        # Retrieve console output for specified instance
        #
        # ==== Parameters
        # * instance_id<~String> - Id of instance to get console output from
        #
        # ==== Returns
        # # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'instanceId'<~String> - Id of instance
        #     * 'output'<~String> - Console output
        #     * 'requestId'<~String> - Id of request
        #     * 'timestamp'<~Time> - Timestamp of last update to output
        #
        # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetConsoleOutput.html]
        def get_console_output(instance_id)
          request(
            'Action'      => 'GetConsoleOutput',
            'InstanceId'  => instance_id,
            :idempotent   => true,
            :parser       => Fog::Parsers::AWS::Compute::GetConsoleOutput.new
          )
        end
      end

      class Mock
        def get_console_output(instance_id)
          response = Excon::Response.new
          if instance = self.data[:instances][instance_id]
            response.status = 200
            response.body = {
              'instanceId'    => instance_id,
              'output'        => (Time.now - instance['launchTime'] >= Fog::Mock.delay) ? nil : Fog::AWS::Mock.console_output,
              'requestId'     => Fog::AWS::Mock.request_id,
              'timestamp'     => Time.now
            }
            response
          else;
            raise Fog::AWS::Compute::NotFound.new("The instance ID '#{instance_id}' does not exist")
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.29.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.28.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.27.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.26.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.25.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.24.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.23.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.22.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.21.1 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.21.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.20.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.19.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.18.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.17.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.16.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.15.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.14.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.13.0 lib/fog/aws/requests/compute/get_console_output.rb
fog-aws-3.12.0 lib/fog/aws/requests/compute/get_console_output.rb