mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|compute] made device an optional parameter in attach_volume method and request; split volume_attach and attachments into two different tests
This commit is contained in:
parent
7b6bcd481e
commit
19a70fd612
3 changed files with 9 additions and 6 deletions
|
@ -104,7 +104,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_volume(volume, device)
|
def attach_volume(volume, device=nil)
|
||||||
requires :identity
|
requires :identity
|
||||||
volume_id = volume.is_a?(String) ? volume : volume.id
|
volume_id = volume.is_a?(String) ? volume : volume.id
|
||||||
attachments.create(:server_id => identity, :volume_id => volume_id, :device => device)
|
attachments.create(:server_id => identity, :volume_id => volume_id, :device => device)
|
||||||
|
|
|
@ -5,11 +5,12 @@ module Fog
|
||||||
def attach_volume(server_id, volume_id, device)
|
def attach_volume(server_id, volume_id, device)
|
||||||
data = {
|
data = {
|
||||||
'volumeAttachment' => {
|
'volumeAttachment' => {
|
||||||
'volumeId' => volume_id,
|
'volumeId' => volume_id
|
||||||
'device' => device
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data['volumeAttachment']['device'] = device if device
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:body => Fog::JSON.encode(data),
|
:body => Fog::JSON.encode(data),
|
||||||
:expects => [200],
|
:expects => [200],
|
||||||
|
|
|
@ -64,12 +64,14 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
|
||||||
begin
|
begin
|
||||||
@volume = cbs_service.volumes.create(:size => 100, :display_name => "fog-#{timestamp}")
|
@volume = cbs_service.volumes.create(:size => 100, :display_name => "fog-#{timestamp}")
|
||||||
@volume.wait_for(timeout=1500) { ready? }
|
@volume.wait_for(timeout=1500) { ready? }
|
||||||
tests('#attach_volume') do
|
tests('#attach_volume').succeeds do
|
||||||
@instance.attach_volume(@volume, "/dev/xvdb")
|
@instance.attach_volume(@volume)
|
||||||
|
end
|
||||||
|
tests('#attachments').returns(true) do
|
||||||
@instance.wait_for(timeout=1500) do
|
@instance.wait_for(timeout=1500) do
|
||||||
!attachments.empty?
|
!attachments.empty?
|
||||||
end
|
end
|
||||||
returns(true) { @instance.attachments.any? {|a| a.volume_id == @volume.id } }
|
@instance.attachments.any? {|a| a.volume_id == @volume.id }
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
@volume.wait_for(timeout=1500) { !attachments.empty? }
|
@volume.wait_for(timeout=1500) { !attachments.empty? }
|
||||||
|
|
Loading…
Add table
Reference in a new issue