fog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/Gemfile +8 -8
  2. data/Gemfile.lock +3 -3
  3. data/bin/fog +2 -10
  4. data/fog.gemspec +45 -20
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/attributes.rb +48 -8
  7. data/lib/fog/aws/ec2.rb +5 -2
  8. data/lib/fog/aws/elb.rb +5 -2
  9. data/lib/fog/aws/models/ec2/server.rb +1 -1
  10. data/lib/fog/aws/requests/simpledb/put_attributes.rb +43 -12
  11. data/lib/fog/aws/s3.rb +2 -2
  12. data/lib/fog/aws/simpledb.rb +15 -3
  13. data/lib/fog/bin.rb +11 -2
  14. data/lib/fog/bluebox.rb +5 -1
  15. data/lib/fog/connection.rb +9 -1
  16. data/lib/fog/credentials.rb +3 -0
  17. data/lib/fog/new_servers.rb +89 -0
  18. data/lib/fog/new_servers/bin.rb +30 -0
  19. data/lib/fog/new_servers/requests/add_server.rb +39 -0
  20. data/lib/fog/new_servers/requests/cancel_server.rb +36 -0
  21. data/lib/fog/new_servers/requests/get_server.rb +42 -0
  22. data/lib/fog/new_servers/requests/list_images.rb +33 -0
  23. data/lib/fog/new_servers/requests/list_plans.rb +36 -0
  24. data/lib/fog/new_servers/requests/list_servers.rb +43 -0
  25. data/lib/fog/new_servers/requests/reboot_server.rb +30 -0
  26. data/lib/fog/parser.rb +6 -0
  27. data/lib/fog/rackspace/files.rb +8 -2
  28. data/lib/fog/rackspace/models/servers/server.rb +5 -0
  29. data/lib/fog/rackspace/servers.rb +5 -1
  30. data/lib/fog/service.rb +6 -1
  31. data/lib/fog/slicehost.rb +5 -1
  32. data/lib/fog/terremark/ecloud.rb +1 -0
  33. data/lib/fog/terremark/shared.rb +4 -1
  34. data/lib/fog/terremark/vcloud.rb +1 -0
  35. data/lib/fog/vcloud.rb +150 -141
  36. data/lib/fog/vcloud/bin.rb +2 -2
  37. data/lib/fog/vcloud/collection.rb +3 -84
  38. data/lib/fog/vcloud/extension.rb +44 -0
  39. data/lib/fog/vcloud/generators.rb +33 -0
  40. data/lib/fog/vcloud/model.rb +5 -38
  41. data/lib/fog/vcloud/models/vdc.rb +14 -24
  42. data/lib/fog/vcloud/models/vdcs.rb +13 -8
  43. data/lib/fog/vcloud/requests/get_network.rb +4 -11
  44. data/lib/fog/vcloud/requests/get_organization.rb +4 -11
  45. data/lib/fog/vcloud/requests/get_vdc.rb +4 -12
  46. data/lib/fog/vcloud/requests/get_versions.rb +4 -13
  47. data/lib/fog/vcloud/requests/login.rb +4 -4
  48. data/lib/fog/vcloud/terremark/ecloud.rb +125 -54
  49. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +30 -0
  50. data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +31 -0
  51. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +21 -22
  52. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +11 -25
  53. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +38 -5
  54. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +11 -15
  55. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +52 -11
  56. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +14 -13
  57. data/lib/fog/vcloud/terremark/ecloud/models/node.rb +47 -0
  58. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +30 -0
  59. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +6 -9
  60. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +19 -3
  61. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +203 -0
  62. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +43 -0
  63. data/lib/fog/vcloud/terremark/ecloud/models/task.rb +22 -0
  64. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +30 -0
  65. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +32 -10
  66. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +5 -6
  67. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +23 -10
  68. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +54 -0
  69. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +14 -12
  70. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +53 -0
  71. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +52 -0
  72. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +42 -0
  73. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +115 -0
  74. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +4 -23
  75. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -0
  76. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +19 -0
  77. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +18 -0
  78. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +18 -0
  79. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +18 -0
  80. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +9 -16
  81. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +8 -14
  82. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +36 -0
  83. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +44 -0
  84. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +11 -12
  85. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +18 -0
  86. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +18 -0
  87. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -19
  88. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +5 -12
  89. data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +18 -0
  90. data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +19 -0
  91. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +18 -0
  92. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +7 -15
  93. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +18 -0
  94. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +18 -0
  95. data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +18 -0
  96. data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +18 -0
  97. data/lib/fog/vcloud/terremark/vcloud.rb +4 -18
  98. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +4 -12
  99. data/spec/aws/requests/simpledb/put_attributes_spec.rb +18 -0
  100. data/spec/vcloud/bin_spec.rb +2 -2
  101. data/spec/vcloud/models/vdc_spec.rb +35 -29
  102. data/spec/vcloud/requests/get_network_spec.rb +32 -43
  103. data/spec/vcloud/requests/get_organization_spec.rb +45 -38
  104. data/spec/vcloud/requests/get_vdc_spec.rb +42 -32
  105. data/spec/vcloud/requests/get_versions_spec.rb +17 -17
  106. data/spec/vcloud/requests/login_spec.rb +7 -4
  107. data/spec/vcloud/spec_helper.rb +137 -46
  108. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +53 -58
  109. data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +20 -20
  110. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +22 -21
  111. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +18 -18
  112. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +55 -51
  113. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +16 -15
  114. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +26 -27
  115. data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +16 -15
  116. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +52 -36
  117. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +18 -15
  118. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +46 -43
  119. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +37 -32
  120. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +26 -23
  121. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +57 -49
  122. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +41 -0
  123. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +39 -34
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +26 -48
  125. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +25 -26
  126. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +35 -27
  127. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +85 -110
  128. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -4
  129. data/spec/vcloud/vcloud_spec.rb +9 -8
  130. metadata +62 -26
  131. data/lib/fog/vcloud/parser.rb +0 -42
  132. data/lib/fog/vcloud/parsers/get_organization.rb +0 -37
  133. data/lib/fog/vcloud/parsers/get_vdc.rb +0 -62
  134. data/lib/fog/vcloud/parsers/get_versions.rb +0 -46
  135. data/lib/fog/vcloud/parsers/login.rb +0 -36
  136. data/lib/fog/vcloud/parsers/network.rb +0 -53
  137. data/lib/fog/vcloud/terremark/all.rb +0 -9
  138. data/lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb +0 -59
  139. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb +0 -30
  140. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb +0 -40
  141. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +0 -59
  142. data/lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb +0 -58
  143. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +0 -28
  144. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +0 -31
  145. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +0 -27
  146. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +0 -34
  147. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +0 -74
@@ -1,63 +1,41 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
2
 
3
- describe Fog::Vcloud, :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe Fog::Vcloud, :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_network }
7
+ it { should respond_to :get_network }
7
8
 
8
- describe :get_network, :type => :vcloud_request do
9
- context "with a valid network uri" do
10
- before { @network = @vcloud.get_network(URI.parse(@mock_network[:href])) }
11
- subject { @network }
9
+ describe :get_network, :type => :vcloud_request do
10
+ context "with a valid network uri" do
11
+ before { @network = @vcloud.get_network( @mock_network[:href] ) }
12
+ subject { @network }
12
13
 
13
- it_should_behave_like "all requests"
14
+ it_should_behave_like "all responses"
15
+ it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.network+xml" }
14
16
 
15
- its(:headers) { should include "Content-Type" }
16
- its(:body) { should be_an_instance_of Struct::TmrkEcloudNetwork }
17
+ describe :body do
18
+ subject { @network.body }
17
19
 
18
- describe :headers do
19
- let(:header) { @network.headers["Content-Type"] }
20
- specify { header.should == "application/vnd.vmware.vcloud.network+xml" }
21
- end
22
-
23
- describe :body do
24
- subject { @network.body }
25
-
26
- it_should_behave_like "it has a vcloud v0.8 xmlns"
27
-
28
- its(:configuration) { should be_an_instance_of Struct::VcloudNetworkConfiguration }
29
- its(:features) { should be_an_instance_of Array }
30
- its(:ips_link) { should be_an_instance_of Struct::VcloudLink }
31
- its(:href) { should == URI.parse("https://fakey.com/api/v0.8/network/31") }
32
- its(:type) { should == "application/vnd.vmware.vcloud.network+xml" }
33
- its(:name) { should == @mock_network[:name] }
34
-
35
- describe :configuration do
36
- subject { @network.body.configuration }
20
+ it { should have(9).keys }
37
21
 
38
- its(:gateway) { should == "1.2.3.1" }
39
- its(:netmask) { should == "255.255.255.0" }
40
- end
22
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
41
23
 
42
- describe :ips_link do
43
- subject { @network.body.ips_link }
44
- its(:href) { should == URI.parse(@mock_network[:href] + "/ips") }
45
- its(:rel) { should == "down" }
46
- its(:type) { should == "application/xml" }
47
- its(:name) { should == "IP Addresses" }
48
- end
24
+ it { should have_key_with_value :type, "application/vnd.vmware.vcloud.network+xml" }
25
+ it { should have_key_with_value :Features, {:FenceMode => "isolated"} }
26
+ it { should have_key_with_value :href, @mock_network[:href] }
27
+ it { should have_key_with_value :name, @mock_network[:name] }
28
+ it { should have_key_with_value :Configuration, {:Gateway => @mock_network[:gateway],
29
+ :Netmask => @mock_network[:netmask] } }
49
30
 
50
- describe "FenceMode Feature" do
51
- subject { @network.body.features.detect { |feature| feature.is_a?(Struct::VcloudNetworkFenceMode) } }
52
- its(:mode) { should == "isolated" }
53
31
  end
54
-
55
32
  end
56
- end
57
- context "with a network uri that doesn't exist" do
58
- subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/network/999')) } }
59
- it_should_behave_like "a request for a resource that doesn't exist"
33
+ context "with a network uri that doesn't exist" do
34
+ subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/network/999')) } }
35
+ it_should_behave_like "a request for a resource that doesn't exist"
36
+ end
60
37
  end
61
38
  end
39
+ else
62
40
  end
63
41
 
@@ -1,40 +1,39 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
2
 
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_public_ip }
7
+ it { should respond_to :get_public_ip }
7
8
 
8
- describe "#get_public_ip" do
9
- context "with a valid public_ip_uri" do
10
- before do
11
- @mock_ip = @mock_vdc[:public_ips].first
12
- @public_ip = @vcloud.get_public_ip(URI.parse("#{@base_url}/extensions/publicIp/#{@mock_ip[:id]}"))
13
- end
14
-
15
- subject { @public_ip }
16
-
17
- it_should_behave_like "all requests"
9
+ describe "#get_public_ip" do
10
+ context "with a valid public_ip_uri" do
11
+ before do
12
+ @mock_ip = @mock_vdc[:public_ips].first
13
+ @public_ip = @vcloud.get_public_ip( @mock_ip[:href] )
14
+ end
18
15
 
19
- its(:headers) { should include "Content-Type" }
20
- specify { subject.headers['Content-Type'].should == "application/vnd.tmrk.ecloud.publicIp+xml" }
16
+ subject { @public_ip }
21
17
 
22
- its(:body) { should be_an_instance_of Struct::TmrkEcloudPublicIp }
18
+ it_should_behave_like "all responses"
19
+ it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.publicIp+xml" }
23
20
 
24
- describe "#body" do
25
- subject { @public_ip.body }
21
+ describe "#body" do
22
+ subject { @public_ip.body }
26
23
 
27
- its(:name) { should == @mock_ip[:name] }
28
- its(:href) { should == URI.parse("#{@base_url}/extensions/publicIp/#{@mock_ip[:id]}") }
29
- its(:id) { should == @mock_ip[:id] }
24
+ its(:Name) { should == @mock_ip[:name] }
25
+ its(:Href) { should == @mock_ip[:href] }
26
+ its(:Id) { should == @mock_ip[:id] }
30
27
 
28
+ end
31
29
  end
32
- end
33
30
 
34
- context "with a public_ips_uri that doesn't exist" do
35
- subject { lambda { @vcloud.get_public_ip(URI.parse('https://www.fakey.c/piv89')) } }
31
+ context "with a public_ips_uri that doesn't exist" do
32
+ subject { lambda { @vcloud.get_public_ip(URI.parse('https://www.fakey.c/piv89')) } }
36
33
 
37
- it_should_behave_like "a request for a resource that doesn't exist"
34
+ it_should_behave_like "a request for a resource that doesn't exist"
35
+ end
38
36
  end
39
37
  end
38
+ else
40
39
  end
@@ -1,44 +1,52 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
2
 
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_public_ips }
7
+ it { should respond_to :get_public_ips }
7
8
 
8
- describe "#get_public_ips" do
9
- context "with a valid public_ips_uri" do
10
- before { @public_ips = @vcloud.get_public_ips(URI.parse(@mock_vdc[:href] + "/publicIps")) }
11
- subject { @public_ips }
9
+ describe "#get_public_ips" do
10
+ context "with a valid public_ips_uri" do
11
+ before { @public_ips = @vcloud.get_public_ips(URI.parse(@mock_vdc[:href] + "/publicIps")) }
12
+ subject { @public_ips }
12
13
 
13
- it_should_behave_like "all requests"
14
+ it_should_behave_like "all responses"
15
+ it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.publicIpsList+xml" }
14
16
 
15
- its(:headers) { should include "Content-Type" }
16
- specify { subject.headers['Content-Type'].should == "application/vnd.tmrk.ecloud.publicIpsList+xml" }
17
+ describe "#body" do
18
+ subject { @public_ips.body }
17
19
 
18
- its(:body) { should be_an_instance_of Struct::TmrkEcloudList }
20
+ it { should have(1).item }
19
21
 
20
- describe "#body" do
21
- describe "#links" do
22
- subject { @public_ips.body.links }
22
+ describe "[:PublicIPAddress]" do
23
+ subject { @public_ips.body[:PublicIPAddress] }
23
24
 
24
- it { should have(3).ips }
25
+ it { should have(@mock_vdc[:public_ips].length).addresses }
26
+
27
+ [0,1,2].each do |idx|
28
+
29
+ context "[#{idx}]" do
30
+ subject { @public_ips.body[:PublicIPAddress][idx] }
31
+ let(:public_ip) { @mock_vdc[:public_ips][idx] }
32
+ its(:Href) { should == public_ip[:href] }
33
+ its(:Id) { should == public_ip[:id] }
34
+ its(:Name) { should == public_ip[:name] }
35
+ end
36
+
37
+ end
25
38
 
26
- [0,1,2].each do |idx|
27
- let(:ip) { subject[idx] }
28
- let(:mock_ip) { @mock_vdc[:public_ips][idx] }
29
- specify { ip.should be_an_instance_of Struct::TmrkEcloudPublicIp }
30
- specify { ip.name.should == mock_ip[:name] }
31
- specify { ip.id.should == mock_ip[:id] }
32
- specify { ip.href.should == URI.parse("#{@base_url}/extensions/publicIp/#{mock_ip[:id]}") }
33
39
  end
40
+
34
41
  end
35
42
  end
36
- end
37
43
 
38
- context "with a public_ips_uri that doesn't exist" do
39
- subject { lambda { @vcloud.get_public_ips(URI.parse('https://www.fakey.c/piv8vc99')) } }
44
+ context "with a public_ips_uri that doesn't exist" do
45
+ subject { lambda { @vcloud.get_public_ips(URI.parse('https://www.fakey.c/piv8vc99')) } }
40
46
 
41
- it_should_behave_like "a request for a resource that doesn't exist"
47
+ it_should_behave_like "a request for a resource that doesn't exist"
48
+ end
42
49
  end
43
50
  end
51
+ else
44
52
  end
@@ -1,135 +1,110 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
2
 
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_vdc }
7
+ it { should respond_to :get_vdc }
7
8
 
8
- describe "#get_vdc" do
9
- context "with a valid vdc uri" do
10
- before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
11
- subject { @vdc }
9
+ describe "#get_vdc" do
10
+ context "with a valid vdc uri" do
11
+ before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
12
+ subject { @vdc }
12
13
 
13
- it_should_behave_like "all requests"
14
+ it_should_behave_like "all responses"
15
+ it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.vdc+xml" }
14
16
 
15
- its(:headers) { should include "Content-Type" }
16
- its(:body) { should be_an_instance_of Struct::TmrkEcloudVdc }
17
+ describe "#body" do
18
+ subject { @vdc.body }
17
19
 
18
- describe "#headers" do
19
- let(:header) { @vdc.headers["Content-Type"] }
20
- specify { header.should == "application/vnd.vmware.vcloud.vdc+xml" }
21
- end
22
-
23
- describe "#body" do
24
- subject { @vdc.body }
20
+ it { should have(11).items }
25
21
 
26
- it_should_behave_like "it has a vcloud v0.8 xmlns"
27
- it_should_behave_like "a tmrk vdc"
22
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
28
23
 
29
- it { should respond_to :storage_capacity }
30
- it { should respond_to :cpu_capacity }
31
- it { should respond_to :memory_capacity }
32
- it { should respond_to :deployed_vm_quota }
33
- it { should respond_to :instantiated_vm_quota }
24
+ its(:Description) { should == "" }
25
+ its(:StorageCapacity) { should == {:Units => "bytes * 10^9", :Allocated => @mock_vdc[:storage][:allocated], :Used => @mock_vdc[:storage][:used] } }
26
+ its(:ComputeCapacity) { should == {:InstantiatedVmsQuota => { :Limit => "-1", :Used => "-1" },
27
+ :Memory => { :Units => "bytes * 2^20", :Allocated => @mock_vdc[:memory][:allocated] },
28
+ :Cpu => { :Units => "hz * 10^6", :Allocated => @mock_vdc[:cpu][:allocated] },
29
+ :DeployedVmsQuota => { :Limit => "-1", :Used => "-1" } } }
34
30
 
35
- its(:name) { should == @mock_vdc[:name] }
36
- its(:href) { should == URI.parse(@mock_vdc[:href]) }
37
- its(:description) { should == '' }
31
+ its(:Link) { should have(4).links }
38
32
 
39
- describe "#links" do
40
- subject { @vdc.body.links }
41
- it { should have(4).links }
42
-
43
- describe "[0]" do
44
- subject { @vdc.body.links[0] }
45
- it_should_behave_like "a vdc catalog link"
33
+ describe "link 0" do
34
+ subject { @vdc.body[:Link][0] }
35
+ it { should have(4).attributes }
36
+ its(:type) { should == "application/vnd.vmware.vcloud.catalog+xml" }
37
+ its(:rel) { should == "down" }
38
+ its(:href) { should == "#{@mock_vdc[:href]}/catalog" }
39
+ its(:name) { should == @mock_vdc[:name] }
46
40
  end
47
-
48
- describe "[1]" do
49
- subject { @vdc.body.links[1] }
50
-
51
- it_should_behave_like "all rel=down vcloud links"
52
- it_should_behave_like "all tmrk ecloud publicIpList links"
53
-
54
- specify { subject.href.should == URI.parse(@mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/publicIps") }
41
+ describe "link 1" do
42
+ subject { @vdc.body[:Link][1] }
43
+ it { should have(4).attributes }
44
+ its(:type) { should == "application/vnd.tmrk.ecloud.publicIpsList+xml" }
45
+ its(:rel) { should == "down" }
46
+ its(:href) { should == "#{@mock_vdc[:extension_href]}/publicIps"}
47
+ its(:name) { should == "Public IPs" }
55
48
  end
56
-
57
- describe "[2]" do
58
- subject { @vdc.body.links[2] }
59
-
60
- it_should_behave_like "all rel=down vcloud links"
61
- it_should_behave_like "all tmrk ecloud internetServicesList links"
62
-
63
- specify { subject.href.should == URI.parse(@mock_vdc[:href] + "/internetServices") }
49
+ describe "link 2" do
50
+ subject { @vdc.body[:Link][2] }
51
+ it { should have(4).attributes }
52
+ its(:type) { should == "application/vnd.tmrk.ecloud.internetServicesList+xml" }
53
+ its(:rel) { should == "down" }
54
+ its(:href) { should == "#{@mock_vdc[:extension_href]}/internetServices"}
55
+ its(:name) { should == "Internet Services" }
64
56
  end
65
-
66
- describe "[3]" do
67
- subject { @vdc.body.links[3] }
68
-
69
- it_should_behave_like "all rel=down vcloud links"
70
- it_should_behave_like "all tmrk ecloud firewallAclList links"
71
-
72
- specify { subject.href.should == URI.parse(@mock_vdc[:href].sub('/vdc','/extensions/vdc') + "/firewallAcls") }
57
+ describe "link 3" do
58
+ subject { @vdc.body[:Link][3] }
59
+ it { should have(4).attributes }
60
+ its(:type) { should == "application/vnd.tmrk.ecloud.firewallAclsList+xml" }
61
+ its(:rel) { should == "down" }
62
+ its(:href) { should == "#{@mock_vdc[:extension_href]}/firewallAcls"}
63
+ its(:name) { should == "Firewall Access List" }
73
64
  end
74
- end
75
65
 
76
- describe "#networks" do
77
- subject { @vdc.body.networks }
78
- it_should_behave_like "the mocked tmrk network links"
79
- end
80
-
81
- describe "#storage_capacity" do
82
- subject { @vdc.body.storage_capacity }
83
-
84
- its(:units) { should == "bytes * 10^9" }
85
- its(:allocated) { should == @mock_vdc[:storage][:allocated] }
86
- its(:used) { should == @mock_vdc[:storage][:used] }
87
- end
66
+ let(:resource_entities) { subject[:ResourceEntities][:ResourceEntity] }
67
+ specify { resource_entities.should have(@mock_vdc[:vms].length).vapps }
68
+
69
+ describe "[:ResourceEntities][:ResourceEntity]" do
70
+ context "[0]" do
71
+ subject { @vdc.body[:ResourceEntities][:ResourceEntity][0] }
72
+ it { should be_a_vapp_link_to @mock_vdc[:vms][0] }
73
+ end
74
+ context "[1]" do
75
+ subject { @vdc.body[:ResourceEntities][:ResourceEntity][1] }
76
+ it { should be_a_vapp_link_to @mock_vdc[:vms][1] }
77
+ end
78
+ context "[2]" do
79
+ subject { @vdc.body[:ResourceEntities][:ResourceEntity][2] }
80
+ it { should be_a_vapp_link_to @mock_vdc[:vms][2] }
81
+ end
82
+ end
88
83
 
89
- describe "#cpu_capacity" do
90
- subject { @vdc.body.cpu_capacity }
91
- its(:units) { should == "hz * 10^6" }
92
- its(:allocated) { should == @mock_vdc[:cpu][:allocated] }
93
- its(:used) { should == nil }
94
- its(:limit) { should == nil }
95
- end
84
+ its(:name) { should == @mock_vdc[:name] }
96
85
 
97
- describe "#memory_capacity" do
98
- subject { @vdc.body.memory_capacity }
99
- it { should be_an_instance_of Struct::VcloudXCapacity }
100
- its(:units) { should == "bytes * 2^20" }
101
- its(:allocated) { should == @mock_vdc[:memory][:allocated] }
102
- its(:used) { should == nil }
103
- its(:limit) { should == nil }
104
- end
86
+ let(:available_networks) { subject[:AvailableNetworks][:Network] }
87
+ specify { available_networks.should have(2).networks }
105
88
 
106
- describe "#deployed_vm_quota" do
107
- subject { @vdc.body.deployed_vm_quota }
108
- it { should be_an_instance_of Struct::VcloudXCapacity }
109
- its(:limit) { should == -1 }
110
- its(:used) { should == -1 }
111
- its(:units) { should == nil }
112
- its(:allocated) { should == nil }
113
- end
114
- describe "#instantiated_vm_quota" do
115
- subject { @vdc.body.instantiated_vm_quota }
116
- it { should be_an_instance_of Struct::VcloudXCapacity }
117
- its(:limit) { should == -1 }
118
- its(:used) { should == -1 }
119
- its(:units) { should == nil }
120
- its(:allocated) { should == nil }
121
- end
122
- describe "#resource_entities" do
123
- subject { @vdc.body.resource_entities }
124
- it_should_behave_like "the mocked tmrk resource entity links"
89
+ describe "[:AvailableNetworks][:Network]" do
90
+ context "[0]" do
91
+ subject { @vdc.body[:AvailableNetworks][:Network][0] }
92
+ it { should be_a_network_link_to @mock_vdc[:networks][0] }
93
+ end
94
+ context "[1]" do
95
+ subject { @vdc.body[:AvailableNetworks][:Network][1] }
96
+ it { should be_a_network_link_to @mock_vdc[:networks][1] }
97
+ end
98
+ end
125
99
  end
126
100
  end
127
- end
128
101
 
129
- context "with a vdc uri that doesn't exist" do
130
- subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
102
+ context "with a vdc uri that doesn't exist" do
103
+ subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
131
104
 
132
- it_should_behave_like "a request for a resource that doesn't exist"
105
+ it_should_behave_like "a request for a resource that doesn't exist"
106
+ end
133
107
  end
134
108
  end
109
+ else
135
110
  end