blib/lib/VM/EC2/REST/private_ip.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 19 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 4 SCAR 25.1
CC
4
Cov
0%
assign_private_ip_addresses
20.0
unassign_private_ip_addresses
2.0
BEGIN
2.0
CRAP 12.3
1 package VM::EC2::REST::private_ip;
2  
3 use strict;
4 use VM::EC2 ''; # important not to import anything!
5 package VM::EC2; # add methods to VM::EC2
6  
7 VM::EC2::Dispatch->register(
8 AssignPrivateIpAddresses => 'boolean',
9 UnassignPrivateIpAddresses => 'boolean',
10 );
11  
12 =head1 NAME VM::EC2::REST::private_ip
13  
14 =head1 SYNOPSIS
15  
16 use VM::EC2 ':vpc';
17  
18 =head1 METHODS
19  
20 These methods allow you to control private IP addresses associated
21 with instances running in a VPC.
22  
23 =head2 $result = $ec2->assign_private_ip_addresses(%args)
24  
25 Assign one or more secondary private IP addresses to a network
26 interface. You can either set the addresses explicitly, or provide a
27 count of secondary addresses, and let Amazon select them for you.
28  
29 Required arguments:
30  
31 -network_interface_id The network interface to which the IP address(es)
32 will be assigned.
33  
34 -private_ip_address One or more secondary IP addresses, as a scalar string
35 -private_ip_addresses or array reference. (The two arguments are equivalent).
36  
37 Optional arguments:
38  
39 -allow_reassignment If true, allow assignment of an IP address is already in
40 use by another network interface or instance.
41  
42 The following are valid arguments to -private_ip_address:
43  
44 -private_ip_address => '192.168.0.12' # single address
45 -private_ip_address => ['192.168.0.12','192.168.0.13] # multiple addresses
46 -private_ip_address => 3 # autoselect three addresses
47  
48 The mixed form of address, such as ['192.168.0.12','auto'] is not allowed in this call.
49  
50 On success, this method returns true.
51  
52 =cut
53  
54 sub assign_private_ip_addresses {
55 my $self = shift;
56 my %args = $self->args(-network_interface_id => @_);
57 $args{-private_ip_address} ||= $args{-private_ip_addresses};
58 $args{-network_interface_id} && $args{-private_ip_address}
59 or croak "usage: assign_private_ip_addresses(-network_interface_id=>\$id,-private_ip_address=>\\\@addresses)";
60 my @parms = $self->single_parm('NetworkInterfaceId',\%args);
61  
62 if (!ref($args{-private_ip_address}) && $args{-private_ip_address} =~ /^\d+$/) {
63 push @parms,('SecondaryPrivateIpAddressCount' => $args{-private_ip_address});
64 } else {
65 push @parms,$self->list_parm('PrivateIpAddress',\%args);
66 }
67 push @parms,('AllowReassignment' => $args{-allow_reassignment} ? 'true' : 'false')
68 if exists $args{-allow_reassignment};
69 $self->call('AssignPrivateIpAddresses',@parms);
70 }
71  
72 =head2 $result = $ec2->unassign_private_ip_addresses(%args)
73  
74 Unassign one or more secondary private IP addresses from a network
75 interface.
76  
77 Required arguments:
78  
79 -network_interface_id The network interface to which the IP address(es)
80 will be assigned.
81  
82 -private_ip_address One or more secondary IP addresses, as a scalar string
83 -private_ip_addresses or array reference. (The two arguments are equivalent).
84  
85  
86 The following are valid arguments to -private_ip_address:
87  
88 -private_ip_address => '192.168.0.12' # single address
89 -private_ip_address => ['192.168.0.12','192.168.0.13] # multiple addresses
90  
91 On success, this method returns true.
92  
93 =cut
94  
95 sub unassign_private_ip_addresses {
96 my $self = shift;
97 my %args = $self->args(-network_interface_id => @_);
98 $args{-private_ip_address} ||= $args{-private_ip_addresses};
99 $args{-network_interface_id} && $args{-private_ip_address}
100 or croak "usage: assign_private_ip_addresses(-network_interface_id=>\$id,-private_ip_address=>\\\@addresses)";
101 my @parms = $self->single_parm('NetworkInterfaceId',\%args);
102 push @parms,$self->list_parm('PrivateIpAddress',\%args);
103 $self->call('UnassignPrivateIpAddresses',@parms);
104 }
105  
106 =head1 SEE ALSO
107  
108 L<VM::EC2>
109  
110 =head1 AUTHOR
111  
112 Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>.
113  
114 Copyright (c) 2011 Ontario Institute for Cancer Research
115  
116 This package and its accompanying libraries is free software; you can
117 redistribute it and/or modify it under the terms of the GPL (either
118 version 1, or at your option, any later version) or the Artistic
119 License 2.0. Refer to LICENSE for the full license text. In addition,
120 please see DISCLAIMER.txt for disclaimers of warranty.
121  
122 =cut
123  
124  
125 1;