1VM::EC2::Volume(3) User Contributed Perl Documentation VM::EC2::Volume(3)
2
3
4
6 VM::EC2::Volume - Object describing an Amazon EBS volume
7
9 use VM::EC2;
10
11 $ec2 = VM::EC2->new(...);
12 @vol = $ec2->describe_volumes;
13 for my $vol (@vols) {
14 $id = $vol->volumeId;
15 $size = $vol->size;
16 $snap = $vol->snapshotId;
17 $zone = $vol->availabilityZone;
18 $status = $vol->status;
19 $ctime = $vol->createTime;
20 @attachments = $vol->attachments;
21 $attachment = $vol->attachment;
22 $origin = $vol->from_snapshot;
23 @snapshots = $vol->to_snapshots;
24 }
25 $vols[0]->attach('i-12345','/dev/sdg1');
26 $vols[0]->deleteOnTermination('true');
27 $vols[0]->detach;
28 $vols[0]->create_snapshot('automatic snapshot')
29
31 This object is used to describe an Amazon EBS volume. It is returned by
32 VM::EC2->describe_volumes().
33
35 The following object methods are supported:
36
37 volumeId -- ID of this volume.
38 size -- Size of this volume (in GB).
39 snapshotId -- ID of snapshot this volume was created from.
40 availabilityZone -- Availability zone in which this volume resides.
41 status -- Volume state, one of "creating", "available",
42 "in-use", "deleting", "deleted", "error"
43 createTime -- Timestamp for when volume was created.
44 volumeType -- The volume type, one of "standard", "io1", or "gp2"
45 iops -- The number of I/O operations per second that the volume
46 supports, an integer between 100 and 4000. Only valid for
47 volumes of type "io1".
48 encrypted -- True if volume is encrypted.
49 tags -- Hashref containing tags associated with this group.
50 See L<VM::EC2::Generic>.
51
52 In addition, this class provides several convenience functions:
53
54 $attachment = $vol->attachment
55 @attachments = $vol->attachments
56 The attachment() method returns a VM::EC2::BlockDevice::Attachment
57 object describing the attachment of this volume to an instance. If the
58 volume is unused, then this returns undef.
59
60 The attachments() method is similar, except that it returns a list of
61 the attachments. Currently an EBS volume can only be attached to one
62 instance at a time, but the Amazon call syntax supports multiple
63 attachments and this method is provided for future compatibility.
64
65 $attachment = $vol->attach($instance,$device)
66 $attachment = $vol->attach(-instance_id=>$instance,-device=>$device)
67 Attach this volume to an instance using virtual device $device. Both
68 arguments are required. The result is a
69 VM::EC2::BlockDevice::Attachment object which you can monitor by
70 calling current_status():
71
72 my $a = $volume->attach('i-12345','/dev/sdg');
73 while ($a->current_status ne 'attached') {
74 sleep 2;
75 }
76 print "volume is ready to go\n";
77
78 $attachment = $volume->detach()
79 $attachment = $volume->detach(-instance_id=>$instance_id, -device=>$device,
80 -force=>$force);
81 Detaches this volume. With no arguments, will detach the volume from
82 whatever instance it is currently attached to. Provide -instance_id
83 and/or -device as a check that you are detaching the volume from the
84 expected instance and device.
85
86 Optional arguments:
87
88 -instance_id -- ID of the instance to detach from.
89 -device -- How the device is exposed to the instance.
90 -force -- Force detachment, even if previous attempts were
91 unsuccessful.
92
93 The result is a VM::EC2::BlockDevice::Attachment object which you can
94 monitor by calling current_status():
95
96 my $a = $volume->detach;
97 while ($a->current_status ne 'detached') {
98 sleep 2;
99 }
100 print "volume is ready to go\n";
101
102 $boolean = $vol->deleteOnTermination([$boolean])
103 Get or set the deleteOnTermination flag for attached volumes. If the
104 volume is unattached, then this causes a fatal error. Called with no
105 arguments, this method returns the current state of the
106 deleteOnTermination flag for the volume's attachment. Called with a
107 true/false argument, the method sets the flag by calling
108 modify_instance_attributes() on the corresponding instance and returns
109 true if successful.
110
111 $snap = $vol->from_snapshot
112 Returns the VM::EC2::Snapshot object that this volume was originally
113 derived from. It will return undef if the resource no longer exists, or
114 if the volume was created from scratch.
115
116 @snap = $vol->to_snapshots
117 If this volume has been used to create one or more snapshots, this
118 method will return them as a list of VM::EC2::Snapshot objects.
119
120 $snapshot = $vol->create_snapshot('Description')
121 Create a snapshot of the volume and return a VM::EC2::Snapshot object.
122 To ensure a consistent snapshot, you should unmount the volume before
123 snapshotting it. The optional argument allows you to add a description
124 to the snapshot.
125
126 Here is an example:
127
128 $s = $volume->create_snapshot("Backed up at ".localtime);
129 while ($s->current_status eq 'pending') {
130 print "Progress: ",$s->progress,"% done\n";
131 }
132 print "Snapshot status: ",$s->current_status,"\n";
133
134 $status = $vol->current_status
135 This returns the up-to-date status of the volume. It works by calling
136 refresh() and then returning status().
137
138 $boolean = $vol->auto_enable_io([$new_boolean])
139 Get or set the auto-enable IO flag.
140
141 $boolean = $vol->enable_volume_io()
142 Enable volume I/O after it has been disabled by an Amazon health check.
143 If successful, the call will return true.
144
146 When used in a string context, this object will interpolate the
147 volumeId.
148
150 VM::EC2 VM::EC2::Generic VM::EC2::Snapshot VM::EC2::BlockDevice
151 VM::EC2::BlockDevice::Attachment
152
154 Lincoln Stein <lincoln.stein@gmail.com>.
155
156 Copyright (c) 2011 Ontario Institute for Cancer Research
157
158 This package and its accompanying libraries is free software; you can
159 redistribute it and/or modify it under the terms of the GPL (either
160 version 1, or at your option, any later version) or the Artistic
161 License 2.0. Refer to LICENSE for the full license text. In addition,
162 please see DISCLAIMER.txt for disclaimers of warranty.
163
164
165
166perl v5.28.1 2019-02-02 VM::EC2::Volume(3)