2011-01-10 01:12:48 -05:00
|
|
|
require 'vcloud/spec_helper'
|
2010-10-15 13:40:32 -04:00
|
|
|
|
|
|
|
if Fog.mocking?
|
|
|
|
describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
|
|
|
subject { @vcloud }
|
|
|
|
|
|
|
|
it { should respond_to :get_vapp }
|
|
|
|
|
|
|
|
describe "#get_vapp" do
|
|
|
|
context "with a valid vapp_uri" do
|
2010-10-17 19:06:44 -04:00
|
|
|
before { @vapp = @vcloud.get_vapp(@mock_vm.href) }
|
2010-10-15 13:40:32 -04:00
|
|
|
subject { @vapp }
|
|
|
|
let(:vapp_id) { @vapp.body[:href].split("/").last }
|
|
|
|
|
|
|
|
it_should_behave_like "all responses"
|
|
|
|
it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.vApp+xml" }
|
|
|
|
|
|
|
|
describe "#body" do
|
|
|
|
subject { @vapp.body }
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
specify { subject.keys.sort_by(&:to_s).should == [:Link, :NetworkConnectionSection,
|
|
|
|
:OperatingSystemSection, :VirtualHardwareSection,
|
|
|
|
:href, :name,
|
|
|
|
:size, :status,
|
|
|
|
:type, :xmlns,
|
|
|
|
:xmlns_xsd, :xmlns_xsi] }
|
2010-10-15 13:40:32 -04:00
|
|
|
|
|
|
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vm.href }
|
|
|
|
its(:name) { should == @mock_vm.name }
|
|
|
|
its(:status) { should == @mock_vm.status.to_s }
|
|
|
|
its(:size) { should == (@mock_vm.disks.inject(0) {|s, d| s += d[:size].to_i } * 1024).to_s }
|
2010-10-15 13:40:32 -04:00
|
|
|
|
|
|
|
describe "Link" do
|
|
|
|
subject { @vapp.body[:Link] }
|
|
|
|
|
|
|
|
its(:rel) { should == "up" }
|
|
|
|
its(:type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.href }
|
2010-10-15 13:40:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "NetworkConnectionSection" do
|
|
|
|
subject { @vapp.body[:NetworkConnectionSection] }
|
|
|
|
|
|
|
|
it { should include :NetworkConnection }
|
|
|
|
|
|
|
|
describe "NetworkConnection" do
|
|
|
|
subject { @vapp.body[:NetworkConnectionSection][:NetworkConnection] }
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:IpAddress) { should == @mock_vm.ip }
|
2010-10-15 13:40:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "OperatingSystemSection" do
|
|
|
|
subject { @vapp.body[:OperatingSystemSection] }
|
|
|
|
|
|
|
|
its(:Info) { should == "The kind of installed guest operating system" }
|
|
|
|
its(:Description) { should == "Red Hat Enterprise Linux 5 (64-bit)" }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "VirtualHardwareSection" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection] }
|
|
|
|
|
|
|
|
specify { subject.keys.sort_by(&:to_s).should == [:Info, :Item, :System, :xmlns] }
|
|
|
|
|
|
|
|
describe "Item" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item] }
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
it { should have(5).items }
|
2010-10-15 13:40:32 -04:00
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
specify { subject.map {|i| i[:ResourceType] }.uniq.sort.should == %w(3 4 6 17).sort }
|
2010-10-15 13:40:32 -04:00
|
|
|
|
|
|
|
describe "CPU" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "3" } }
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:VirtualQuantity) { should == @mock_vm.cpus.to_s }
|
2010-10-15 13:40:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "memory" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "4" } }
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:VirtualQuantity) { should == @mock_vm.memory.to_s }
|
2010-10-15 13:40:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "SCSI controller" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].detect {|i| i[:ResourceType] == "6" } }
|
|
|
|
|
|
|
|
its(:Address) { should == "0" }
|
|
|
|
end
|
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
describe "Hard Disks" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" } }
|
2010-10-15 13:40:32 -04:00
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
it { should have(2).disks }
|
|
|
|
|
|
|
|
describe "#1" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[0] }
|
|
|
|
|
|
|
|
its(:AddressOnParent) { should == "0" }
|
|
|
|
its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s }
|
|
|
|
its(:HostResource) { should == (1024 * @mock_vm.disks[0][:size].to_i).to_s }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#2" do
|
|
|
|
subject { @vapp.body[:VirtualHardwareSection][:Item].find_all {|i| i[:ResourceType] == "17" }[1] }
|
|
|
|
|
|
|
|
its(:AddressOnParent) { should == "1" }
|
|
|
|
its(:VirtualQuantity) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s }
|
|
|
|
its(:HostResource) { should == (1024 * @mock_vm.disks[1][:size].to_i).to_s }
|
|
|
|
end
|
2010-10-15 13:40:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with a vapp uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.get_vapp(URI.parse('https://www.fakey.com/api/v0.8/vApp/99999')) } }
|
|
|
|
|
|
|
|
it_should_behave_like "a request for a resource that doesn't exist"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
end
|