2010-03-16 18:46:21 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
module EC2
|
|
|
|
class Real
|
2009-09-11 23:47:32 -04:00
|
|
|
|
|
|
|
# Retrieve console output for specified instance
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * instance_id<~String> - Id of instance to get console output from
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# # * response<~Excon::Response>:
|
2009-09-11 23:47:32 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'instanceId'<~String> - Id of instance
|
|
|
|
# * 'output'<~String> - Console output
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'timestamp'<~Time> - Timestamp of last update to output
|
|
|
|
def get_console_output(instance_id)
|
2010-03-16 01:15:33 -04:00
|
|
|
request(
|
|
|
|
'Action' => 'GetConsoleOutput',
|
|
|
|
'InstanceId' => instance_id,
|
|
|
|
:parser => Fog::Parsers::AWS::EC2::GetConsoleOutput.new
|
|
|
|
)
|
2009-09-11 23:47:32 -04:00
|
|
|
end
|
|
|
|
|
2009-07-24 22:25:55 -04:00
|
|
|
end
|
|
|
|
|
2010-03-16 18:46:21 -04:00
|
|
|
class Mock
|
2009-09-11 23:47:32 -04:00
|
|
|
|
|
|
|
def get_console_output(instance_id)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2010-03-16 18:46:21 -04:00
|
|
|
if instance = @data[:instances][instance_id]
|
2009-09-11 23:47:32 -04:00
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'instanceId' => instance_id,
|
|
|
|
'output' => Fog::AWS::Mock.console_output,
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'timestamp' => Time.now
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response.status = 400
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
2009-09-11 23:47:32 -04:00
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-24 22:25:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|