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,28 +1,28 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Ips", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
5
-
6
- it { should_not respond_to :ips }
7
-
8
- describe :class do
9
- subject { @vcloud.vdcs[0].networks[0].ips.class }
10
- its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Ip }
11
- its(:get_request) { should be_nil }
12
- its(:all_request) { should be_nil }
13
- its(:vcloud_type) { should be_nil }
14
- it { should_not respond_to :create }
15
- end
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Ips", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
6
+
7
+ it { should_not respond_to :ips }
8
+
9
+ describe :class do
10
+ subject { @vcloud.vdcs[0].networks[0].ips.class }
11
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Ip }
12
+ end
16
13
 
17
- describe :ips do
18
- subject { @vcloud.vdcs[0].networks[0].ips }
14
+ describe :ips do
15
+ subject { @vcloud.vdcs[0].networks[0].ips.reload; @vcloud.vdcs[0].networks[0].ips }
16
+ it { should_not respond_to :create }
19
17
 
20
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Ips }
18
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Ips }
21
19
 
22
- its(:length) { should == 252 }
20
+ its(:length) { should == 252 }
23
21
 
24
- it { should have_members_of_the_right_model }
22
+ it { should have_members_of_the_right_model }
23
+ end
25
24
  end
25
+ else
26
26
  end
27
27
 
28
28
 
@@ -1,65 +1,69 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Network", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Network", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- describe :class do
7
- subject { Fog::Vcloud::Terremark::Ecloud::Network }
7
+ describe :class do
8
+ subject { Fog::Vcloud::Terremark::Ecloud::Network }
8
9
 
9
- it { should have_identity :href }
10
- it { should have_only_these_attributes [:href, :name, :features, :configuration, :ips_link, :type, :xmlns] }
11
- end
12
-
13
- context "with no uri" do
14
-
15
- subject { Fog::Vcloud::Terremark::Ecloud::Network.new() }
16
-
17
- its(:href) { should be_nil }
18
- its(:identity) { should be_nil }
19
- its(:name) { should be_nil }
20
- its(:type) { should be_nil }
21
- its(:features) { should be_nil }
22
- its(:configuration) { should be_nil }
23
- its(:ips_link) { should be_nil }
24
- its(:xmlns) { should be_nil }
25
- end
26
-
27
- context "as a collection member" do
28
- subject { @vcloud.vdcs[0].networks[0] }
29
-
30
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Network }
31
-
32
- it_should_behave_like "it has a vcloud v0.8 xmlns"
10
+ it { should have_identity :href }
11
+ it { should have_only_these_attributes [:href, :name, :id, :features, :links, :type, :gateway, :broadcast, :address, :rnat, :extension_href] }
12
+ end
33
13
 
34
- its(:href) { should == URI.parse(@mock_network[:href]) }
35
- its(:identity) { should == URI.parse(@mock_network[:href]) }
36
- its(:name) { should == @mock_network[:name] }
37
- its(:type) { should == "application/vnd.vmware.vcloud.network+xml" }
14
+ context "with no uri" do
38
15
 
39
- it { should have(1).features }
16
+ subject { Fog::Vcloud::Terremark::Ecloud::Network.new() }
40
17
 
41
- describe :features do
42
- let(:feature) { subject.features[0] }
43
- specify { feature.should be_an_instance_of Struct::VcloudNetworkFenceMode }
44
- specify { feature.mode.should == "isolated" }
18
+ it { should have_all_attributes_be_nil }
45
19
  end
46
20
 
47
- describe :configurations do
48
- let(:configuration) { subject.configuration }
49
- specify { configuration.should be_an_instance_of Struct::VcloudNetworkConfiguration }
50
- specify { configuration.gateway.should == @mock_network[:gateway] }
51
- specify { configuration.netmask.should == @mock_network[:netmask] }
52
- specify { configuration.dns.should be_nil }
53
- end
21
+ context "as a collection member" do
22
+ subject { @vcloud.vdcs[0].networks[0].reload; @vcloud.vdcs[0].networks[0] }
23
+
24
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Network }
25
+
26
+ its(:href) { should == @mock_network[:href] }
27
+ its(:identity) { should == @mock_network[:href] }
28
+ its(:name) { should == @mock_network[:name] }
29
+ its(:type) { should == "application/vnd.vmware.vcloud.network+xml" }
30
+ its(:id) { should == @mock_network[:id] }
31
+ its(:gateway) { should == @mock_network[:gateway] }
32
+ its(:broadcast) { should == IPAddr.new(@mock_network[:subnet]).to_range.last.to_s }
33
+ its(:address) { should == @mock_network[:subnet].split("/")[0] }
34
+ its(:rnat) { should == @mock_network[:rnat] }
35
+ its(:extension_href) { should == @mock_network[:extension_href] }
36
+
37
+ it { should have(1).features }
38
+
39
+ describe :features do
40
+ let(:feature) { subject.features[0] }
41
+ specify { feature.should be_an_instance_of Hash }
42
+ specify { feature[:FenceMode].should == @mock_network[:features][0][:value] }
43
+ end
44
+
45
+ it { should have(2).links }
46
+
47
+ describe :links do
48
+ context "[0]" do
49
+ let(:link) { subject.links[0] }
50
+ specify { link[:rel].should == "down" }
51
+ specify { link[:href].should == "#{@mock_network[:href]}/ips" }
52
+ specify { link[:type].should == "application/xml" }
53
+ specify { link[:name].should == "IP Addresses" }
54
+ end
55
+
56
+ context "[1]" do
57
+ let(:link) { subject.links[1] }
58
+ specify { link[:rel].should == "down" }
59
+ specify { link[:href].should == @mock_network[:extension_href] }
60
+ specify { link[:type].should == "application/xml" }
61
+ specify { link[:name].should == @mock_network[:name] }
62
+ end
63
+ end
54
64
 
55
- describe :ips_link do
56
- let(:ips_link) { subject.ips_link }
57
- specify { ips_link.rel.should == "down" }
58
- specify { ips_link.href.should == URI.parse(@mock_network[:href] + "/ips") }
59
- specify { ips_link.type.should == "application/xml" }
60
- specify { ips_link.name.should == "IP Addresses" }
61
65
  end
62
-
63
66
  end
67
+ else
64
68
  end
65
69
 
@@ -1,26 +1,27 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Networks", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Networks", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :networks }
7
+ it { should respond_to :networks }
7
8
 
8
- describe :class do
9
- subject { @vcloud.networks.class }
10
- its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Network }
11
- its(:get_request) { should == :get_network }
12
- its(:all_request) { should be_an_instance_of Proc }
13
- its(:vcloud_type) { should == "application/vnd.vmware.vcloud.network+xml" }
14
- end
9
+ describe :class do
10
+ subject { @vcloud.networks.class }
11
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Network }
12
+ end
15
13
 
16
- describe :networks do
17
- subject { @vcloud.vdcs[0].networks }
14
+ describe :networks do
15
+ subject { @vcloud.vdcs[0].networks }
16
+ it { should_not respond_to :create }
18
17
 
19
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Networks }
18
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Networks }
20
19
 
21
- its(:length) { should == 2 }
20
+ its(:length) { should == 2 }
22
21
 
23
- it { should have_members_of_the_right_model }
22
+ it { should have_members_of_the_right_model }
23
+ end
24
24
  end
25
+ else
25
26
  end
26
27
 
@@ -1,41 +1,40 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::PublicIp", :type => :tmrk_ecloud_model do
4
- before do
5
- @mock_ip = @mock_vdc[:public_ips].first
6
- @mock_ip_uri = URI.parse("#{@base_url}/extensions/publicIp/#{@mock_ip[:id]}")
7
- end
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::PublicIp", :type => :mock_tmrk_ecloud_model do
5
+ before do
6
+ @mock_ip = @mock_vdc[:public_ips].first
7
+ end
8
8
 
9
- subject { @vcloud }
9
+ subject { @vcloud }
10
10
 
11
- describe :class do
12
- subject { Fog::Vcloud::Terremark::Ecloud::PublicIp }
11
+ describe :class do
12
+ subject { Fog::Vcloud::Terremark::Ecloud::PublicIp }
13
13
 
14
- it { should have_identity :href }
15
- it { should have_only_these_attributes [:name, :type, :id, :href] }
16
- end
14
+ it { should have_identity :href }
15
+ it { should have_only_these_attributes [:name, :id, :href] }
16
+ end
17
17
 
18
- context "with no uri" do
18
+ context "with no uri" do
19
19
 
20
- subject { Fog::Vcloud::Terremark::Ecloud::PublicIp.new() }
20
+ subject { Fog::Vcloud::Terremark::Ecloud::PublicIp.new() }
21
21
 
22
- its(:href) { should be_nil }
23
- its(:identity) { should be_nil }
24
- its(:name) { should be_nil }
25
- its(:type) { should be_nil }
26
- end
22
+ it { should have_all_attributes_be_nil }
23
+ end
24
+
25
+ context "as a collection member" do
26
+ subject { @vcloud.vdcs[0].public_ips[0].reload; @vcloud.vdcs[0].public_ips[0] }
27
27
 
28
- context "as a collection member" do
29
- subject { @vcloud.vdcs[0].public_ips[0] }
28
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIp }
30
29
 
31
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIp }
30
+ its(:href) { should == @mock_ip[:href] }
31
+ its(:identity) { should == @mock_ip[:href] }
32
+ its(:name) { should == @mock_ip[:name] }
33
+ its(:id) { should == @mock_ip[:id] }
32
34
 
33
- its(:href) { should == @mock_ip_uri }
34
- its(:identity) { should == @mock_ip_uri }
35
- its(:name) { should == @mock_ip[:name] }
36
- its(:id) { should == @mock_ip[:id] }
35
+ its(:internet_services) { should have(2).services }
37
36
 
38
- its(:internet_services) { should have(2).services }
39
-
37
+ end
40
38
  end
39
+ else
41
40
  end
@@ -1,26 +1,27 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::PublicIps", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::PublicIps", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :public_ips }
7
+ it { should respond_to :public_ips }
7
8
 
8
- describe :class do
9
- subject { @vcloud.public_ips.class }
10
- its(:model) { should == Fog::Vcloud::Terremark::Ecloud::PublicIp }
11
- its(:get_request) { should == :get_public_ip }
12
- its(:all_request) { should be_an_instance_of Proc }
13
- its(:vcloud_type) { should == "application/vnd.tmrk.ecloud.publicIp+xml" }
14
- end
9
+ describe :class do
10
+ subject { @vcloud.public_ips.class }
11
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::PublicIp }
12
+ end
15
13
 
16
- describe :public_ips do
17
- subject { @vcloud.vdcs[0].public_ips }
14
+ describe :public_ips do
15
+ subject { @vcloud.vdcs[0].public_ips }
16
+ it { should_not respond_to :create }
18
17
 
19
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIps }
18
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIps }
20
19
 
21
- its(:length) { should == 3 }
20
+ its(:length) { should == 3 }
22
21
 
23
- it { should have_members_of_the_right_model }
22
+ it { should have_members_of_the_right_model }
23
+ end
24
24
  end
25
+ else
25
26
  end
26
27
 
@@ -1,47 +1,63 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Vdc", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Vdc", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :get_vdc }
7
+ it { should respond_to :get_vdc }
7
8
 
8
- describe :class do
9
- subject { Fog::Vcloud::Terremark::Ecloud::Vdc }
9
+ describe :class do
10
+ subject { Fog::Vcloud::Terremark::Ecloud::Vdc }
10
11
 
11
- it { should have_identity :href }
12
- it { should have_only_these_attributes [:href, :name, :other_links, :resource_entity_links, :network_links, :cpu_capacity,
13
- :storage_capacity, :memory_capacity, :vcloud_type, :xmlns, :description,
14
- :deployed_vm_quota, :instantiated_vm_quota] }
15
- end
12
+ it { should have_identity :href }
13
+ it { should have_only_these_attributes [:href, :name, :type, :description, :other_links, :compute_capacity, :storage_capacity, :available_networks,
14
+ :resource_entities, :deployed_vm_quota, :instantiated_vm_quota] }
15
+ end
16
16
 
17
- context "with no uri" do
17
+ context "with no uri" do
18
18
 
19
- subject { Fog::Vcloud::Terremark::Ecloud::Vdc.new() }
19
+ subject { Fog::Vcloud::Terremark::Ecloud::Vdc.new() }
20
20
 
21
- its(:href) { should be_nil }
22
- its(:identity) { should be_nil }
23
- end
21
+ it { should have_all_attributes_be_nil }
22
+ end
23
+
24
+ context "as a collection member" do
25
+ subject { @vcloud.vdcs[0].reload; @vcloud.vdcs[0] }
26
+
27
+ its(:href) { should == @mock_vdc[:href] }
28
+ its(:identity) { should == @mock_vdc[:href] }
29
+ its(:name) { should == @mock_vdc[:name] }
30
+ its(:public_ips) { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIps }
31
+ its(:other_links) { should have(4).items }
32
+ its(:resource_entities) { should have(3).items }
33
+ its(:available_networks) { should have(2).items }
34
+
35
+ its(:compute_capacity) { should == {:Memory =>
36
+ {:Allocated => @mock_vdc[:memory][:allocated], :Units => "bytes * 2^20"},
37
+ :DeployedVmsQuota =>
38
+ {:Limit => "-1", :Used => "-1"},
39
+ :InstantiatedVmsQuota =>
40
+ {:Limit => "-1", :Used => "-1"},
41
+ :Cpu =>
42
+ {:Allocated => @mock_vdc[:cpu][:allocated], :Units => "hz * 10^6"}} }
43
+
44
+ its(:storage_capacity) { should == {:Allocated => @mock_vdc[:storage][:allocated], :Used => @mock_vdc[:storage][:used], :Units => "bytes * 10^9"} }
45
+
46
+ its(:deployed_vm_quota) { should == nil }
47
+ its(:instantiated_vm_quota) { should == nil }
48
+
49
+ its(:public_ips) { should have(3).public_ips }
50
+ its(:internet_services) { should have(4).services }
51
+ its(:networks) { should have(2).networks }
52
+ its(:servers) { should have(3).servers }
53
+
54
+ #FIXME: need to mock tasks related requests first
55
+ #its(:tasks) { should have(0).tasks }
56
+
57
+ #FIXME: need to mock catalog related requests first
58
+ #its(:catalog) { should have(0).entries }
24
59
 
25
- context "as a collection member" do
26
- subject { @vcloud.vdcs[0] }
27
-
28
- its(:href) { should == URI.parse(@mock_vdc[:href]) }
29
- its(:identity) { should == URI.parse(@mock_vdc[:href]) }
30
- its(:name) { should == @mock_vdc[:name] }
31
- its(:public_ips) { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::PublicIps }
32
- its(:other_links) { should have(4).items }
33
- its(:resource_entity_links) { should have(3).items }
34
- its(:network_links) { should have(2).items }
35
-
36
- its(:cpu_capacity) { should == Struct::VcloudXCapacity.new('hz * 10^6',@mock_vdc[:cpu][:allocated]) }
37
- its(:memory_capacity) { should == Struct::VcloudXCapacity.new('bytes * 2^20',@mock_vdc[:memory][:allocated]) }
38
- its(:storage_capacity) { should == Struct::VcloudXCapacity.new('bytes * 10^9',@mock_vdc[:storage][:allocated], @mock_vdc[:storage][:used]) }
39
-
40
- its(:deployed_vm_quota) { should == Struct::VcloudXCapacity.new(nil,nil,-1,-1) }
41
- its(:instantiated_vm_quota) { should == Struct::VcloudXCapacity.new(nil,nil,-1,-1) }
42
-
43
- its(:public_ips) { should have(3).public_ips }
44
- its(:internet_services) { should have(4).services }
45
-
60
+ end
46
61
  end
62
+ else
47
63
  end
@@ -1,25 +1,28 @@
1
1
  require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
2
2
 
3
- describe "Fog::Vcloud::Terremark::Ecloud::Vdcs", :type => :tmrk_ecloud_model do
4
- subject { @vcloud }
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud::Terremark::Ecloud::Vdcs", :type => :mock_tmrk_ecloud_model do
5
+ subject { @vcloud }
5
6
 
6
- it { should respond_to :vdcs }
7
+ it { should respond_to :vdcs }
7
8
 
8
- describe :class do
9
- subject { @vcloud.vdcs.class }
10
- its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Vdc }
11
- its(:get_request) { should == :get_vdc }
12
- its(:all_request) { should be_an_instance_of Proc }
13
- its(:vcloud_type) { should == "application/vnd.vmware.vcloud.vdc+xml" }
14
- end
9
+ describe :class do
10
+ subject { @vcloud.vdcs.class }
11
+ its(:model) { should == Fog::Vcloud::Terremark::Ecloud::Vdc }
12
+ end
13
+
14
+ describe :vdcs do
15
+ subject { @vcloud.vdcs }
16
+ it { should_not respond_to :create }
15
17
 
16
- describe :vdcs do
17
- subject { @vcloud.vdcs }
18
+ it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Vdcs }
18
19
 
19
- it { should be_an_instance_of Fog::Vcloud::Terremark::Ecloud::Vdcs }
20
+ its(:length) { should == 2 }
20
21
 
21
- its(:length) { should == 2 }
22
+ it { should have_members_of_the_right_model }
22
23
 
23
- it { should have_members_of_the_right_model }
24
+ its(:organization_uri) { should == @mock_organization[:info][:href] }
25
+ end
24
26
  end
27
+ else
25
28
  end