1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS] Adds ModifyVolumeAttribute

This commit is contained in:
Eric Stonfer 2012-11-05 12:53:36 -05:00
parent 86322ce4bf
commit c2c46d18ee
4 changed files with 60 additions and 1 deletions

View file

@ -113,6 +113,7 @@ module Fog
request :modify_instance_attribute
request :modify_network_interface_attribute
request :modify_snapshot_attribute
request :modify_volume_attribute
request :purchase_reserved_instances_offering
request :reboot_instances
request :release_address

View file

@ -125,7 +125,6 @@ module Fog
end
end
end
end
end

View file

@ -0,0 +1,51 @@
module Fog
module Compute
class AWS
class Real
require 'fog/aws/parsers/compute/basic'
# Modifies a volume attribute.
#
# ==== Parameters
# * volume_id<~String> - The ID of the volume.
# * auto_enable_io_value<~Boolean> - This attribute exists to auto-enable the I/O operations to the volume.
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'return'<~Boolean> - success?
#
# {Amazon API Reference}[http://http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyVolumeAttribute.html]
def modify_volume_attribute(volume_id=nil, auto_enable_io_value=false)
request(
'Action' => 'ModifyVolumeAttribute',
'VolumeId' => volume_id,
'AutoEnableIO.Value' => auto_enable_io_value,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
)
end
end
class Mock
def modify_volume_attribute(volume_id=nil, auto_enable_io_value=false)
response = Excon::Response.new
if volume = self.data[:volumes][volume_id]
response.status = 200
response.body = {
'requestId' => Fog::AWS::Mock.request_id,
'return' => true
}
response
else
raise Fog::Compute::AWS::NotFound.new("The volume '#{volume_id}' does not exist.")
end
end
end
end
end
end

View file

@ -136,6 +136,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
Fog::Compute[:aws].volumes.get(@volume_id).wait_for { ready? }
tests("#modify_volume_attribute('#{@volume_id}', true)").formats(AWS::Compute::Formats::BASIC) do
Fog::Compute[:aws].modify_volume_attribute(@volume_id, true).body
end
tests("#delete_volume('#{@volume_id}')").formats(AWS::Compute::Formats::BASIC) do
Fog::Compute[:aws].delete_volume(@volume_id).body
end
@ -156,6 +160,10 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
Fog::Compute[:aws].detach_volume('vol-00000000')
end
tests("#modify_volume_attribute('vol-00000000', true)").raises(Fog::Compute::AWS::NotFound) do
Fog::Compute[:aws].modify_volume_attribute('vol-00000000', true)
end
tests("#detach_volume('#{@volume.identity}')").raises(Fog::Compute::AWS::Error) do
Fog::Compute[:aws].detach_volume(@volume.identity)
end