| 1 | package VM::EC2::REST::ebs; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | 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 | VM::EC2::Dispatch->register( | ||||||||||||||||||||||||||||||||||||||||||
| 8 | AttachVolume => 'VM::EC2::BlockDevice::Attachment', | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | CopySnapshot => sub { shift->{snapshotId} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | CreateSnapshot => 'VM::EC2::Snapshot', | |||||||||||||||||||||||||||||||||||||||||
| 11 | CreateVolume => 'VM::EC2::Volume', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | DeleteSnapshot => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | DeleteVolume => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | DescribeAvailabilityZones => 'fetch_items,availabilityZoneInfo,VM::EC2::AvailabilityZone', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | DescribeImages => 'fetch_items,imagesSet,VM::EC2::Image', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | DescribeInstanceStatus => 'fetch_items_iterator,instanceStatusSet,VM::EC2::Instance::StatusItem,instance_status', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | DescribeRegions => 'fetch_items,regionInfo,VM::EC2::Region', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | DescribeSecurityGroups => 'fetch_items,securityGroupInfo,VM::EC2::SecurityGroup', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | DescribeSnapshots => 'fetch_items,snapshotSet,VM::EC2::Snapshot', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | DescribeVolumeStatus => 'fetch_items_iterator,volumeStatusSet,VM::EC2::Volume::StatusItem,volume_status', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | DescribeVolumes => 'fetch_items,volumeSet,VM::EC2::Volume', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | DetachVolume => 'VM::EC2::BlockDevice::Attachment', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | EnableVolumeIO => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ModifySnapshotAttribute => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ResetSnapshotAttribute => 'boolean', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 7 | my $VEP = 'VM::EC2::ParmParser'; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | VM::EC2::REST::ebs - Modules for EC2 EBS volumes | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | use VM::EC2 ':standard'; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | The methods in this section allow you to query and manipulate EC2 EBS | ||||||||||||||||||||||||||||||||||||||||||
| 41 | volumes and snapshots. See L<VM::EC2::Volume> and L<VM::EC2::Snapshot> | ||||||||||||||||||||||||||||||||||||||||||
| 42 | for additional functionality provided through the object interface. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | Implemented: | ||||||||||||||||||||||||||||||||||||||||||
| 45 | AttachVolume | ||||||||||||||||||||||||||||||||||||||||||
| 46 | CopySnapshot | ||||||||||||||||||||||||||||||||||||||||||
| 47 | CreateSnapshot | ||||||||||||||||||||||||||||||||||||||||||
| 48 | CreateVolume | ||||||||||||||||||||||||||||||||||||||||||
| 49 | DeleteSnapshot | ||||||||||||||||||||||||||||||||||||||||||
| 50 | DeleteVolume | ||||||||||||||||||||||||||||||||||||||||||
| 51 | DescribeSnapshotAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 52 | DescribeSnapshots | ||||||||||||||||||||||||||||||||||||||||||
| 53 | DescribeVolumes | ||||||||||||||||||||||||||||||||||||||||||
| 54 | DescribeVolumeAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 55 | DescribeVolumeStatus | ||||||||||||||||||||||||||||||||||||||||||
| 56 | DetachVolume | ||||||||||||||||||||||||||||||||||||||||||
| 57 | EnableVolumeIO | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ModifySnapshotAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ModifyVolumeAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ResetSnapshotAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | Unimplemented: | ||||||||||||||||||||||||||||||||||||||||||
| 63 | (none) | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =head2 @v = $ec2->describe_volumes(-volume_id=>\@ids,-filter=>\%filters) | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | =head2 @v = $ec2->describe_volumes(@volume_ids) | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | Return a series of VM::EC2::Volume objects. Optional arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | -volume_id The id of the volume to fetch, either a string | ||||||||||||||||||||||||||||||||||||||||||
| 72 | scalar or an arrayref. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | -filter One or more filters to apply to the search | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | The -filter argument name can be omitted if there are no other | ||||||||||||||||||||||||||||||||||||||||||
| 77 | arguments you wish to pass. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | The full list of volume filters can be found at: | ||||||||||||||||||||||||||||||||||||||||||
| 80 | http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVolumes.html | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sub describe_volumes { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_volumes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my %args = $VEP->args(-volume_id,@_); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | list_parm => 'VolumeId', | ||||||||||||||||||||||||||||||||||||||||||
| 90 | filter_parm => 'Filter' | ||||||||||||||||||||||||||||||||||||||||||
| 91 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $self->call('DescribeVolumes',@params); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | =head2 $v = $ec2->create_volume(-availability_zone=>$zone,-snapshot_id=>$snapshotId,-size=>$size,-volume_type=>$type,-iops=>$iops,-encrypted=>$boolean) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | Create a volume in the specified availability zone and return | ||||||||||||||||||||||||||||||||||||||||||
| 98 | information about it. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | -availability_zone -- An availability zone from | ||||||||||||||||||||||||||||||||||||||||||
| 103 | describe_availability_zones (required) | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | -snapshot_id -- ID of a snapshot to use to build volume from. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | -size -- Size of the volume, in GB (between 1 and 1024). | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | One or both of -snapshot_id or -size are required. For convenience, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | you may abbreviate -availability_zone as -zone, and -snapshot_id as | ||||||||||||||||||||||||||||||||||||||||||
| 111 | -snapshot. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | Optional Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | -volume_type -- The volume type. "standard", "io1", or "gp2" | ||||||||||||||||||||||||||||||||||||||||||
| 116 | Default is "standard" | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | -iops -- The number of I/O operations per second (IOPS) that | ||||||||||||||||||||||||||||||||||||||||||
| 119 | the volume supports. Range is 100 to 4000. Required | ||||||||||||||||||||||||||||||||||||||||||
| 120 | when volume type is io1. IOPS must be 30-to-1 ratio | ||||||||||||||||||||||||||||||||||||||||||
| 121 | to size. ie: 3000 IOPS volume must be at least 100GB. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | -encrypted -- Specifies whether the volume should be encrypted. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | Encrypted Amazon EBS volumes may only be attached to | ||||||||||||||||||||||||||||||||||||||||||
| 125 | instances that support them. Volumes created from | ||||||||||||||||||||||||||||||||||||||||||
| 126 | encrypted snapshots are also encrypted using the same | ||||||||||||||||||||||||||||||||||||||||||
| 127 | key as the original volume. | ||||||||||||||||||||||||||||||||||||||||||
| 128 | See: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSEncryption.html | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | The returned object is a VM::EC2::Volume object. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | sub create_volume { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_volume: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $args{-availability_zone} ||= $args{-zone} or croak "-availability_zone argument is required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"-availability_zone"} ||= $args{"-zone"}
MC/DC0%0/2
$args{"-availability_zone"} ||= $args{"-zone"}
$args{"-availability_zone"}
$args{"-zone"}
Truth table0%0/3
A ||= B
A= $args{"-availability_zone"}B= $args{"-zone"}
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $args{-snapshot_id} ||= $args{-snapshot}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-snapshot_id"} ||= $args{"-snapshot"}
MC/DC0%0/2
$args{"-snapshot_id"} ||= $args{"-snapshot"}
$args{"-snapshot_id"}
$args{"-snapshot"}
Truth table0%0/3
A ||= B
A= $args{"-snapshot_id"}B= $args{"-snapshot"}
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $args{-snapshot_id} || $args{-size} or croak "One or both of -snapshot_id or -size are required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"-snapshot_id"} or $args{"-size"}
MC/DC0%0/2
$args{"-snapshot_id"} or $args{"-size"}
$args{"-snapshot_id"}
$args{"-size"}
Truth table0%0/3
A or B
A= $args{"-snapshot_id"}B= $args{"-size"}
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if (exists $args{-volume_type} && $args{-volume_type} eq 'io1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
exists $args{"-volume_type"} and $args{"-volume_type"} eq "io1"
MC/DC0%0/2
exists $args{"-volume_type"} and $args{"-volume_type"} eq "io1"
exists $args{"-volume_type"}
$args{"-volume_type"} eq "io1"
Truth table0%0/3
A and B
A= exists $args{"-volume_type"}B= $args{"-volume_type"} eq "io1"
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $args{-iops} or croak "Argument -iops required when -volume_type is 'io1'"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | elsif ($args{-iops}) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | croak "Argument -iops cannot be used when volume type is 'standard'"; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | single_parm => [qw(AvailabilityZone SnapshotId Size VolumeType Iops)], | ||||||||||||||||||||||||||||||||||||||||||
| 150 | boolean_parm => 'Encrypted' | ||||||||||||||||||||||||||||||||||||||||||
| 151 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return $self->call('CreateVolume',@params); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | =head2 $result = $ec2->delete_volume($volume_id); | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | Deletes the specified volume. Returns a boolean indicating success of | ||||||||||||||||||||||||||||||||||||||||||
| 158 | the delete operation. Note that a volume will remain in the "deleting" | ||||||||||||||||||||||||||||||||||||||||||
| 159 | state for some time after this call completes. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | sub delete_volume { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_volume: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my %args = $VEP->args(-volume_id => @_); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my @param = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | single_parm => 'VolumeId' | ||||||||||||||||||||||||||||||||||||||||||
| 169 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return $self->call('DeleteVolume',@param); | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | =head2 $attachment = $ec2->attach_volume($volume_id,$instance_id,$device); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | =head2 $attachment = $ec2->attach_volume(-volume_id=>$volume_id,-instance_id=>$instance_id,-device=>$device); | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | Attaches the specified volume to the instance using the indicated | ||||||||||||||||||||||||||||||||||||||||||
| 179 | device. All arguments are required: | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | -volume_id -- ID of the volume to attach. The volume must be in | ||||||||||||||||||||||||||||||||||||||||||
| 182 | "available" state. | ||||||||||||||||||||||||||||||||||||||||||
| 183 | -instance_id -- ID of the instance to attach to. Both instance and | ||||||||||||||||||||||||||||||||||||||||||
| 184 | attachment must be in the same availability zone. | ||||||||||||||||||||||||||||||||||||||||||
| 185 | -device -- How the device is exposed to the instance, e.g. | ||||||||||||||||||||||||||||||||||||||||||
| 186 | '/dev/sdg'. | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | The result is a VM::EC2::BlockDevice::Attachment object which | ||||||||||||||||||||||||||||||||||||||||||
| 189 | you can monitor by calling current_status(): | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | my $a = $ec2->attach_volume('vol-12345','i-12345','/dev/sdg'); | ||||||||||||||||||||||||||||||||||||||||||
| 192 | while ($a->current_status ne 'attached') { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | sleep 2; | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | print "volume is ready to go\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | or more simply | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | my $a = $ec2->attach_volume('vol-12345','i-12345','/dev/sdg'); | ||||||||||||||||||||||||||||||||||||||||||
| 200 | $ec2->wait_for_attachments($a); | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | sub attach_volume { | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attach_volume: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ($_[0] !~ /^-/ && @_ == 3) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $_[0] =~ /^-/ and @_ == 3
MC/DC0%0/2
not $_[0] =~ /^-/ and @_ == 3
not $_[0] =~ /^-/
@_ == 3
Truth table0%0/3
not(A) and B
A= not $_[0] =~ /^-/B= @_ == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | @args{qw(-volume_id -instance_id -device)} = @_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | $args{-volume_id} && $args{-instance_id} && $args{-device} or | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | croak "-volume_id, -instance_id and -device arguments must all be specified"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$args{"-volume_id"} and $args{"-instance_id"} and $args{"-device"}
$args{"-volume_id"} and $args{"-instance_id"}
MC/DC0%0/3
$args{"-volume_id"} and $args{"-instance_id"} and $args{"-device"}
$args{"-volume_id"}
$args{"-instance_id"}
$args{"-device"}
Truth table0%0/4
A and B and C
A= $args{"-volume_id"}B= $args{"-instance_id"}C= $args{"-device"}
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my @param = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | single_parm => [qw(VolumeId InstanceId Device)] | ||||||||||||||||||||||||||||||||||||||||||
| 217 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return $self->call('AttachVolume',@param); | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =head2 $attachment = $ec2->detach_volume($volume_id) | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =head2 $attachment = $ec2->detach_volume(-volume_id=>$volume_id,-instance_id=>$instance_id, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | -device=>$device, -force=>$force); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | Detaches the specified volume from an instance. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | -volume_id -- ID of the volume to detach. (required) | ||||||||||||||||||||||||||||||||||||||||||
| 229 | -instance_id -- ID of the instance to detach from. (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 230 | -device -- How the device is exposed to the instance. (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 231 | -force -- Force detachment, even if previous attempts were | ||||||||||||||||||||||||||||||||||||||||||
| 232 | unsuccessful. (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | The result is a VM::EC2::BlockDevice::Attachment object which | ||||||||||||||||||||||||||||||||||||||||||
| 236 | you can monitor by calling current_status(): | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | my $a = $ec2->detach_volume('vol-12345'); | ||||||||||||||||||||||||||||||||||||||||||
| 239 | while ($a->current_status ne 'detached') { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | sleep 2; | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | print "volume is ready to go\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | Or more simply: | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | my $a = $ec2->detach_volume('vol-12345'); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | $ec2->wait_for_attachments($a); | ||||||||||||||||||||||||||||||||||||||||||
| 248 | print "volume is ready to go\n" if $a->current_status eq 'detached'; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | sub detach_volume { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach_volume: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my %args = $VEP->args(-volume_id => @_); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my @param = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | single_parm => [qw(VolumeId InstanceId Device)], | ||||||||||||||||||||||||||||||||||||||||||
| 259 | boolean_parm => 'Force' | ||||||||||||||||||||||||||||||||||||||||||
| 260 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return $self->call('DetachVolume',@param); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | =head2 $ec2->wait_for_attachments(@attachment) | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | Wait for all members of the provided list of | ||||||||||||||||||||||||||||||||||||||||||
| 267 | VM::EC2::BlockDevice::Attachment objects to reach some terminal state | ||||||||||||||||||||||||||||||||||||||||||
| 268 | ("attached" or "detached"), and then return a hash reference that maps | ||||||||||||||||||||||||||||||||||||||||||
| 269 | each attachment to its final state. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | Typical usage: | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | my $i = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 274 | my $instance = 'i-12345'; | ||||||||||||||||||||||||||||||||||||||||||
| 275 | my @attach; | ||||||||||||||||||||||||||||||||||||||||||
| 276 | foreach (@volume) { | ||||||||||||||||||||||||||||||||||||||||||
| 277 | push @attach,$_->attach($instance,'/dev/sdf'.$i++; | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | my $s = $ec2->wait_for_attachments(@attach); | ||||||||||||||||||||||||||||||||||||||||||
| 280 | my @failed = grep($s->{$_} ne 'attached'} @attach; | ||||||||||||||||||||||||||||||||||||||||||
| 281 | warn "did not attach: ",join ', ',@failed; | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | If no terminal state is reached within a set timeout, then this method | ||||||||||||||||||||||||||||||||||||||||||
| 284 | returns undef and sets $ec2->error_str() to a suitable message. The | ||||||||||||||||||||||||||||||||||||||||||
| 285 | timeout, which defaults to 10 minutes (600 seconds), can be get or set | ||||||||||||||||||||||||||||||||||||||||||
| 286 | with $ec2->wait_for_timeout(). | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub wait_for_attachments { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_for_attachments: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $self->wait_for_terminal_state(\@_, | |||||||||||||||||||||||||||||||||||||||||
| 293 | ['attached','detached'], | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $self->wait_for_timeout); | ||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | =head2 @v = $ec2->describe_volume_status(@volume_ids) | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | =head2 @v = $ec2->describe_volume_status(\%filters) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =head2 @v = $ec2->describe_volume_status(-volume_id=>\@ids,-filter=>\%filters) | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Return a series of VM::EC2::Volume::StatusItem objects. Optional arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | -volume_id The id of the volume to fetch, either a string | ||||||||||||||||||||||||||||||||||||||||||
| 306 | scalar or an arrayref. | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | -filter One or more filters to apply to the search | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | -max_results Maximum number of items to return (must be more than | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 5). | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | The -filter argument name can be omitted if there are no other | ||||||||||||||||||||||||||||||||||||||||||
| 314 | arguments you wish to pass. | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | The full list of volume filters can be found at: | ||||||||||||||||||||||||||||||||||||||||||
| 317 | http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVolumeStatus.html | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | If -max_results is specified, then the call will return at most the | ||||||||||||||||||||||||||||||||||||||||||
| 320 | number of volume status items you requested. You may see whether there | ||||||||||||||||||||||||||||||||||||||||||
| 321 | are additional results by calling more_volume_status(), and then | ||||||||||||||||||||||||||||||||||||||||||
| 322 | retrieve the next set of results with additional call(s) to | ||||||||||||||||||||||||||||||||||||||||||
| 323 | describe_volume_status(): | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | my @results = $ec2->describe_volume_status(-max_results => 10); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | do_something(\@results); | ||||||||||||||||||||||||||||||||||||||||||
| 327 | while ($ec2->more_volume_status) { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | @results = $ec2->describe_volume_status; | ||||||||||||||||||||||||||||||||||||||||||
| 329 | do_something(\@results); | ||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | sub more_volume_status { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
more_volume_status: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | return $self->{volume_status_token} && | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | !$self->{volume_status_stop}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'volume_status_token'} && !$self->{'volume_status_stop'}
MC/DC0%0/2
$self->{'volume_status_token'} && !$self->{'volume_status_stop'}
$self->{'volume_status_token'}
!$self->{'volume_status_stop'}
Truth table0%0/3
A && not(B)
A= $self->{'volume_status_token'}B= !$self->{'volume_status_stop'}
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | sub describe_volume_status { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_volume_status: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my @parms; | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if (!@_ && $self->{volume_status_token} && $self->{volume_status_args}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not @_ and $self->{"volume_status_token"} and $self->{"volume_status_args"}
not @_ and $self->{"volume_status_token"}
MC/DC0%0/3
not @_ and $self->{"volume_status_token"} and $self->{"volume_status_args"}
not @_
$self->{"volume_status_token"}
$self->{"volume_status_args"}
Truth table0%0/4
not(A) and B and C
A= not @_B= $self->{"volume_status_token"}C= $self->{"volume_status_args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | @parms = (@{$self->{volume_status_args}},NextToken=>$self->{volume_status_token}); | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my %args = $VEP->args('-volume_id',@_); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my @parms = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | list_parm => 'VolumeId', | ||||||||||||||||||||||||||||||||||||||||||
| 353 | filter_parm => 'Filter', | ||||||||||||||||||||||||||||||||||||||||||
| 354 | single_parm => 'MaxResults' | ||||||||||||||||||||||||||||||||||||||||||
| 355 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ($args{-max_results}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $self->{volume_status_token} = 'xyzzy'; # dummy value | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $self->{volume_status_args} = \@parms; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $self->call('DescribeVolumeStatus',@parms); | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | =head2 $ec2->wait_for_volumes(@volumes) | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | Wait for all members of the provided list of volumes to reach some | ||||||||||||||||||||||||||||||||||||||||||
| 368 | terminal state ("available", "in-use", "deleted" or "error"), and then | ||||||||||||||||||||||||||||||||||||||||||
| 369 | return a hash reference that maps each volume ID to its final state. | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | If no terminal state is reached within a set timeout, then this method | ||||||||||||||||||||||||||||||||||||||||||
| 372 | returns undef and sets $ec2->error_str() to a suitable message. The | ||||||||||||||||||||||||||||||||||||||||||
| 373 | timeout, which defaults to 10 minutes (600 seconds), can be get or set | ||||||||||||||||||||||||||||||||||||||||||
| 374 | with $ec2->wait_for_timeout(). | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | sub wait_for_volumes { | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_for_volumes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->wait_for_terminal_state(\@_, | |||||||||||||||||||||||||||||||||||||||||
| 381 | ['available','in-use','deleted','error'], | ||||||||||||||||||||||||||||||||||||||||||
| 382 | $self->wait_for_timeout); | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =head2 @data = $ec2->describe_volume_attribute($volume_id,$attribute) | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | This method returns volume attributes. Only one attribute can be | ||||||||||||||||||||||||||||||||||||||||||
| 388 | retrieved at a time. The following is the list of attributes that can be | ||||||||||||||||||||||||||||||||||||||||||
| 389 | retrieved: | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | autoEnableIO -- boolean | ||||||||||||||||||||||||||||||||||||||||||
| 392 | productCodes -- list of scalar | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | These values can be retrieved more conveniently from the | ||||||||||||||||||||||||||||||||||||||||||
| 395 | L<VM::EC2::Volume> object returned from describe_volumes(): | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | $volume->auto_enable_io(1); | ||||||||||||||||||||||||||||||||||||||||||
| 398 | @codes = $volume->product_codes; | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | sub describe_volume_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_volume_attribute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | @_ == 2 or croak "Usage: describe_volume_attribute(\$instance_id,\$attribute_name)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my ($instance_id,$attribute) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my @param = (VolumeId=>$instance_id,Attribute=>$attribute); | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $result = $self->call('DescribeVolumeAttribute',@param); | |||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | return $result && $result->attribute($attribute); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$result && $result->attribute($attribute)
MC/DC0%0/2
$result && $result->attribute($attribute)
$result
$result->attribute($attribute)
Truth table0%0/3
A && B
A= $resultB= $result->attribute($attribute)
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | sub modify_volume_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modify_volume_attribute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | my $volume_id = shift or croak "Usage: modify_volume_attribute(\$volumeId,%param)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my @param = (VolumeId=>$volume_id); | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | push @param,('AutoEnableIO.Value'=>$args{-auto_enable_io} ? 'true':'false'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | return $self->call('ModifyVolumeAttribute',@param); | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | =head2 $boolean = $ec2->enable_volume_io($volume_id) | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | =head2 $boolean = $ec2->enable_volume_io(-volume_id=>$volume_id) | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | Given the ID of a volume whose I/O has been disabled (e.g. due to | ||||||||||||||||||||||||||||||||||||||||||
| 425 | hardware degradation), this method will reenable the I/O and return | ||||||||||||||||||||||||||||||||||||||||||
| 426 | true if successful. | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | sub enable_volume_io { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_volume_io: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my %args = $self->args('-volume_id',@_); | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | $args{-volume_id} or croak "Usage: enable_volume_io(\$volume_id)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @param = $self->single_parm('VolumeId',\%args); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | return $self->call('EnableVolumeIO',@param); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | =head2 @snaps = $ec2->describe_snapshots(@snapshot_ids) | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | =head2 @snaps = $ec2->describe_snapshots(-snapshot_id=>\@ids,%other_args) | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | Returns a series of VM::EC2::Snapshot objects. All arguments | ||||||||||||||||||||||||||||||||||||||||||
| 443 | are optional: | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | -snapshot_id ID of the snapshot | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | -owner Filter by owner ID | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | -restorable_by Filter by IDs of a user who is allowed to restore | ||||||||||||||||||||||||||||||||||||||||||
| 450 | the snapshot | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | -filter Tags and other filters | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | The -filter argument name can be omitted if there are no other | ||||||||||||||||||||||||||||||||||||||||||
| 455 | arguments you wish to pass. | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | The full list of applicable filters can be found at | ||||||||||||||||||||||||||||||||||||||||||
| 458 | http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSnapshots.html | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | sub describe_snapshots { | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_snapshots: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my %args = $VEP->args('-snapshot_id',@_); | |||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||||||||||
| 468 | list_parm => [qw(SnapshotId Owner RestorableBy)], | ||||||||||||||||||||||||||||||||||||||||||
| 469 | filter_parm => 'Filter' | ||||||||||||||||||||||||||||||||||||||||||
| 470 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | return $self->call('DescribeSnapshots',@params); | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | =head2 @data = $ec2->describe_snapshot_attribute($snapshot_id,$attribute) | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | This method returns snapshot attributes. The first argument is the | ||||||||||||||||||||||||||||||||||||||||||
| 477 | snapshot ID, and the second is the name of the attribute to | ||||||||||||||||||||||||||||||||||||||||||
| 478 | fetch. Currently Amazon defines two attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | createVolumePermission -- return a list of user Ids who are | ||||||||||||||||||||||||||||||||||||||||||
| 481 | allowed to create volumes from this snapshot. | ||||||||||||||||||||||||||||||||||||||||||
| 482 | productCodes -- product codes for this snapshot | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | The result is a raw hash of attribute values. Please see | ||||||||||||||||||||||||||||||||||||||||||
| 485 | L<VM::EC2::Snapshot> for a more convenient way of accessing and | ||||||||||||||||||||||||||||||||||||||||||
| 486 | modifying snapshot attributes. | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | sub describe_snapshot_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_snapshot_attribute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | @_ == 2 or croak "Usage: describe_snapshot_attribute(\$instance_id,\$attribute_name)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my ($snapshot_id,$attribute) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my @param = (SnapshotId=>$snapshot_id,Attribute=>$attribute); | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $result = $self->call('DescribeSnapshotAttribute',@param); | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | return $result && $result->attribute($attribute); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$result && $result->attribute($attribute)
MC/DC0%0/2
$result && $result->attribute($attribute)
$result
$result->attribute($attribute)
Truth table0%0/3
A && B
A= $resultB= $result->attribute($attribute)
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =head2 $boolean = $ec2->modify_snapshot_attribute($snapshot_id,-$argument=>$value) | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | This method changes snapshot attributes. The first argument is the | ||||||||||||||||||||||||||||||||||||||||||
| 502 | snapshot ID, and this is followed by an attribute modification command | ||||||||||||||||||||||||||||||||||||||||||
| 503 | and the value to change it to. | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | Currently the only attribute that can be changed is the | ||||||||||||||||||||||||||||||||||||||||||
| 506 | createVolumeAttribute. This is done through the following arguments | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | -createvol_add_user -- scalar or arrayref of UserIds to grant create volume permissions to | ||||||||||||||||||||||||||||||||||||||||||
| 509 | -createvol_add_group -- scalar or arrayref of Groups to remove create volume permissions from | ||||||||||||||||||||||||||||||||||||||||||
| 510 | (only currently valid value is "all") | ||||||||||||||||||||||||||||||||||||||||||
| 511 | -createvol_remove_user -- scalar or arrayref of UserIds to remove from create volume permissions | ||||||||||||||||||||||||||||||||||||||||||
| 512 | -createvol_remove_group -- scalar or arrayref of Groups to remove from create volume permissions | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | You can abbreviate these to -add_user, -add_group, -remove_user, -remove_group, etc. | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | See L<VM::EC2::Snapshot> for more convenient methods for interrogating | ||||||||||||||||||||||||||||||||||||||||||
| 517 | and modifying the create volume permissions. | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | sub modify_snapshot_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modify_snapshot_attribute: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | my $snapshot_id = shift or croak "Usage: modify_snapshot_attribute(\$snapshotId,%param)"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | # shortcuts | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | foreach (qw(add_user remove_user add_group remove_group)) { | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | $args{"-createvol_$_"} ||= $args{"-$_"}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-createvol_$_"} ||= $args{"-$_"}
MC/DC0%0/2
$args{"-createvol_$_"} ||= $args{"-$_"}
$args{"-createvol_$_"}
$args{"-$_"}
Truth table0%0/3
A ||= B
A= $args{"-createvol_$_"}B= $args{"-$_"}
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my @param = (SnapshotId=>$snapshot_id); | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | push @param,$self->create_volume_perm_parm('Add','UserId', $args{-createvol_add_user}); | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | push @param,$self->create_volume_perm_parm('Remove','UserId',$args{-createvol_remove_user}); | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | push @param,$self->create_volume_perm_parm('Add','Group', $args{-createvol_add_group}); | |||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | push @param,$self->create_volume_perm_parm('Remove','Group', $args{-createvol_remove_group}); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return $self->call('ModifySnapshotAttribute',@param); | |||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | =head2 $boolean = $ec2->reset_snapshot_attribute($snapshot_id,$attribute) | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | This method resets an attribute of the given snapshot to its default | ||||||||||||||||||||||||||||||||||||||||||
| 542 | value. The only valid attribute at this time is | ||||||||||||||||||||||||||||||||||||||||||
| 543 | "createVolumePermission." | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | sub reset_snapshot_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_snapshot_attribute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | @_ == 2 or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | croak "Usage: reset_snapshot_attribute(\$snapshotId,\$attribute_name)"; | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my ($snapshot_id,$attribute) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my %valid = map {$_=>1} qw(createVolumePermission); | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | $valid{$attribute} or croak "attribute to reset must be 'createVolumePermission'"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | return $self->call('ResetSnapshotAttribute', | |||||||||||||||||||||||||||||||||||||||||
| 555 | SnapshotId => $snapshot_id, | ||||||||||||||||||||||||||||||||||||||||||
| 556 | Attribute => $attribute); | ||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | =head2 $snapshot = $ec2->create_snapshot($volume_id) | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | =head2 $snapshot = $ec2->create_snapshot(-volume_id=>$vol,-description=>$desc) | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | Snapshot the EBS volume and store it to S3 storage. To ensure a | ||||||||||||||||||||||||||||||||||||||||||
| 565 | consistent snapshot, the volume should be unmounted prior to | ||||||||||||||||||||||||||||||||||||||||||
| 566 | initiating this operation. | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | -volume_id -- ID of the volume to snapshot (required) | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | -description -- A description to add to the snapshot (optional) | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | The return value is a VM::EC2::Snapshot object that can be queried | ||||||||||||||||||||||||||||||||||||||||||
| 575 | through its current_status() interface to follow the progress of the | ||||||||||||||||||||||||||||||||||||||||||
| 576 | snapshot operation. | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | Another way to accomplish the same thing is through the | ||||||||||||||||||||||||||||||||||||||||||
| 579 | VM::EC2::Volume interface: | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | my $volume = $ec2->describe_volumes(-filter=>{'tag:Name'=>'AccountingData'}); | ||||||||||||||||||||||||||||||||||||||||||
| 582 | $s = $volume->create_snapshot("Backed up at ".localtime); | ||||||||||||||||||||||||||||||||||||||||||
| 583 | while ($s->current_status eq 'pending') { | ||||||||||||||||||||||||||||||||||||||||||
| 584 | print "Progress: ",$s->progress,"% done\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | print "Snapshot status: ",$s->current_status,"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | sub create_snapshot { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_snapshot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my %args = $VEP->args('-volume_id',@_); | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 594 | { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | single_parm => ['VolumeId','Description'] | ||||||||||||||||||||||||||||||||||||||||||
| 596 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | return $self->call('CreateSnapshot',@params); | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | =head2 $boolean = $ec2->delete_snapshot($snapshot_id) | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | Delete the indicated snapshot and return true if the request was | ||||||||||||||||||||||||||||||||||||||||||
| 603 | successful. | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | sub delete_snapshot { | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_snapshot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | my %args = $VEP->args('-snapshot_id',@_); | |||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 611 | { | ||||||||||||||||||||||||||||||||||||||||||
| 612 | single_parm => 'SnapshotId' | ||||||||||||||||||||||||||||||||||||||||||
| 613 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | return $self->call('DeleteSnapshot',@params); | |||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | =head2 $snapshot = $ec2->copy_snapshot(-source_region=>$region,-source_snapshot_id=>$id,-description=>$desc) | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | =head2 $snapshot = $ec2->copy_snapshot(-region=>$region,-snapshot_id=>$id,-description=>$desc) | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | Copies an existing snapshot within the same region or from one region to another. | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | Required arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | -source_region -- The region the existing snapshot to copy resides in | ||||||||||||||||||||||||||||||||||||||||||
| 626 | -source_snapshot_id -- The snapshot ID of the snapshot to copy | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | -region -- Alias for -source_region | ||||||||||||||||||||||||||||||||||||||||||
| 629 | -snapshot_id -- Alias for -source_snapshot_id | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | Currently, the DestinationRegion and PresignedUrl API arguments are not | ||||||||||||||||||||||||||||||||||||||||||
| 632 | supported. Therefore, copying encrypted snapshots between regions is | ||||||||||||||||||||||||||||||||||||||||||
| 633 | not yet possible. | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | Optional arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | -description -- A description of the new snapshot | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | The return value is a VM::EC2::Snapshot object that can be queried | ||||||||||||||||||||||||||||||||||||||||||
| 640 | through its current_status() interface to follow the progress of the | ||||||||||||||||||||||||||||||||||||||||||
| 641 | snapshot operation. | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | sub copy_snapshot { | ||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_snapshot: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | $args{-description} ||= $args{-desc}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-description"} ||= $args{"-desc"}
MC/DC0%0/2
$args{"-description"} ||= $args{"-desc"}
$args{"-description"}
$args{"-desc"}
Truth table0%0/3
A ||= B
A= $args{"-description"}B= $args{"-desc"}
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | $args{-source_region} ||= $args{-region}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-source_region"} ||= $args{"-region"}
MC/DC0%0/2
$args{"-source_region"} ||= $args{"-region"}
$args{"-source_region"}
$args{"-region"}
Truth table0%0/3
A ||= B
A= $args{"-source_region"}B= $args{"-region"}
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $args{-source_snapshot_id} ||= $args{-snapshot_id}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$args{"-source_snapshot_id"} ||= $args{"-snapshot_id"}
MC/DC0%0/2
$args{"-source_snapshot_id"} ||= $args{"-snapshot_id"}
$args{"-source_snapshot_id"}
$args{"-snapshot_id"}
Truth table0%0/3
A ||= B
A= $args{"-source_snapshot_id"}B= $args{"-snapshot_id"}
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | $args{-source_region} or croak "copy_snapshot(): -source_region argument required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | $args{-source_snapshot_id} or croak "copy_snapshot(): -source_snapshot_id argument required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my @params = $VEP->format_parms(\%args, | |||||||||||||||||||||||||||||||||||||||||
| 654 | { | ||||||||||||||||||||||||||||||||||||||||||
| 655 | single_parm => [qw(SourceRegion SourceSnapshotId Description)] | ||||||||||||||||||||||||||||||||||||||||||
| 656 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | my $snap_id = $self->call('CopySnapshot',@params) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return eval { | |||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $snapshot; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | local $SIG{ALRM} = sub {die "timeout"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | alarm(60); | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | until ($snapshot = $self->describe_snapshots($snap_id)) { sleep 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | alarm(0); | |||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $snapshot; | |||||||||||||||||||||||||||||||||||||||||
| 665 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||
| 668 | =head2 $ec2->wait_for_snapshots(@snapshots) | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | Wait for all members of the provided list of snapshots to reach some | ||||||||||||||||||||||||||||||||||||||||||
| 671 | terminal state ("completed", "error"), and then return a hash | ||||||||||||||||||||||||||||||||||||||||||
| 672 | reference that maps each snapshot ID to its final state. | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | This method may potentially wait forever. It has no set timeout. Wrap | ||||||||||||||||||||||||||||||||||||||||||
| 675 | it in an eval{} and set alarm() if you wish to timeout. | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | sub wait_for_snapshots { | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_for_snapshots: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | $self->wait_for_terminal_state(\@_, | |||||||||||||||||||||||||||||||||||||||||
| 682 | ['completed','error'], | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 0); # no timeout on snapshots -- they may take days | ||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | L<VM::EC2> | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | Copyright (c) 2011 Ontario Institute for Cancer Research | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | This package and its accompanying libraries is free software; you can | ||||||||||||||||||||||||||||||||||||||||||
| 697 | redistribute it and/or modify it under the terms of the GPL (either | ||||||||||||||||||||||||||||||||||||||||||
| 698 | version 1, or at your option, any later version) or the Artistic | ||||||||||||||||||||||||||||||||||||||||||
| 699 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||||||||||||||||||||||||||||||||||||||||||
| 700 | please see DISCLAIMER.txt for disclaimers of warranty. | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||