1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

get_console_output

This commit is contained in:
Wesley Beary 2009-07-24 19:25:55 -07:00
parent b3d634e7a3
commit 97dda626ba
5 changed files with 81 additions and 1 deletions

View file

@ -23,6 +23,7 @@ require "#{parsers_directory}/describe_regions"
require "#{parsers_directory}/describe_security_groups"
require "#{parsers_directory}/describe_snapshots"
require "#{parsers_directory}/describe_volumes"
require "#{parsers_directory}/get_console_output"
require "#{parsers_directory}/run_instances"
require "#{parsers_directory}/terminate_instances"
@ -58,7 +59,7 @@ require "#{requests_directory}/describe_snapshots"
require "#{requests_directory}/describe_volumes"
# TODO: require "#{requests_directory}/detach_volume"
require "#{requests_directory}/disassociate_address"
# TODO: require "#{requests_directory}/get_console_output"
require "#{requests_directory}/get_console_output"
# TODO: require "#{requests_directory}/modify_image_attribute"
# TODO: require "#{requests_directory}/monitor_instances"
# TODO: require "#{requests_directory}/purchase_reserver_instances_offering"

View file

@ -0,0 +1,30 @@
module Fog
module Parsers
module AWS
module EC2
class GetConsoleOutput < Fog::Parsers::Base
def reset
@response = {}
end
def end_element(name)
case name
when 'instanceId'
@response[:instance_id] = @value
when 'output'
@response[:output] = Base64.decode64(@value)
when 'requestId'
@response[:request_id] = @value
when 'timestamp'
@response[:timestamp] = Time.parse(@value)
end
end
end
end
end
end
end

View file

@ -0,0 +1,26 @@
module Fog
module AWS
class EC2
# Retrieve console output for specified instance
#
# ==== Parameters
# * instance_id<~String> - Id of instance to get console output from
#
# ==== Returns
# # * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :instance_id<~String> - Id of instance
# * :output<~String> - Console output
# * :request_id<~String> - Id of request
# * :timestamp<~Time> - Timestamp of last update to output
def get_console_output(instance_id)
request({
'Action' => 'GetConsoleOutput',
'InstanceId' => instance_id
}, Fog::Parsers::AWS::EC2::GetConsoleOutput.new)
end
end
end
end

View file

@ -1,4 +1,5 @@
require 'rubygems'
require 'base64'
require 'nokogiri'
require 'time'

View file

@ -0,0 +1,22 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.get_console_output' do
before(:all) do
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body[:instances_set].first[:instance_id]
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes" do
actual = ec2.get_console_output(@instance_id)
p actual
# actual.body[:instance_id].should be_a(String)
# actual.body[:output].should be_a(String)
# actual.body[:request_id].should be_a(String)
# actual.body[:timestamp].should be_a(Time)
end
end