blib/lib/VM/EC2/Instance/State.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 30 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
code
2.0
name
2.0
CRAP 2.0
1 package VM::EC2::Instance::State;
2  
3 =head1 NAME
4  
5 VM::EC2::State - Object describing the state of an EC2 instance
6  
7 =head1 SYNOPSIS
8  
9 use VM::EC2;
10  
11 $ec2 = VM::EC2->new(...);
12 $instance = $ec2->describe_instances(-instance_id=>'i-12345');
13 $state = $instance->state;
14 $code = $state->code;
15 $name = $state->name;
16  
17 =head1 DESCRIPTION
18  
19 This object represents the state of an Amazon EC2 instance. It is
20 returned by calling the state() method of an VM::EC2::Instance,
21 and is also returned by VM::EC2->start_instances(), stop_instances() and
22 terminate_instances().
23  
24 =head1 METHODS
25  
26 These object methods are supported:
27
28 code -- The state code
29 name -- The state name
30  
31 Code Name
32 ---- -------
33 0 pending
34 16 running
35 32 shutting-down
36 48 terminated
37 64 stopping
38 80 stopped
39 272 <none>
40  
41 Code 272 is said to correspond to a problem with the instance host.
42  
43 =head1 STRING OVERLOADING
44  
45 When used in a string context, this object will interpolate the
46 name.
47  
48 =head1 SEE ALSO
49  
50 L<VM::EC2>
51 L<VM::EC2::Generic>
52 L<VM::EC2::State>
53 L<VM::EC2::Instance>
54  
55 =head1 AUTHOR
56  
57 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
58  
59 Copyright (c) 2011 Ontario Institute for Cancer Research
60  
61 This package and its accompanying libraries is free software; you can
62 redistribute it and/or modify it under the terms of the GPL (either
63 version 1, or at your option, any later version) or the Artistic
64 License 2.0. Refer to LICENSE for the full license text. In addition,
65 please see DISCLAIMER.txt for disclaimers of warranty.
66  
67 =cut
68  
69 use strict;
70 use overload '""' => 'name',
71 fallback => 1;
72  
73 sub new {
74 my $self = shift;
75 my $state = shift;
76 return bless \$state,ref $self || $self;
77 }
78  
79 sub code { ${shift()}->{code} }
80 sub name { ${shift()}->{name} }
81  
82 sub invalid_state {
83 my $self = shift;
84 my $aws = shift;
85 return $self->new({code=>undef,name=>'invalid'},$aws);
86 }
87  
88 1;