mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|aws] Apply tags to volume at creation
Same approach as used for server tags for issue #366
This commit is contained in:
parent
61ffd3ce11
commit
8fa64aefbf
2 changed files with 18 additions and 1 deletions
|
@ -44,6 +44,19 @@ module Fog
|
|||
data = connection.create_volume(availability_zone, size, snapshot_id).body
|
||||
new_attributes = data.reject {|key,value| key == 'requestId'}
|
||||
merge_attributes(new_attributes)
|
||||
|
||||
if tags = self.tags
|
||||
# expect eventual consistency
|
||||
Fog.wait_for { self.reload rescue nil }
|
||||
for key, value in (self.tags = tags)
|
||||
connection.tags.create(
|
||||
:key => key,
|
||||
:resource_id => self.identity,
|
||||
:value => value
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if @server
|
||||
self.server = @server
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ Shindo.tests("Fog::Compute[:aws] | volume", ['aws']) do
|
|||
@server = Fog::Compute[:aws].servers.create
|
||||
@server.wait_for { ready? }
|
||||
|
||||
model_tests(Fog::Compute[:aws].volumes, {:availability_zone => @server.availability_zone, :size => 1, :device => '/dev/sdz1'}, true) do
|
||||
model_tests(Fog::Compute[:aws].volumes, {:availability_zone => @server.availability_zone, :size => 1, :device => '/dev/sdz1', :tags => {"key" => "value"}}, true) do
|
||||
|
||||
@instance.wait_for { ready? }
|
||||
|
||||
|
@ -32,6 +32,10 @@ Shindo.tests("Fog::Compute[:aws] | volume", ['aws']) do
|
|||
|
||||
@instance.wait_for { ready? }
|
||||
|
||||
tests('@instance.reload.tags').returns({'key' => 'value'}) do
|
||||
@instance.reload.tags
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@server.destroy
|
||||
|
|
Loading…
Add table
Reference in a new issue