Skip to content

Commit 7af36b0

Browse files
committed
Merge pull request fog#1254 from estonfer/modify_volume_attribute
[AWS] Adds ModifyVolumeAttribute
2 parents 521f511 + c2c46d1 commit 7af36b0

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

lib/fog/aws/compute.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class AWS < Fog::Service
113113
request :modify_instance_attribute
114114
request :modify_network_interface_attribute
115115
request :modify_snapshot_attribute
116+
request :modify_volume_attribute
116117
request :purchase_reserved_instances_offering
117118
request :reboot_instances
118119
request :release_address

lib/fog/aws/models/compute/volume.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def detach(force = false)
125125
end
126126

127127
end
128-
129128
end
130129
end
131130
end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module Fog
2+
module Compute
3+
class AWS
4+
class Real
5+
6+
require 'fog/aws/parsers/compute/basic'
7+
8+
# Modifies a volume attribute.
9+
#
10+
# ==== Parameters
11+
# * volume_id<~String> - The ID of the volume.
12+
# * auto_enable_io_value<~Boolean> - This attribute exists to auto-enable the I/O operations to the volume.
13+
#
14+
# ==== Returns
15+
# * response<~Excon::Response>:
16+
# * body<~Hash>:
17+
# * 'requestId'<~String> - Id of request
18+
# * 'return'<~Boolean> - success?
19+
#
20+
# {Amazon API Reference}[http://http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyVolumeAttribute.html]
21+
def modify_volume_attribute(volume_id=nil, auto_enable_io_value=false)
22+
request(
23+
'Action' => 'ModifyVolumeAttribute',
24+
'VolumeId' => volume_id,
25+
'AutoEnableIO.Value' => auto_enable_io_value,
26+
:idempotent => true,
27+
:parser => Fog::Parsers::Compute::AWS::Basic.new
28+
)
29+
end
30+
31+
end
32+
33+
class Mock
34+
35+
def modify_volume_attribute(volume_id=nil, auto_enable_io_value=false)
36+
response = Excon::Response.new
37+
if volume = self.data[:volumes][volume_id]
38+
response.status = 200
39+
response.body = {
40+
'requestId' => Fog::AWS::Mock.request_id,
41+
'return' => true
42+
}
43+
response
44+
else
45+
raise Fog::Compute::AWS::NotFound.new("The volume '#{volume_id}' does not exist.")
46+
end
47+
end
48+
end
49+
end
50+
end
51+
end

tests/aws/requests/compute/volume_tests.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@
136136

137137
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
138138

139+
tests("#modify_volume_attribute('#{@volume_id}', true)").formats(AWS::Compute::Formats::BASIC) do
140+
Fog::Compute[:aws].modify_volume_attribute(@volume_id, true).body
141+
end
142+
139143
tests("#delete_volume('#{@volume_id}')").formats(AWS::Compute::Formats::BASIC) do
140144
Fog::Compute[:aws].delete_volume(@volume_id).body
141145
end
@@ -156,6 +160,10 @@
156160
Fog::Compute[:aws].detach_volume('vol-00000000')
157161
end
158162

163+
tests("#modify_volume_attribute('vol-00000000', true)").raises(Fog::Compute::AWS::NotFound) do
164+
Fog::Compute[:aws].modify_volume_attribute('vol-00000000', true)
165+
end
166+
159167
tests("#detach_volume('#{@volume.identity}')").raises(Fog::Compute::AWS::Error) do
160168
Fog::Compute[:aws].detach_volume(@volume.identity)
161169
end

0 commit comments

Comments
 (0)