it gets called like this actually

This commit is contained in:
Dan Peterson 2010-10-15 18:13:25 -03:00
parent e7aa0e83c1
commit d8e9ff71a6
2 changed files with 6 additions and 6 deletions

View File

@ -328,7 +328,7 @@ module Fog
},
],
:vms => [
{ :href => "#{base_url}/vap/41",
{ :href => "#{base_url}/vapp/41",
:name => "Broom 1",
:ip => "1.2.3.3",
:memory => 1024,
@ -336,11 +336,11 @@ module Fog
:disks => [{ :size => 25 }],
:status => 2
},
{ :href => "#{base_url}/vap/42",
{ :href => "#{base_url}/vapp/42",
:name => "Broom 2",
:ip => "1.2.3.4"
},
{ :href => "#{base_url}/vap/43",
{ :href => "#{base_url}/vapp/43",
:name => "Email!"
}
]
@ -394,8 +394,8 @@ module Fog
end
def vapp_and_vdc_from_vapp_uri(uri)
if vdc = mock_data[:organizations].map {|o| o[:vdcs] }.flatten.detect {|vd| vd[:vms].detect {|vm| vm[:href] == uri } }
vapp = vdc[:vms].detect {|v| v[:href] == uri }
if vdc = mock_data[:organizations].map {|o| o[:vdcs] }.flatten.detect {|vd| vd[:vms].detect {|vm| uri =~ %r{^#{Regexp.escape(vm[:href])}($|/)} } }
vapp = vdc[:vms].detect {|v| uri =~ %r{^#{Regexp.escape(v[:href])}($|/)} }
if vapp
[vapp, vdc]
end

View File

@ -9,7 +9,7 @@ if Fog.mocking?
describe :power_on, :type => :vcloud_request do
context "with a valid vapp uri" do
let(:vm_data) { @vcloud.mock_data[:organizations].first[:vdcs].first[:vms].first }
before { vm_data[:status] = 2; @power_on = @vcloud.power_on(@vcloud.vdcs.first.servers.first.href) }
before { vm_data[:status] = 2; @power_on = @vcloud.power_on(@vcloud.vdcs.first.servers.first.href + "/power/action/powerOn") }
subject { @power_on }
it_should_behave_like "all responses"