| 1 | package VM::EC2::Instance::ConsoleOutput; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::ConsoleOutput - Object describing console output from | ||
| 6 | an Amazon EC2 instance | ||
| 7 | |||
| 8 | =head1 SYNOPSIS | ||
| 9 | |||
| 10 | use VM::EC2; | ||
| 11 | |||
| 12 | $ec2 = VM::EC2->new(...); | ||
| 13 | $instance = $ec2->describe_instance(-instance_id=>'i-123456'); | ||
| 14 | |||
| 15 | my $out = $instance->console_output; | ||
| 16 | |||
| 17 | print $out,"\n"; | ||
| 18 | my $ts = $out->timestamp; | ||
| 19 | my $instance = $out->instanceId; | ||
| 20 | |||
| 21 | =head1 DESCRIPTION | ||
| 22 | |||
| 23 | This object represents the output from the console of a Amazon EC2 | ||
| 24 | instance. The instance may be running, pending or stopped. It is | ||
| 25 | returned by VM::EC2->get_console_output(), as well as | ||
| 26 | VM::EC2::Instance->console_output. | ||
| 27 | |||
| 28 | Please see L<VM::EC2::Generic> for methods shared by all VM::EC2 | ||
| 29 | objects. | ||
| 30 | |||
| 31 | =head1 METHODS | ||
| 32 | |||
| 33 | These object methods are supported: | ||
| 34 | |||
| 35 | requestId -- ID of the request that generated this object | ||
| 36 | instanceId -- ID of the instance that generated this output | ||
| 37 | timestamp -- Time that this output was generated | ||
| 38 | output -- Text of the console output | ||
| 39 | |||
| 40 | =head1 STRING OVERLOADING | ||
| 41 | |||
| 42 | When used in a string context, this object will act as if its output() | ||
| 43 | method was called, allowing it to be printed or searched directly. | ||
| 44 | |||
| 45 | =head1 SEE ALSO | ||
| 46 | |||
| 47 | L<VM::EC2> | ||
| 48 | L<VM::EC2::Generic> | ||
| 49 | L<VM::EC2::Instance> | ||
| 50 | |||
| 51 | =head1 AUTHOR | ||
| 52 | |||
| 53 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 54 | |||
| 55 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||
| 56 | |||
| 57 | This package and its accompanying libraries is free software; you can | ||
| 58 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 59 | version 1, or at your option, any later version) or the Artistic | ||
| 60 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 61 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | use strict; | ||
| 66 | use base 'VM::EC2::Generic'; | ||
| 67 | use MIME::Base64; | ||
| 68 | |||
| 69 | use overload '""' => 'output', | ||
| 70 | fallback => 1; | ||
| 71 | |||
| 72 | sub valid_fields { | ||
| 73 | my $self = shift; | ||
| 74 | return $self->SUPER::valid_fields, | ||
| 75 | qw(requestId instanceId timestamp output); | ||
| 76 | } | ||
| 77 | |||
| 78 | sub output { | ||
| 79 | my $self = shift; | ||
| 80 | my $out = $self->SUPER::output; | ||
| 81 | return decode_base64($out); | ||
| 82 | } | ||
| 83 | |||
| 84 | 1; | ||
| 85 |