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
@@ -18,6 +18,24 @@ describe 'SimpleDB.put_attributes' do
18
18
  actual.body['BoxUsage'].should be_a(Float)
19
19
  end
20
20
 
21
+ it 'conditional put should succeed' do
22
+ AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '1' })
23
+ AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])
24
+ actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '3' }, :expect => { 'version' => '2' }, :replace => ['version'])
25
+ actual.body['RequestId'].should be_a(String)
26
+ actual.body['BoxUsage'].should be_a(Float)
27
+ end
28
+
29
+ it 'conditional put should raise Conflict error' do
30
+ actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :replace => ['version'])
31
+ actual.body['RequestId'].should be_a(String)
32
+ actual.body['BoxUsage'].should be_a(Float)
33
+
34
+ lambda {
35
+ actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])
36
+ }.should raise_error(Excon::Errors::Conflict)
37
+ end
38
+
21
39
  end
22
40
  describe 'failure' do
23
41
 
@@ -3,12 +3,12 @@ require 'spec_helper'
3
3
  describe Vcloud do
4
4
  it { should be_initialized }
5
5
 
6
- it { should have(2).services }
6
+ it { should have(3).services }
7
7
 
8
8
  describe "#registered_services" do
9
9
  subject { Vcloud.registered_services }
10
10
 
11
- it { should == ":ecloud, :vcloud" }
11
+ it { should == ":ecloud, :etest, :vcloud" }
12
12
  end
13
13
 
14
14
  describe "when indexing it like an array" do
@@ -1,46 +1,52 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe "Fog::Vcloud::Vdc", :type => :vcloud_model do
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Vdc", :type => :mock_vcloud_model do
4
5
 
5
- describe :class do
6
- subject { Fog::Vcloud::Vdc }
6
+ describe :class do
7
+ subject { Fog::Vcloud::Vdc }
7
8
 
8
- it { should have_identity :href }
9
+ it { should have_identity :href }
9
10
 
10
- it { should have_only_these_attributes [:allocation_model, :cpu_capacity, :description, :enabled, :href, :memory_capacity, :name, :network_links, :network_quota,
11
- :nic_quota, :other_links, :resource_entity_links, :storage_capacity, :vcloud_type, :vm_quota, :xmlns] }
12
- end
11
+ it { should have_only_these_attributes [:href, :name, :type, :description, :other_links, :compute_capacity, :storage_capacity, :available_networks,
12
+ :resource_entities, :enabled, :vm_quota, :nic_quota, :network_quota, :allocation_model] }
13
+ end
13
14
 
14
- context "with no uri" do
15
+ context "with no uri" do
15
16
 
16
- subject { Fog::Vcloud::Vdc.new() }
17
+ subject { Fog::Vcloud::Vdc.new() }
17
18
 
18
- its(:href) { should be_nil }
19
- its(:identity) { should be_nil }
20
- end
19
+ it { should have_all_attributes_be_nil }
21
20
 
22
- context "as a collection member" do
23
- subject { @vcloud.vdcs[0] }
21
+ end
24
22
 
25
- its(:href) { should == URI.parse(@mock_vdc[:href]) }
26
- its(:identity) { should == URI.parse(@mock_vdc[:href]) }
27
- its(:name) { should == @mock_vdc[:name] }
28
- its(:other_links) { should have(7).items }
29
- its(:resource_entity_links) { should have(3).items }
30
- its(:network_links) { should have(2).items }
23
+ context "as a collection member" do
24
+ subject { @vcloud.vdcs[0].reload; @vcloud.vdcs[0] }
31
25
 
32
- its(:cpu_capacity) { should == Struct::VcloudXCapacity.new('Mhz',@mock_vdc[:cpu][:allocated], nil, @mock_vdc[:cpu][:allocated]) }
33
- its(:memory_capacity) { should == Struct::VcloudXCapacity.new('MB',@mock_vdc[:memory][:allocated], nil, @mock_vdc[:memory][:allocated]) }
34
- its(:storage_capacity) { should == Struct::VcloudXCapacity.new('MB',@mock_vdc[:storage][:allocated], nil, @mock_vdc[:storage][:allocated]) }
26
+ it { should be_an_instance_of Fog::Vcloud::Vdc }
35
27
 
36
- its(:vm_quota) { should == 0 }
37
- its(:nic_quota) { should == 0 }
38
- its(:network_quota) { should == 0 }
28
+ its(:href) { should == @mock_vdc[:href] }
29
+ its(:identity) { should == @mock_vdc[:href] }
30
+ its(:name) { should == @mock_vdc[:name] }
31
+ its(:other_links) { should have(7).items }
32
+ its(:resource_entities) { should have(3).items }
33
+ its(:available_networks) { should have(2).items }
39
34
 
40
- its(:enabled) { should == true }
41
-
42
- end
35
+ its(:compute_capacity) { should be_an_instance_of Hash }
36
+ its(:compute_capacity) { should == {:Cpu =>
37
+ {:Units => "Mhz", :Allocated => @mock_vdc[:cpu][:allocated], :Limit => @mock_vdc[:cpu][:allocated]},
38
+ :Memory =>
39
+ {:Units => "MB", :Allocated => @mock_vdc[:memory][:allocated], :Limit => @mock_vdc[:memory][:allocated]}} }
40
+ its(:storage_capacity) { should be_an_instance_of Hash }
41
+ its(:storage_capacity) { should == {:Limit => @mock_vdc[:storage][:allocated], :Units=>"MB", :Allocated => @mock_vdc[:storage][:allocated]} }
43
42
 
43
+ its(:vm_quota) { should == "0" }
44
+ its(:nic_quota) { should == "0" }
45
+ its(:network_quota) { should == "0" }
44
46
 
47
+ its(:enabled) { should == "true" }
45
48
 
49
+ end
50
+ end
51
+ else
46
52
  end
@@ -1,55 +1,44 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
- describe Fog::Vcloud, :type => :vcloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe Fog::Vcloud, :type => :mock_vcloud_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(URI.parse(@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::VcloudNetwork }
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(:href) { should == URI.parse("https://fakey.com/api/v0.8/network/31") }
31
- its(:type) { should == "application/vnd.vmware.vcloud.network+xml" }
32
- its(:name) { should == @mock_network[:name] }
33
- its(:description) { should == @mock_network[:name] }
34
-
35
- describe :configuration do
36
- subject { @network.body.configuration }
37
-
38
- its(:gateway) { should == "1.2.3.1" }
39
- its(:netmask) { should == "255.255.255.0" }
40
- its(:dns) { should == "8.8.8.8" }
41
- end
20
+ it { should have(9).keys }
42
21
 
43
- describe "FenceMode Feature" do
44
- subject { @network.body.features.detect { |feature| feature.is_a?(Struct::VcloudNetworkFenceMode) } }
45
- its(:mode) { should == "isolated" }
22
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
23
+ it { should have_key_with_value :type, "application/vnd.vmware.vcloud.network+xml" }
24
+ it { should have_key_with_value :Features, "" }
25
+ it { should have_key_with_value :Description, @mock_network[:name] }
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],
30
+ :Dns => @mock_network[:dns] } }
46
31
  end
47
-
48
32
  end
49
- end
50
- context "with a network uri that doesn't exist" do
51
- subject { lambda { @vcloud.get_network(URI.parse('https://www.fakey.com/api/v0.8/network/999')) } }
52
- 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
53
37
  end
54
38
  end
39
+ else
40
+
41
+ describe Fog::Vcloud, :type => :vcloud_request do
42
+ end
43
+
55
44
  end
@@ -1,46 +1,53 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
- describe Fog::Vcloud, :type => :vcloud_request do
4
- subject { @vcloud }
5
-
6
- it { should respond_to :get_organization }
7
-
8
- describe "#get_organization" do
9
- context "with a valid organization uri" do
10
- before { @organization = @vcloud.get_organization(@vcloud.default_organization_uri) }
11
- subject { @organization }
12
-
13
- it_should_behave_like "all requests"
14
-
15
- its(:headers) { should include "Content-Type" }
16
- its(:body) { should be_an_instance_of Struct::VcloudOrganization }
17
-
18
- describe :headers do
19
- let(:header){ @organization.headers["Content-Type"] }
20
- specify{ header.should == "application/vnd.vmware.vcloud.org+xml" }
3
+ if Fog.mocking?
4
+ describe Fog::Vcloud, :type => :mock_vcloud_request do
5
+ subject { @vcloud }
6
+
7
+ it { should respond_to :get_organization }
8
+
9
+ describe "#get_organization" do
10
+ context "with a valid organization uri" do
11
+ before { @organization = @vcloud.get_organization(@vcloud.default_organization_uri) }
12
+ subject { @organization }
13
+
14
+ it_should_behave_like "all responses"
15
+ it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.org+xml" }
16
+
17
+ describe "#body" do
18
+ subject { @organization.body }
19
+
20
+
21
+ let(:links) { subject[:Link] }
22
+
23
+ it { should have(6).keys }
24
+
25
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
26
+ it { should have_key_with_value :href, @mock_organization[:info][:href] }
27
+ it { should have_key_with_value :name, @mock_organization[:info][:name] }
28
+ it { should have_key_with_array :Link, @mock_organization[:vdcs].map { |vdc|
29
+ [{ :type => "application/vnd.vmware.vcloud.vdc+xml",
30
+ :href => vdc[:href],
31
+ :name => vdc[:name],
32
+ :rel => "down" },
33
+ { :type => "application/vnd.vmware.vcloud.catalog+xml",
34
+ :href => vdc[:href] + "/catalog",
35
+ :name => vdc[:name] + " Catalog",
36
+ :rel => "down" },
37
+ { :type => "application/vnd.vmware.vcloud.tasksList+xml",
38
+ :href => vdc[:href] + "/tasksList",
39
+ :name => vdc[:name] + " Tasks List",
40
+ :rel => "down" }]
41
+ }.flatten }
42
+
43
+ end
21
44
  end
22
-
23
- describe "#body" do
24
- subject { @organization.body }
25
-
26
- it_should_behave_like "it has a vcloud v0.8 xmlns"
27
-
28
- its(:links) { should have(@mock_organization[:vdcs].length * 3).links }
29
- its(:name) { should == @mock_organization[:info][:name] }
30
- its(:href) { should == URI.parse(@mock_organization[:info][:href]) }
31
-
32
- let(:link) { subject.links[0] }
33
- specify { link.should be_an_instance_of Struct::VcloudLink }
34
- specify { link.rel.should == "down" }
35
- specify { link.href.should == URI.parse(@mock_vdc[:href]) }
36
- specify { link.type.should == "application/vnd.vmware.vcloud.vdc+xml" }
37
- specify { link.name.should == @mock_vdc[:name] }
45
+ context "with an organization uri that doesn't exist" do
46
+ subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } }
47
+ it_should_behave_like "a request for a resource that doesn't exist"
38
48
  end
39
49
  end
40
- context "with an organization uri that doesn't exist" do
41
- subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } }
42
- it_should_behave_like "a request for a resource that doesn't exist"
43
- end
44
50
  end
51
+ else
45
52
  end
46
53
 
@@ -1,53 +1,63 @@
1
- require "spec_helper"
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
3
  #
4
4
  # WARNING: INCOMPLETE
5
5
  #
6
6
 
7
- describe Fog::Vcloud, :type => :vcloud_request do
8
- subject { @vcloud }
7
+ if Fog.mocking?
8
+ describe Fog::Vcloud, :type => :mock_vcloud_request do
9
+ subject { @vcloud }
9
10
 
10
- it { should respond_to :get_vdc }
11
+ it { should respond_to :get_vdc }
11
12
 
12
- describe :get_vdc, :type => :vcloud_request do
13
- context "with a valid vdc uri" do
14
- before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
15
- subject { @vdc }
13
+ describe :get_vdc, :type => :vcloud_request do
14
+ context "with a valid vdc uri" do
15
+ before { @vdc = @vcloud.get_vdc(URI.parse(@mock_vdc[:href])) }
16
+ subject { @vdc }
16
17
 
17
- it_should_behave_like "all requests"
18
+ it_should_behave_like "all responses"
19
+ it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.vdc+xml" }
18
20
 
19
- its(:headers) { should include "Content-Type" }
20
- its(:body) { should be_an_instance_of Struct::VcloudVdc }
21
+ describe :body do
22
+ subject { @vdc.body }
21
23
 
22
- describe :headers do
23
- let(:header) { @vdc.headers["Content-Type"] }
24
- specify { header.should == "application/vnd.vmware.vcloud.vdc+xml" }
25
- end
24
+ it { should have(16).items }
25
+
26
+ it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
27
+
28
+ its(:name) { should == @mock_vdc[:name] }
29
+ its(:href) { should == @mock_vdc[:href] }
30
+ its(:VmQuota) { should == "0" }
31
+ its(:Description) { should == @mock_vdc[:name] + " VDC" }
32
+ its(:NicQuota) { should == "0" }
33
+ its(:IsEnabled) { should == "true" }
34
+ its(:NetworkQuota) { should == "0" }
35
+ its(:AllocationModel) { should == "AllocationPool" }
36
+ its(:Link) { should have(7).links }
37
+ its(:ResourceEntities) { should have(1).resource }
26
38
 
27
- describe :body do
28
- subject { @vdc.body }
39
+ let(:resource_entities) { subject[:ResourceEntities][:ResourceEntity] }
40
+ specify { resource_entities.should have(3).vapps }
41
+ #FIXME: test for the resources
29
42
 
30
- it_should_behave_like "it has a vcloud v0.8 xmlns"
43
+ its(:ComputeCapacity) { should == {:Memory => { :Units => "MB", :Allocated => @mock_vdc[:memory][:allocated], :Limit => @mock_vdc[:memory][:allocated] },
44
+ :Cpu => { :Units => "Mhz", :Allocated => @mock_vdc[:cpu][:allocated], :Limit => @mock_vdc[:cpu][:allocated] } } }
31
45
 
32
- its(:links) { should have(7).links }
33
- its(:resource_entities) { should have(3).links }
34
- its(:networks) { should have(2).networks }
46
+ its(:StorageCapacity) { should == {:Units => "MB", :Allocated => @mock_vdc[:storage][:allocated], :Limit => @mock_vdc[:storage][:allocated] } }
35
47
 
36
- its(:name) { should == @mock_vdc[:name] }
37
- its(:href) { should == URI.parse(@mock_vdc[:href]) }
48
+ let(:available_networks) { subject[:AvailableNetworks][:Network] }
49
+ specify { available_networks.should have(2).networks }
50
+ #FIXME :test the available networks
38
51
 
39
- let(:link) { subject.links[0] }
40
- specify { link.should be_an_instance_of Struct::VcloudLink }
41
- specify { link.rel.should == "up" }
42
- specify { link.href.should == URI.parse(@mock_organization[:info][:href]) }
43
- specify { link.type.should == "application/vnd.vmware.vcloud.org+xml" }
52
+ end
53
+ end
54
+ context "with a vdc uri that doesn't exist" do
55
+ subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
56
+ it_should_behave_like "a request for a resource that doesn't exist"
44
57
  end
45
- end
46
- context "with a vdc uri that doesn't exist" do
47
- subject { lambda { @vcloud.get_vdc(URI.parse('https://www.fakey.com/api/v0.8/vdc/999')) } }
48
- it_should_behave_like "a request for a resource that doesn't exist"
49
58
  end
50
59
  end
60
+ else
51
61
  end
52
62
 
53
63
 
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
- describe Fog::Vcloud, :type => :vcloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe Fog::Vcloud, :type => :mock_vcloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_versions }
7
+ it { should respond_to :get_versions }
7
8
 
8
- describe "#get_versions" do
9
- before { @versions = @vcloud.get_versions }
10
- subject { @versions }
9
+ describe "#get_versions" do
10
+ before { @versions = @vcloud.get_versions( @vcloud.versions_uri ) }
11
+ subject { @versions }
11
12
 
12
- it_should_behave_like "all requests"
13
+ it_should_behave_like "all responses"
13
14
 
14
- its(:body) { should have(1).version }
15
+ describe "body" do
16
+ subject { @versions.body }
15
17
 
16
- describe "body.first" do
17
- let(:version) { @versions.body.first }
18
- subject { version }
18
+ it { should have(4).keys }
19
+ it_should_behave_like "it has the standard xmlns attributes" # 2 keys
19
20
 
20
- its(:login_url) { should == @mock_version[:login_url] }
21
-
22
- its(:version) { should == @mock_version[:version] }
23
-
24
- its(:supported) { should == @mock_version[:supported] }
21
+ its(:xmlns) { should == "http://www.vmware.com/vcloud/versions" }
22
+ its(:VersionInfo) { should == { :LoginUrl => @mock_version[:login_url] , :Version => @mock_version[:version] } }
25
23
 
24
+ end
26
25
  end
27
26
  end
27
+ else
28
28
  end
@@ -1,8 +1,11 @@
1
- require 'spec_helper'
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
- describe Fog::Vcloud, :type => :vcloud_request do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe Fog::Vcloud, :type => :mock_vcloud_request do
5
+ subject { @vcloud }
5
6
 
6
- it_should_behave_like "all login requests"
7
+ it_should_behave_like "all login requests"
8
+ end
9
+ else
7
10
  end
8
11