2011-02-17 13:44:46 -05:00
|
|
|
require 'ecloud/spec_helper'
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
if Fog.mocking?
|
2011-02-17 13:44:46 -05:00
|
|
|
describe "Fog::Ecloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
|
2010-06-17 19:58:09 -04:00
|
|
|
subject { @vcloud }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should respond_to(:get_vdc) }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "#get_vdc" do
|
|
|
|
context "with a valid vdc uri" do
|
2010-10-17 19:06:44 -04:00
|
|
|
before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc.href)) }
|
2010-06-17 19:58:09 -04:00
|
|
|
subject { @vdc }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it_should_behave_like "all responses"
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.vdc+xml") }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "#body" do
|
|
|
|
subject { @vdc.body }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
it { should have(11).items }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2011-02-15 16:47:14 -05:00
|
|
|
it_should_behave_like("it has the standard vcloud v0.8 xmlns attributes") # 3 keys
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.href }
|
|
|
|
its(:name) { should == @mock_vdc.name }
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
its(:Description) { should == "" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:StorageCapacity) { should == {:Units => "bytes * 10^9", :Allocated => @mock_vdc.storage_allocated.to_s, :Used => @mock_vdc.storage_used.to_s } }
|
2010-06-17 19:58:09 -04:00
|
|
|
its(:ComputeCapacity) { should == {:InstantiatedVmsQuota => { :Limit => "-1", :Used => "-1" },
|
2010-10-17 19:06:44 -04:00
|
|
|
:Memory => { :Units => "bytes * 2^20", :Allocated => @mock_vdc.memory_allocated.to_s },
|
|
|
|
:Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc.cpu_allocated.to_s },
|
2010-06-17 19:58:09 -04:00
|
|
|
:DeployedVmsQuota => { :Limit => "-1", :Used => "-1" } } }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
its(:Link) { should have(4).links }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "link 0" do
|
|
|
|
subject { @vdc.body[:Link][0] }
|
|
|
|
it { should have(4).attributes }
|
|
|
|
its(:type) { should == "application/vnd.vmware.vcloud.catalog+xml" }
|
|
|
|
its(:rel) { should == "down" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.catalog.href }
|
|
|
|
its(:name) { should == @mock_vdc.catalog.name }
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "link 1" do
|
|
|
|
subject { @vdc.body[:Link][1] }
|
|
|
|
it { should have(4).attributes }
|
|
|
|
its(:type) { should == "application/vnd.tmrk.ecloud.publicIpsList+xml" }
|
|
|
|
its(:rel) { should == "down" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.public_ip_collection.href }
|
|
|
|
its(:name) { should == @mock_vdc.public_ip_collection.name }
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "link 2" do
|
|
|
|
subject { @vdc.body[:Link][2] }
|
|
|
|
it { should have(4).attributes }
|
|
|
|
its(:type) { should == "application/vnd.tmrk.ecloud.internetServicesList+xml" }
|
|
|
|
its(:rel) { should == "down" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.internet_service_collection.href }
|
|
|
|
its(:name) { should == @mock_vdc.internet_service_collection.name }
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "link 3" do
|
|
|
|
subject { @vdc.body[:Link][3] }
|
|
|
|
it { should have(4).attributes }
|
|
|
|
its(:type) { should == "application/vnd.tmrk.ecloud.firewallAclsList+xml" }
|
|
|
|
its(:rel) { should == "down" }
|
2010-10-17 19:06:44 -04:00
|
|
|
its(:href) { should == @mock_vdc.firewall_acls.href }
|
|
|
|
its(:name) { should == @mock_vdc.firewall_acls.name }
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
let(:resource_entities) { subject[:ResourceEntities][:ResourceEntity] }
|
2010-10-17 19:06:44 -04:00
|
|
|
specify { resource_entities.should have(@mock_vdc.virtual_machines.length).vapps }
|
2010-06-17 19:58:09 -04:00
|
|
|
|
|
|
|
describe "[:ResourceEntities][:ResourceEntity]" do
|
|
|
|
context "[0]" do
|
|
|
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][0] }
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[0]) }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
|
|
|
context "[1]" do
|
|
|
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][1] }
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[1]) }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
|
|
|
context "[2]" do
|
|
|
|
subject { @vdc.body[:ResourceEntities][:ResourceEntity][2] }
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should be_a_vapp_link_to(@mock_vdc.virtual_machines[2]) }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
|
|
|
end
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
its(:name) { should == @mock_vdc[:name] }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
let(:available_networks) { subject[:AvailableNetworks][:Network] }
|
|
|
|
specify { available_networks.should have(2).networks }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
describe "[:AvailableNetworks][:Network]" do
|
|
|
|
context "[0]" do
|
|
|
|
subject { @vdc.body[:AvailableNetworks][:Network][0] }
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should be_a_network_link_to(@mock_vdc.networks[0]) }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
|
|
|
context "[1]" do
|
|
|
|
subject { @vdc.body[:AvailableNetworks][:Network][1] }
|
2011-02-15 16:47:14 -05:00
|
|
|
it { should be_a_network_link_to(@mock_vdc.networks[1]) }
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
|
|
|
end
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-17 19:58:09 -04:00
|
|
|
context "with a vdc uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
|
2010-05-03 00:46:43 -04:00
|
|
|
|
2011-02-15 16:47:14 -05:00
|
|
|
it_should_behave_like("a request for a resource that doesn't exist")
|
2010-06-17 19:58:09 -04:00
|
|
|
end
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|