fog 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.2.3'
10
+ s.version = '0.2.4'
11
11
  s.date = '2010-06-29'
12
12
  s.rubyforge_project = 'fog'
13
13
 
data/lib/fog.rb CHANGED
@@ -39,7 +39,7 @@ require 'fog/vcloud'
39
39
  module Fog
40
40
 
41
41
  unless const_defined?(:VERSION)
42
- VERSION = '0.2.3'
42
+ VERSION = '0.2.4'
43
43
  end
44
44
 
45
45
  module Mock
@@ -74,7 +74,6 @@ module Fog
74
74
 
75
75
  def self.data( base_url = self.base_url )
76
76
  @mock_data ||= begin
77
- extension_href =
78
77
  vcloud_data = Fog::Vcloud::Mock.data(base_url)
79
78
  vcloud_data.delete( :versions )
80
79
  vcloud_data.merge!( :versions => [ { :version => "v0.8b-ext2.3", :login_url => "#{base_url}/login", :supported => true } ] )
@@ -85,16 +84,26 @@ module Fog
85
84
  :href => extension_url + "/publicIp/51",
86
85
  :name => "99.1.2.3",
87
86
  :services => [
88
- { :id => "71", :port => "80", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'Web Site', :description => 'Web Servers' },
89
- { :id => "72", :port => "7000", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'An SSH Map', :description => 'SSH 1' }
87
+ { :id => "71", :href => extension_url + "/internetService/71", :port => "80", :protocol => 'HTTP', :enabled => "true",
88
+ :timeout => "2", :name => 'Web Site', :description => 'Web Servers', :redirect_url => 'http://fakey.com',
89
+ :nodes => [ {:ip => "1.2.3.5", :name => "Test Node 1", :port => "80", :enabled => "true", :description => "web 1" }
90
+ ] },
91
+ { :id => "72", :href => extension_url + "/internetService/72", :port => "7000", :protocol => 'HTTP', :enabled => "true",
92
+ :timeout => "2", :name => 'An SSH Map', :description => 'SSH 1', :redirect_url => '',
93
+ :nodes => [ {:ip => "1.2.3.5", :name => "SSH", :port => "22", :enabled => "true", :description => "web ssh" }
94
+ ] }
90
95
  ]
91
96
  },
92
97
  { :id => "52",
93
98
  :href => extension_url + "/publicIp/52",
94
99
  :name => "99.1.2.4",
95
100
  :services => [
96
- { :id => "73", :port => "80", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'Web Site', :description => 'Web Servers' },
97
- { :id => "74", :port => "7000", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'An SSH Map', :description => 'SSH 2' }
101
+ { :id => "73", :href => extension_url + "/internetService/73", :port => "80", :protocol => 'HTTP', :enabled => "true",
102
+ :timeout => "2", :name => 'Web Site', :description => 'Web Servers', :redirect_url => 'http://fakey.com',
103
+ :nodes => [] },
104
+ { :id => "74", :href => extension_url + "/internetService/74", :port => "7000", :protocol => 'HTTP', :enabled => "true",
105
+ :timeout => "2", :name => 'An SSH Map', :description => 'SSH 2', :redirect_url => '',
106
+ :nodes => [] }
98
107
  ]
99
108
  },
100
109
  { :id => "53",
@@ -14,7 +14,7 @@ module Fog
14
14
  builder.Port(service_data[:port])
15
15
  builder.Enabled(service_data[:enabled])
16
16
  builder.Description(service_data[:description])
17
- builder.RedirectUrl(service_data[:redirect_url])
17
+ builder.RedirectURL(service_data[:redirect_url])
18
18
  #builder.Monitor {
19
19
  # builder.MonitorType {}
20
20
  # builder.UrlSendString {}
@@ -4,7 +4,7 @@ module Fog
4
4
  module Ecloud
5
5
  module Real
6
6
 
7
- def generate_configure_internet_service_request(service_data,ip_address_data)
7
+ def generate_configure_internet_service_response(service_data,ip_address_data)
8
8
  builder = Builder::XmlMarkup.new
9
9
  builder.InternetService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
10
10
  :xmlns => "urn:tmrk:eCloudExtensions-2.3") {
@@ -38,7 +38,7 @@ module Fog
38
38
  validate_public_ip_address_data(ip_address_data)
39
39
 
40
40
  request(
41
- :body => generate_configure_internet_service_request(service_data, ip_address_data),
41
+ :body => generate_configure_internet_service_response(service_data, ip_address_data),
42
42
  :expects => 200,
43
43
  :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
44
44
  :method => 'PUT',
@@ -62,33 +62,16 @@ module Fog
62
62
 
63
63
  internet_service_uri = ensure_unparsed(internet_service_uri)
64
64
 
65
- found = false
66
65
  xml = nil
66
+
67
67
  if ip = ip_from_uri(ip_address_data[:href])
68
68
  if service = ip[:services].detect { |service| service[:id] == internet_service_uri.split('/')[-1] }
69
- found = true
70
69
  ip[:services][ip[:services].index(service)] = service_data
71
-
72
- builder = Builder::XmlMarkup.new
73
- xml = builder.InternetService(:xmlns => "urn:tmrk:eCloudExtensions-2.0",
74
- :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {
75
- builder.Id(service_data[:id])
76
- builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(service_data))
77
- builder.Name(service_data[:name])
78
- builder.PublicIpAddress {
79
- builder.Id(ip[:id])
80
- builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.public_ip_href(ip))
81
- builder.Name(ip[:name])
82
- }
83
- builder.Protocol(service_data[:protocol])
84
- builder.Port(service_data[:port])
85
- builder.Enabled(service_data[:enabled])
86
- builder.Description(service_data[:description])
87
- builder.Timeout(service_data[:timeout])
88
- }
70
+ xml = generate_configure_internet_service_response(service_data, ip)
89
71
  end
90
72
  end
91
- if found
73
+
74
+ if xml
92
75
  mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
93
76
  else
94
77
  mock_error 200, "401 Unauthorized"
@@ -31,7 +31,7 @@ module Fog
31
31
  xml.Enabled(service[:enabled])
32
32
  xml.Timeout(service[:timeout])
33
33
  xml.Description(service[:description])
34
- xml.RedirectURL
34
+ xml.RedirectURL(service[:redirect_url])
35
35
  xml.Monitor
36
36
  }
37
37
  end
@@ -226,10 +226,12 @@ Spec::Runner.configure do |config|
226
226
  config.before(:all, :type => :mock_tmrk_ecloud_request) do
227
227
  @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
228
228
  @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
229
- @mock_version = @mock_data[:versions][0]
230
- @mock_organization = @mock_data[:organizations][0]
231
- @mock_vdc = @mock_organization[:vdcs][0]
232
- @mock_network = @mock_vdc[:networks][0]
229
+ @mock_version = @mock_data[:versions].first
230
+ @mock_organization = @mock_data[:organizations].first
231
+ @mock_vdc = @mock_organization[:vdcs].first
232
+ @mock_public_ip = @mock_vdc[:public_ips].first
233
+ @mock_service = @mock_public_ip[:services].first
234
+ @mock_network = @mock_vdc[:networks].first
233
235
  end
234
236
  config.after(:all, :type => :mock_tmrk_ecloud_request) do
235
237
  Fog::Vcloud::Terremark::Ecloud::Mock.data_reset
@@ -237,10 +239,12 @@ Spec::Runner.configure do |config|
237
239
  config.before(:all, :type => :mock_tmrk_ecloud_model) do
238
240
  @base_url = Fog::Vcloud::Terremark::Ecloud::Mock.base_url
239
241
  @mock_data = Fog::Vcloud::Terremark::Ecloud::Mock.data
240
- @mock_version = @mock_data[:versions][0]
241
- @mock_organization = @mock_data[:organizations][0]
242
- @mock_vdc = @mock_organization[:vdcs][0]
243
- @mock_network = @mock_vdc[:networks][0]
242
+ @mock_version = @mock_data[:versions].first
243
+ @mock_organization = @mock_data[:organizations].first
244
+ @mock_vdc = @mock_organization[:vdcs].first
245
+ @mock_public_ip = @mock_vdc[:public_ips].first
246
+ @mock_service = @mock_public_ip[:services].first
247
+ @mock_network = @mock_vdc[:networks].first
244
248
  end
245
249
  config.before(:each, :type => :mock_tmrk_ecloud_model) do
246
250
  @vcloud = Fog::Vcloud.new(:username => "foo", :password => "bar", :versions_uri => "http://fakey.com/api/versions", :module => "Fog::Vcloud::Terremark::Ecloud")
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__),'..','..','..','spec_helper')
3
3
  if Fog.mocking?
4
4
  describe "Fog::Vcloud::Terremark::Ecloud::InternetService", :type => :mock_tmrk_ecloud_model do
5
5
  before do
6
- @mock_ip = @mock_vdc[:public_ips].first
7
- @mock_service = @mock_ip[:services].first
8
6
  @mock_service_uri = "#{@base_url}/extensions/internetService/#{@mock_service[:id]}"
9
7
  end
10
8
 
@@ -41,13 +39,13 @@ if Fog.mocking?
41
39
  its(:identity) { should == @mock_service_uri }
42
40
  its(:name) { should == @mock_service[:name] }
43
41
  its(:id) { should == @mock_service[:id] }
44
- its(:protocol) { should == "HTTP" }
45
- its(:port) { should == "80" }
46
- its(:enabled) { should == "true" }
47
- its(:description) { should == "Web Servers" }
42
+ its(:protocol) { should == @mock_service[:protocol] }
43
+ its(:port) { should == @mock_service[:port] }
44
+ its(:enabled) { should == @mock_service[:enabled] }
45
+ its(:description) { should == @mock_service[:description] }
48
46
  its(:public_ip) { should == public_ip }
49
- its(:timeout) { should == "2" }
50
- its(:redirect_url) { should == "" }
47
+ its(:timeout) { should == @mock_service[:timeout] }
48
+ its(:redirect_url) { should == @mock_service[:redirect_url] }
51
49
  its(:monitor) { should == "" }
52
50
 
53
51
  specify { composed_public_ip_data[:href].should == public_ip[:Href].to_s }
@@ -8,7 +8,7 @@ if Fog.mocking?
8
8
 
9
9
  describe "#configure_internet_service" do
10
10
  before do
11
- @public_ip = @vcloud.vdcs[0].public_ips[0]
11
+ @public_ip = @vcloud.vdcs.first.public_ips.first
12
12
  @original_service = @vcloud.get_internet_services(@public_ip.href).body[:InternetService].first
13
13
  @ip_data = { :id => @public_ip.id, :name => @public_ip.name, :href => @public_ip.href.to_s }
14
14
  @service_data = { :name => @original_service[:Name], :protocol => @original_service[:Protocol],
@@ -26,12 +26,23 @@ if Fog.mocking?
26
26
  context "with some changed data" do
27
27
  before do
28
28
  @service_data[:description] = "TEST BOOM"
29
+ @service_data[:redirect_url] = "http://google.com"
30
+ @service_data[:port] = "80"
29
31
  end
30
32
  it "should change data" do
31
- @original_service[:Description].should == "Web Servers"
33
+ @original_service[:Description].should == @mock_service[:description]
34
+ @original_service[:RedirectURL].should == @mock_service[:redirect_url]
35
+ @original_service[:Port].should == @mock_service[:port]
32
36
  result = subject
33
- result.body[:Description].should == "TEST BOOM"
34
- @vcloud.get_internet_services(@public_ip.href).body[:InternetService].first[:Description].should == "TEST BOOM"
37
+ result.body[:Description].should == @service_data[:description]
38
+ result.body[:RedirectURL].should == @service_data[:redirect_url]
39
+ result.body[:Port].should == @service_data[:port]
40
+
41
+ new_result = @vcloud.get_internet_services(@public_ip.href).body[:InternetService].first
42
+
43
+ new_result[:Description].should == @service_data[:description]
44
+ new_result[:RedirectURL].should == @service_data[:redirect_url]
45
+ new_result[:Port].should == @service_data[:port]
35
46
  end
36
47
  end
37
48
 
@@ -47,7 +47,57 @@ if Fog.mocking?
47
47
  specify { service[:Enabled].should == mock_service[:enabled] }
48
48
  specify { service[:Timeout].should == mock_service[:timeout] }
49
49
  specify { service[:Description].should == mock_service[:description] }
50
- specify { service[:RedirectURL].should == "" }
50
+ specify { service[:RedirectURL].should == mock_service[:redirect_url] }
51
+ specify { service[:Monitor].should == "" }
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ context "with a valid Public IP uri" do
58
+ before do
59
+ @mock_public_ip = @mock_vdc[:public_ips].first
60
+ @services = @vcloud.get_internet_services( @mock_public_ip[:href] + "/internetServices" )
61
+ end
62
+ subject { @services }
63
+
64
+ it_should_behave_like "all responses"
65
+ it { should have_headers_denoting_a_content_type_of "application/vnd.tmrk.ecloud.internetServicesList+xml" }
66
+
67
+ describe "#body" do
68
+ subject { @services.body }
69
+
70
+ it { should have(3).items }
71
+
72
+ its(:xmlns) { should == "urn:tmrk:eCloudExtensions-2.3" }
73
+ its(:xmlns_i) { should == "http://www.w3.org/2001/XMLSchema-instance" }
74
+
75
+ context "[:InternetService]" do
76
+ subject { @services.body[:InternetService] }
77
+
78
+ it { should have(2).items }
79
+
80
+ [0,1].each do |idx|
81
+ let(:service) { subject[idx] }
82
+ let(:mock_service) { @mock_public_ip[:services][idx] }
83
+ let(:mock_ip) { @mock_public_ip }
84
+ specify { service.should be_an_instance_of Hash }
85
+ specify { service.should have(11).attributes }
86
+ specify { service[:Name].should == mock_service[:name] }
87
+ specify { service[:Id].should == mock_service[:id] }
88
+ specify { service[:Href].should == Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(mock_service) }
89
+
90
+ specify { service[:PublicIpAddress].should be_an_instance_of Hash }
91
+ specify { service[:PublicIpAddress].should have(3).attributes }
92
+ specify { service[:PublicIpAddress][:Name].should == mock_ip[:name] }
93
+ specify { service[:PublicIpAddress][:Id].should == mock_ip[:id] }
94
+
95
+ specify { service[:Port].should == mock_service[:port] }
96
+ specify { service[:Protocol].should == mock_service[:protocol] }
97
+ specify { service[:Enabled].should == mock_service[:enabled] }
98
+ specify { service[:Timeout].should == mock_service[:timeout] }
99
+ specify { service[:Description].should == mock_service[:description] }
100
+ specify { service[:RedirectURL].should == mock_service[:redirect_url] }
51
101
  specify { service[:Monitor].should == "" }
52
102
  end
53
103
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)