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,57 +1,60 @@
1
- require "spec_helper"
2
-
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
5
-
6
- it { should respond_to :add_internet_service }
7
-
8
- describe "#add_internet_service" do
9
- before do
10
- @public_ip = @vcloud.vdcs[0].public_ips[0]
11
- @new_service_data = { :name => "Test Service",
12
- :protocol => "HTTP",
13
- :port => "80",
14
- :enabled => "true",
15
- :description => "this is a test" }
16
- end
17
-
18
- context "with a valid Public IP uri" do
19
- it "has the right number of Internet Services before" do
20
- before_services = @vcloud.get_internet_services(@public_ip.href)
21
- before_services.body.links.should have(2).links
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
+
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
6
+
7
+ it { should respond_to :add_internet_service }
8
+
9
+ describe "#add_internet_service" do
10
+ before do
11
+ @public_ip = @vcloud.vdcs[0].public_ips[0]
12
+ @new_service_data = { :name => "Test Service",
13
+ :protocol => "HTTP",
14
+ :port => "80",
15
+ :enabled => "true",
16
+ :description => "this is a test",
17
+ :redirect_url => "" }
22
18
  end
23
19
 
24
- subject { @vcloud.add_internet_service(@public_ip.href.to_s + "/internetServices", @new_service_data ) }
20
+ context "with a valid Public IP uri" do
21
+ it "has the right number of Internet Services before" do
22
+ before_services = @vcloud.get_internet_services(@public_ip.href)
23
+ before_services.body[:InternetService].should have(2).services
24
+ end
25
25
 
26
- it "has the right number of Internet Services after" do
27
- subject
28
- @vcloud.get_internet_services(@public_ip.href).body.links.should have(3).links
29
- end
26
+ subject { @vcloud.add_internet_service(@public_ip.href.to_s + "/internetServices", @new_service_data ) }
30
27
 
31
- it_should_behave_like "all requests"
28
+ it "has the right number of Internet Services after" do
29
+ subject
30
+ @vcloud.get_internet_services(@public_ip.href).body[:InternetService].should have(3).services
31
+ end
32
32
 
33
- let(:body) { subject.body }
33
+ it_should_behave_like "all responses"
34
34
 
35
- its(:body) { should be_an_instance_of Struct::TmrkEcloudInternetService }
36
- specify { body.href.to_s.should == Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href( { :id => 372 } ) }
37
- specify { body.name.should == "Test Service" }
38
- specify { body.protocol.should == "HTTP" }
39
- specify { body.enabled.should == true }
40
- specify { body.description.should == "this is a test" }
35
+ let(:body) { subject.body }
41
36
 
42
- let(:public_ip) { subject.body.public_ip }
43
- specify { public_ip.should be_an_instance_of Struct::TmrkEcloudPublicIp }
44
- specify { public_ip.name.should == @public_ip.name }
45
- specify { public_ip.id.should == @public_ip.id }
46
- specify { public_ip.type.should == "application/vnd.tmrk.ecloud.publicIp+xml" }
37
+ its(:body) { should be_an_instance_of Hash }
38
+ specify { body[:Href].should == Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href( { :id => 372 } ) }
39
+ specify { body[:Name].should == "Test Service" }
40
+ specify { body[:Protocol].should == "HTTP" }
41
+ specify { body[:Enabled].should == "true" }
42
+ specify { body[:Description].should == "this is a test" }
47
43
 
48
- end
44
+ let(:public_ip) { subject.body[:PublicIpAddress] }
45
+ specify { public_ip.should be_an_instance_of Hash }
46
+ specify { public_ip[:Name].should == @public_ip.name }
47
+ specify { public_ip[:Id].should == @public_ip.id }
49
48
 
50
- context "with a public_ips_uri that doesn't exist" do
51
- subject { lambda { @vcloud.add_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @new_service_data ) } }
49
+ end
52
50
 
53
- it_should_behave_like "a request for a resource that doesn't exist"
51
+ context "with a public_ips_uri that doesn't exist" do
52
+ subject { lambda { @vcloud.add_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @new_service_data ) } }
53
+
54
+ it_should_behave_like "a request for a resource that doesn't exist"
55
+ end
54
56
  end
55
57
  end
58
+ else
56
59
  end
57
60
 
@@ -1,44 +1,49 @@
1
- require "spec_helper"
2
-
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
5
-
6
- it { should respond_to :configure_internet_service }
7
-
8
- describe "#configure_internet_service" do
9
- before do
10
- @public_ip = @vcloud.vdcs[0].public_ips[0]
11
- @original_service = @vcloud.get_internet_services(@public_ip.href).body.links.first
12
- @service_data = {}
13
- @original_service.each_pair { |sym, data| @service_data[sym] = data }
14
- @ip_data = { :id => @public_ip.id, :name => @public_ip.name, :href => @public_ip.href.to_s }
15
- end
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
+
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
6
+
7
+ it { should respond_to :configure_internet_service }
8
+
9
+ describe "#configure_internet_service" do
10
+ before do
11
+ @public_ip = @vcloud.vdcs[0].public_ips[0]
12
+ @original_service = @vcloud.get_internet_services(@public_ip.href).body[:InternetService].first
13
+ @ip_data = { :id => @public_ip.id, :name => @public_ip.name, :href => @public_ip.href.to_s }
14
+ @service_data = { :name => @original_service[:Name], :protocol => @original_service[:Protocol],
15
+ :port => @original_service[:Port], :description => @original_service[:Description],
16
+ :enabled => @original_service[:Enabled], :redirect_url => @original_service[:RedirectURL],
17
+ :id => @original_service[:Id], :href => @original_service[:Href], :timeout => @original_service[:Timeout] }
18
+ end
16
19
 
17
- context "with a valid Internet Service uri and valid data" do
20
+ context "with a valid Internet Service uri and valid data" do
18
21
 
19
- subject { @vcloud.configure_internet_service(@original_service.href, @service_data, @ip_data) }
22
+ subject { @vcloud.configure_internet_service(@original_service[:Href], @service_data, @ip_data) }
20
23
 
21
- it_should_behave_like "all requests"
24
+ it_should_behave_like "all responses"
22
25
 
23
- context "with some changed data" do
24
- before do
25
- @service_data[:description] = "TEST BOOM"
26
+ context "with some changed data" do
27
+ before do
28
+ @service_data[:description] = "TEST BOOM"
29
+ end
30
+ it "should change data" do
31
+ @original_service[:Description].should == "Web Servers"
32
+ result = subject
33
+ result.body[:Description].should == "TEST BOOM"
34
+ @vcloud.get_internet_services(@public_ip.href).body[:InternetService].first[:Description].should == "TEST BOOM"
35
+ end
26
36
  end
27
- it "should change data" do
28
- @original_service.description.should == "Web Servers"
29
- result = subject
30
- result.body.description.should == "TEST BOOM"
31
- @vcloud.get_internet_services(@public_ip.href).body.links.first.description.should == "TEST BOOM"
32
- end
33
- end
34
37
 
35
- end
38
+ end
36
39
 
37
- context "with an internet_services_uri that doesn't exist" do
38
- subject { lambda { @vcloud.configure_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @service_data, @ip_data ) } }
40
+ context "with an internet_services_uri that doesn't exist" do
41
+ subject { lambda { @vcloud.configure_internet_service(URI.parse('https://www.fakey.c/piv8vc99'), @service_data, @ip_data ) } }
39
42
 
40
- it_should_behave_like "a request for a resource that doesn't exist"
43
+ it_should_behave_like "a request for a resource that doesn't exist"
44
+ end
41
45
  end
42
46
  end
47
+ else
43
48
  end
44
49
 
@@ -1,34 +1,37 @@
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 :delete_internet_service }
7
+ #it { should respond_to :delete_internet_service }
7
8
 
8
- describe "#delete_internet_service" do
9
- before do
10
- @public_ip = @vcloud.vdcs[0].public_ips[0]
11
- @before_services = @vcloud.get_internet_services(@public_ip.href)
12
- end
9
+ #describe "#delete_internet_service" do
10
+ # before do
11
+ # @public_ip = @vcloud.vdcs[0].public_ips[0]
12
+ # @before_services = @vcloud.get_internet_services(@public_ip.href)
13
+ # end
13
14
 
14
- context "with a valid internet service uri" do
15
- subject { @vcloud.delete_internet_service(@before_services.body.links[0].href) }
15
+ # context "with a valid internet service uri" do
16
+ # subject { @vcloud.delete_internet_service(@before_services.body.tap{|o| pp o}.links[0].href) }
17
+ #
18
+ # specify { @before_services.body.links.should have(2).links }
16
19
 
17
- specify { @before_services.body.links.should have(2).links }
20
+ # it "has the right number of Internet Services after" do
21
+ # subject
22
+ # after_services = @vcloud.get_internet_services(@public_ip.href)
23
+ # after_services.body.links.should have(1).link
24
+ # end
18
25
 
19
- it "has the right number of Internet Services after" do
20
- subject
21
- after_services = @vcloud.get_internet_services(@public_ip.href)
22
- after_services.body.links.should have(1).link
23
- end
26
+ # end
24
27
 
25
- end
28
+ # context "with a public_ips_uri that doesn't exist" do
29
+ # subject { lambda { @vcloud.delete_internet_service(URI.parse('https://www.fakey.c/piv8vc99')) } }
26
30
 
27
- context "with a public_ips_uri that doesn't exist" do
28
- subject { lambda { @vcloud.delete_internet_service(URI.parse('https://www.fakey.c/piv8vc99')) } }
29
-
30
- it_should_behave_like "a request for a resource that doesn't exist"
31
- end
31
+ # it_should_behave_like "a request for a resource that doesn't exist"
32
+ # end
33
+ #end
32
34
  end
35
+ else
33
36
  end
34
37
 
@@ -1,57 +1,65 @@
1
- require "spec_helper"
2
-
3
- describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :tmrk_ecloud_request do
4
- subject { @vcloud }
5
-
6
- it { should respond_to :get_internet_services }
7
-
8
- describe "#get_internet_services" do
9
- context "with a valid VDC internet_services_uri" do
10
- before { @services = @vcloud.get_internet_services(URI.parse(@mock_vdc[:href] + "/internetServices")) }
11
- subject { @services }
12
-
13
- it_should_behave_like "all requests"
14
-
15
- its(:headers) { should include "Content-Type" }
16
- specify { subject.headers['Content-Type'].should == "application/vnd.tmrk.ecloud.internetServicesList+xml" }
17
-
18
- its(:body) { should be_an_instance_of Struct::TmrkEcloudList }
19
-
20
- describe "#body" do
21
- describe "#links" do
22
- subject { @services.body.links }
23
-
24
- it { should have(4).services }
25
-
26
- [0,1,2,3].each do |idx|
27
- let(:service) { subject[idx] }
28
- let(:mock_service) { @mock_vdc[:public_ips].map { |ip| ip[:services] }.flatten[idx] }
29
- let(:mock_ip) { @mock_vdc[:public_ips].detect { |ip| ip[:services].detect { |ipservice| ipservice[:id] == service.id } } }
30
- specify { service.should be_an_instance_of Struct::TmrkEcloudInternetService }
31
- specify { service.name.should == mock_service[:name] }
32
- specify { service.id.should == mock_service[:id] }
33
- specify { service.href.should == URI.parse(Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(mock_service)) }
34
- specify { service.type.should == "application/vnd.tmrk.ecloud.internetService+xml" }
35
- specify { service.public_ip.should be_an_instance_of Struct::TmrkEcloudPublicIp }
36
- specify { service.public_ip.name.should == mock_ip[:name] }
37
- specify { service.public_ip.id.should == mock_ip[:id] }
38
- specify { service.public_ip.type.should == "application/vnd.tmrk.ecloud.publicIp+xml" }
39
- specify { service.port.should == mock_service[:port] }
40
- specify { service.protocol.should == mock_service[:protocol] }
41
- specify { service.enabled.should == mock_service[:enabled] }
42
- specify { service.timeout.should == mock_service[:timeout] }
43
- specify { service.description.should == mock_service[:description] }
44
- specify { service.url_send_string.should == nil }
45
- specify { service.http_header.should == nil }
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
+
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
6
+
7
+ it { should respond_to :get_internet_services }
8
+
9
+ describe "#get_internet_services" do
10
+ context "with a valid VDC internet_services_uri" do
11
+ before { @services = @vcloud.get_internet_services( @mock_vdc[:href] + "/internetServices" ) }
12
+ subject { @services }
13
+
14
+ it_should_behave_like "all responses"
15
+ it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.internetServicesList+xml" }
16
+
17
+ describe "#body" do
18
+ subject { @services.body }
19
+
20
+ it { should have(3).items }
21
+
22
+ its(:xmlns) { should == "urn:tmrk:eCloudExtensions-2.3" }
23
+ its(:xmlns_i) { should == "http://www.w3.org/2001/XMLSchema-instance" }
24
+
25
+ context "[:InternetService]" do
26
+ subject { @services.body[:InternetService] }
27
+
28
+ it { should have(4).items }
29
+
30
+ [0,1,2,3].each do |idx|
31
+ let(:service) { subject[idx] }
32
+ let(:mock_service) { @mock_vdc[:public_ips].map { |ip| ip[:services] }.flatten[idx] }
33
+ let(:mock_ip) { @mock_vdc[:public_ips].detect { |ip| ip[:services].detect { |ipservice| ipservice[:id] == service[:Id] } } }
34
+ specify { service.should be_an_instance_of Hash }
35
+ specify { service.should have(11).attributes }
36
+ specify { service[:Name].should == mock_service[:name] }
37
+ specify { service[:Id].should == mock_service[:id] }
38
+ specify { service[:Href].should == Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(mock_service) }
39
+
40
+ specify { service[:PublicIpAddress].should be_an_instance_of Hash }
41
+ specify { service[:PublicIpAddress].should have(3).attributes }
42
+ specify { service[:PublicIpAddress][:Name].should == mock_ip[:name] }
43
+ specify { service[:PublicIpAddress][:Id].should == mock_ip[:id] }
44
+
45
+ specify { service[:Port].should == mock_service[:port] }
46
+ specify { service[:Protocol].should == mock_service[:protocol] }
47
+ specify { service[:Enabled].should == mock_service[:enabled] }
48
+ specify { service[:Timeout].should == mock_service[:timeout] }
49
+ specify { service[:Description].should == mock_service[:description] }
50
+ specify { service[:RedirectURL].should == "" }
51
+ specify { service[:Monitor].should == "" }
52
+ end
46
53
  end
47
54
  end
48
55
  end
49
- end
50
56
 
51
- context "with a public_ips_uri that doesn't exist" do
52
- subject { lambda { @vcloud.get_internet_services(URI.parse('https://www.fakey.c/piv8vc99')) } }
57
+ context "with a public_ips_uri that doesn't exist" do
58
+ subject { lambda { @vcloud.get_internet_services(URI.parse('https://www.fakey.c/piv8vc99')) } }
53
59
 
54
- it_should_behave_like "a request for a resource that doesn't exist"
60
+ it_should_behave_like "a request for a resource that doesn't exist"
61
+ end
55
62
  end
56
63
  end
64
+ else
57
65
  end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper')
2
+
3
+ if Fog.mocking?
4
+ describe "Fog::Vcloud, initialized w/ the TMRK Ecloud module", :type => :mock_tmrk_ecloud_request do
5
+ subject { @vcloud }
6
+
7
+ it { should respond_to :get_network_ip }
8
+
9
+ describe "#get_network_ip" do
10
+ context "with a valid ip_uri" do
11
+ before do
12
+ @mock_network = @mock_vdc[:networks][0]
13
+ @mock_ip = @mock_network[:ips].keys.first
14
+ @mock_ip_href = "#{Fog::Vcloud::Terremark::Ecloud::Mock.extension_url}/ip/#{@mock_ip.gsub('.','')}"
15
+ @ip = @vcloud.get_network_ip( @mock_ip_href )
16
+ end
17
+
18
+ subject { @ip }
19
+
20
+ it_should_behave_like "all responses"
21
+ it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.ip+xml" }
22
+
23
+ describe "#body" do
24
+ subject { @ip.body }
25
+
26
+ its(:Name) { should == @mock_ip }
27
+ its(:Href) { should == @mock_ip_href }
28
+ its(:Id) { should == @mock_ip.gsub('.','') }
29
+
30
+ end
31
+ end
32
+
33
+ context "with an ip_uri that doesn't exist" do
34
+ subject { lambda { @vcloud.get_network_ip('https://www.fakey.c/piv89') } }
35
+
36
+ it_should_behave_like "a request for a resource that doesn't exist"
37
+ end
38
+ end
39
+ end
40
+ else
41
+ end
@@ -1,54 +1,59 @@
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_network_ips }
7
+ it { should respond_to :get_network_ips }
7
8
 
8
- describe "#get_network_ips" do
9
- context "with a valid VDC network ips_uri" do
10
- before { @ips = @vcloud.get_network_ips(URI.parse(@mock_network[:href] + "/ips")) }
11
- subject { @ips }
9
+ describe "#get_network_ips" do
10
+ context "with a valid VDC network ips_uri" do
11
+ before { @ips = @vcloud.get_network_ips( @mock_network[:href] + "/ips" ) }
12
+ subject { @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.ipAddressesList+xml" }
14
16
 
15
- its(:headers) { should include "Content-Type" }
16
- specify { subject.headers['Content-Type'].should == "application/vnd.tmrk.ecloud.ipAddressesList+xml" }
17
+ describe "#body" do
18
+ subject { @ips.body }
17
19
 
18
- its(:body) { should be_an_instance_of Struct::TmrkEcloudNetworkIps }
20
+ it { should have(1).item }
19
21
 
20
- describe "#body" do
21
- describe "#addresses" do
22
- subject { @ips.body.addresses }
22
+ context "[:IpAddress]" do
23
+ subject { @ips.body[:IpAddress] }
23
24
 
24
- it { should have(252).addresses }
25
-
26
- describe "one we know is assigned" do
27
- let(:address) { subject[0] }
28
-
29
- specify { address.status.should == "Assigned" }
30
- specify { address.server.should == "Broom 1" }
31
- specify { address.name.should == "1.2.3.3" }
25
+ # Note the real TMRK API returns only "assigned" ips currently
26
+ # This is a bug they've slated to fix in the next release.
27
+ it { should have(252).addresses }
32
28
 
33
29
  end
34
30
 
35
- describe "one we know is not assigned" do
36
- let(:address) { subject[100] }
37
-
38
- specify { address.status.should == "Available" }
39
- specify { address.server.should == nil }
40
- specify { address.name.should == "1.2.3.103" }
41
-
31
+ context "one we know is assigned" do
32
+ let(:address) { @ips.body[:IpAddress][0] }
33
+ specify { address.should have(5).keys }
34
+ specify { address[:Status].should == "Assigned" }
35
+ specify { address[:Server].should == "Broom 1" }
36
+ specify { address[:Name].should == "1.2.3.3" }
37
+ specify { address[:RnatAddress].should == "99.1.2.3" }
42
38
  end
43
39
 
40
+ context "one we know is assigned" do
41
+ let(:address) { @ips.body[:IpAddress][100] }
42
+ specify { address.should have(4).keys }
43
+ specify { address[:Status].should == "Available" }
44
+ specify { address.has_key?(:Server).should be_false }
45
+ specify { address[:Name].should == "1.2.3.103" }
46
+ specify { address[:RnatAddress].should == "99.1.2.3" }
47
+ end
44
48
  end
45
49
  end
46
- end
47
50
 
48
- context "with a network ips uri that doesn't exist" do
49
- subject { lambda { @vcloud.get_network_ips(URI.parse('https://www.fakey.c/piv8vc99')) } }
51
+ context "with a network ips uri that doesn't exist" do
52
+ subject { lambda { @vcloud.get_network_ips(URI.parse('https://www.fakey.c/piv8vc99')) } }
50
53
 
51
- it_should_behave_like "a request for a resource that doesn't exist"
54
+ it_should_behave_like "a request for a resource that doesn't exist"
55
+ end
52
56
  end
53
57
  end
58
+ else
54
59
  end