| 1 | package VM::EC2::REST::private_ip; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use VM::EC2 ''; # important not to import anything! | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | package VM::EC2; # add methods to VM::EC2 | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | 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 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
assign_private_ip_addresses: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my %args = $self->args(-network_interface_id => @_); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | $args{-private_ip_address} ||= $args{-private_ip_addresses}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-private_ip_address"} ||= $args{"-private_ip_addresses"}
MC/DC0%0/2
$args{"-private_ip_address"} ||= $args{"-private_ip_addresses"}
$args{"-private_ip_address"}
$args{"-private_ip_addresses"}
Truth table0%0/3
A ||= B
A= $args{"-private_ip_address"}B= $args{"-private_ip_addresses"}
| |||||||||||||||||||||||||||||
| 58 | $args{-network_interface_id} && $args{-private_ip_address} | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | or croak "usage: assign_private_ip_addresses(-network_interface_id=>\$id,-private_ip_address=>\\\@addresses)"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"-network_interface_id"} and $args{"-private_ip_address"}
MC/DC0%0/2
$args{"-network_interface_id"} and $args{"-private_ip_address"}
$args{"-network_interface_id"}
$args{"-private_ip_address"}
Truth table0%0/3
A and B
A= $args{"-network_interface_id"}B= $args{"-private_ip_address"}
| |||||||||||||||||||||||||||||
| 60 | 0 | my @parms = $self->single_parm('NetworkInterfaceId',\%args); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (!ref($args{-private_ip_address}) && $args{-private_ip_address} =~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $args{"-private_ip_address"} and $args{"-private_ip_address"} =~ /^\d+$/
MC/DC0%0/2
not ref $args{"-private_ip_address"} and $args{"-private_ip_address"} =~ /^\d+$/
not ref $args{"-private_ip_address"}
$args{"-private_ip_address"} =~ /^\d+$/
Truth table0%0/3
not(A) and B
A= not ref $args{"-private_ip_address"}B= $args{"-private_ip_address"} =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 63 | 0 | push @parms,('SecondaryPrivateIpAddressCount' => $args{-private_ip_address}); | |||||||||||||||||||||||||||
| 64 | } else { | ||||||||||||||||||||||||||||
| 65 | 0 | push @parms,$self->list_parm('PrivateIpAddress',\%args); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | push @parms,('AllowReassignment' => $args{-allow_reassignment} ? 'true' : 'false') | ||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if exists $args{-allow_reassignment}; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 69 | 0 | $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 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
unassign_private_ip_addresses: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 97 | 0 | my %args = $self->args(-network_interface_id => @_); | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | $args{-private_ip_address} ||= $args{-private_ip_addresses}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-private_ip_address"} ||= $args{"-private_ip_addresses"}
MC/DC0%0/2
$args{"-private_ip_address"} ||= $args{"-private_ip_addresses"}
$args{"-private_ip_address"}
$args{"-private_ip_addresses"}
Truth table0%0/3
A ||= B
A= $args{"-private_ip_address"}B= $args{"-private_ip_addresses"}
| |||||||||||||||||||||||||||||
| 99 | $args{-network_interface_id} && $args{-private_ip_address} | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | or croak "usage: assign_private_ip_addresses(-network_interface_id=>\$id,-private_ip_address=>\\\@addresses)"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"-network_interface_id"} and $args{"-private_ip_address"}
MC/DC0%0/2
$args{"-network_interface_id"} and $args{"-private_ip_address"}
$args{"-network_interface_id"}
$args{"-private_ip_address"}
Truth table0%0/3
A and B
A= $args{"-network_interface_id"}B= $args{"-private_ip_address"}
| |||||||||||||||||||||||||||||
| 101 | 0 | my @parms = $self->single_parm('NetworkInterfaceId',\%args); | |||||||||||||||||||||||||||
| 102 | 0 | push @parms,$self->list_parm('PrivateIpAddress',\%args); | |||||||||||||||||||||||||||
| 103 | 0 | $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 | 1; | |||||||||||||||||||||||||||