blib/lib/VM/EC2/NetworkInterface/Attachment.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 26 CC 1 SCAR 6.9
CC
1
Cov
0%
valid_fields
2.0
short_name
2.0
device
2.0
CRAP 2.0
1 package VM::EC2::NetworkInterface::Attachment;
2  
3 =head1 NAME
4  
5 VM::EC2::NetworkInterface::Attachment -- Object representing attachment of a network interface to an instance
6  
7 =head1 SYNOPSIS
8  
9 use VM::EC2;
10 my $ec2 = VM::EC2->new(...);
11 my $instance = $ec2->describe_instances('i-123456');
12 my @interfaces = $instance->network_interfaces();
13 for my $i (@interfaces) {
14 my $attachment = $i->attachment;
15 my $att_id = $attachment->attachmentId;
16 my $ins_id = $attachment->instanceId;
17 my $instance = $attachment->instance;
18 my $device = $attachment->device;
19 my $status = $attachment->status;
20 my $time = $attachment->attachmentTime;
21 my $delete = $attachment->deleteOnTermination;
22 }
23  
24 =head1 DESCRIPTION
25  
26 This object describes the attachment of a elastic network interface
27 (ENI) to an instance, and allows you to manipulate the attachment.
28  
29 Please see L<VM::EC2::Generic> for methods shared by all VM::EC2
30 objects.
31  
32 =head1 METHODS
33  
34 These object methods are supported:
35  
36 attachmentId -- ID of the attachment
37 instanceId -- ID of the instance
38 instanceOwnerId -- ID of the owner of the instance
39 deviceIndex -- Ethernet device number, e.g. "0" for eth0
40 status -- Always "attached"; see below.
41 attachmentTime -- Time this ENI was attached to the instance, as a DateTime
42 deleteOnTermination -- If true, this ENI will be deleted when the instance terminates.
43  
44 Amazon does not document the network interface attachment object well,
45 and many of these fields are inferred by inspection of EC2 REST
46 responses. In particular, the status field always seems to be
47 "attached", but there may be another state, such as "pending", which
48 is too short lived to be apparent.
49  
50 In addition, this object supports the following convenience methods:
51  
52 instance -- The VM::EC2::Instance to which the ENI is attached.
53  
54 =head1 STRING OVERLOADING
55  
56 When used in a string context, this object will be interpolated as the
57 attachmentId.
58  
59 =head1 SEE ALSO
60  
61 L<VM::EC2>
62 L<VM::EC2::Generic>
63  
64 =head1 AUTHOR
65  
66 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
67  
68 Copyright (c) 2012 Ontario Institute for Cancer Research
69  
70 This package and its accompanying libraries is free software; you can
71 redistribute it and/or modify it under the terms of the GPL (either
72 version 1, or at your option, any later version) or the Artistic
73 License 2.0. Refer to LICENSE for the full license text. In addition,
74 please see DISCLAIMER.txt for disclaimers of warranty.
75  
76 =cut
77  
78 use strict;
79 use base 'VM::EC2::Generic';
80  
81 sub valid_fields { return qw(attachmentId instanceId instanceOwnerId deviceIndex status
82 attachTime deleteOnTermination) }
83  
84 sub short_name { shift->attachmentId }
85  
86 sub device { my $index = shift->deviceIndex; return "eth${index}"}
87  
88 sub instance {
89 my $self = shift;
90 my $id = $self->instanceId;
91 return $self->aws->describe_instances($id);
92 }
93  
94 sub deleteOnTermination {
95 return shift->SUPER::deleteOnTermination =~ /true/i;
96 }
97  
98  
99 1;