cloudlb 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.gem
2
+ Gemfile.lock
@@ -1,8 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib/', __FILE__)
3
3
  $:.unshift lib unless $:.include?(lib)
4
-
5
- require 'cloudlb'
4
+
5
+ require File.expand_path('../lib/cloudlb/version', __FILE__)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cloudlb"
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency "json"
21
21
 
22
22
  s.files = [
23
- "VERSION",
24
23
  "COPYING",
25
24
  ".gitignore",
26
25
  "README.rdoc",
@@ -32,7 +31,8 @@ Gem::Specification.new do |s|
32
31
  "lib/cloudlb/exception.rb",
33
32
  "lib/cloudlb/node.rb",
34
33
  "lib/cloudlb/health_monitor.rb",
35
- "lib/cloudlb/connection_throttle.rb"
34
+ "lib/cloudlb/connection_throttle.rb",
35
+ "lib/cloudlb/version.rb"
36
36
  ]
37
37
  s.require_path = 'lib'
38
- end
38
+ end
@@ -20,7 +20,6 @@ module CloudLB
20
20
  AUTH_USA = "https://auth.api.rackspacecloud.com/v1.0"
21
21
  AUTH_UK = "https://lon.auth.api.rackspacecloud.com/v1.0"
22
22
 
23
- VERSION = IO.read(File.dirname(__FILE__) + '/../VERSION').chomp
24
23
  require 'uri'
25
24
  require 'rubygems'
26
25
  require 'json'
@@ -33,6 +32,7 @@ module CloudLB
33
32
  end
34
33
 
35
34
  $:.unshift(File.dirname(__FILE__))
35
+ require 'cloudlb/version'
36
36
  require 'cloudlb/exception'
37
37
  require 'cloudlb/authentication'
38
38
  require 'cloudlb/connection'
@@ -9,10 +9,10 @@ module CloudLB
9
9
  # Should probably never be called directly.
10
10
  def initialize(connection)
11
11
  request = Typhoeus::Request.new(connection.auth_url,
12
- :method => :get,
13
- :headers => { "X-Auth-User" => connection.authuser, "X-Auth-Key" => connection.authkey },
14
- :disable_ssl_peer_verification => true,
15
- :verbose => ENV['LOADBALANCERS_VERBOSE'] ? true : false)
12
+ :method => :get,
13
+ :headers => { "X-Auth-User" => connection.authuser, "X-Auth-Key" => connection.authkey },
14
+ :user_agent => "Cloud Load Balancers Ruby API #{VERSION}",
15
+ :verbose => ENV['LOADBALANCERS_VERBOSE'] ? true : false)
16
16
  CloudLB.hydra.queue(request)
17
17
  CloudLB.hydra.run
18
18
  response = request.response
@@ -20,14 +20,7 @@ module CloudLB
20
20
  if (response.code.to_s == "204")
21
21
  connection.authtoken = headers["x-auth-token"]
22
22
  user_id = headers["x-server-management-url"].match(/.*\/(\d+)$/)[1]
23
- headers["x-server-management-url"] = case connection.region
24
- when :ord
25
- "https://ord.loadbalancers.api.rackspacecloud.com/v1.0/#{user_id}"
26
- when :dfw
27
- "https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/#{user_id}"
28
- else
29
- raise
30
- end
23
+ headers["x-server-management-url"] = "https://#{connection.region}.loadbalancers.api.rackspacecloud.com/v1.0/#{user_id}"
31
24
  connection.lbmgmthost = URI.parse(headers["x-server-management-url"]).host
32
25
  connection.lbmgmtpath = URI.parse(headers["x-server-management-url"]).path.chomp
33
26
  # Force the path into the v1.0 URL space
@@ -32,7 +32,7 @@ module CloudLB
32
32
  @protocol = data["protocol"]
33
33
  @port = data["port"]
34
34
  @algorithm = data["algorithm"]
35
- @connection_logging = data["connectionLogging"]
35
+ @connection_logging = data["connectionLogging"]["enabled"]
36
36
  @status = data["status"]
37
37
  true
38
38
  end
@@ -182,10 +182,16 @@ module CloudLB
182
182
  end
183
183
  alias :access_list :list_access_list
184
184
 
185
- # FIXME: Does not work (JSON error)
185
+ # Adds an entry to your access list. You must supply the :address (an IP address) and :type (either ALLOW or DENY).
186
+ # Items that are configured with the ALLOW type will always take precedence over items with the DENY type.
187
+ #
188
+ # >> balancer.add_to_access_list(:address => '192.168.5.99', :type => 'DENY')
189
+ # => true
190
+ # >> b.list_access_list
191
+ # => [{"address"=>"192.168.5.99", "id"=>96, "type"=>"DENY"}]
186
192
  def add_to_access_list(options={})
187
193
  (raise CloudLB::Exception::MissingArgument, "Must supply address and type") unless (options[:address] && options[:type])
188
- body = {'networkItems' => [ { :address => options[:address], :type => options[:type].upcase}]}.to_json
194
+ body = {'accessList' => [ { :address => options[:address], :type => options[:type].upcase}]}.to_json
189
195
  response = @connection.lbreq("POST",@lbmgmthost,"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/accesslist",@lbmgmtport,@lbmgmtscheme,{},body)
190
196
  CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)
191
197
  true
@@ -202,7 +208,10 @@ module CloudLB
202
208
  true
203
209
  end
204
210
 
205
- # TODO
211
+ # Deletes one member of the access list by id.
212
+ #
213
+ # >> balancer.delete_access_list_member(95)
214
+ # => true
206
215
  def delete_access_list_member(id)
207
216
  response = @connection.lbreq("DELETE",@lbmgmthost,"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/accesslist/#{CloudLB.escape(id.to_s)}",@lbmgmtport,@lbmgmtscheme,{})
208
217
  CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)
@@ -80,7 +80,7 @@ module CloudLB
80
80
 
81
81
  # Creates a brand new load balancer under your account.
82
82
  #
83
- # A minimal request must pass in :name, :protocol, :nodes, and either :virtual_ip_ids or :virtual_ip_types.
83
+ # A minimal request must pass in :name, :protocol, :port, :nodes, and either :virtual_ip_ids or :virtual_ip_types.
84
84
  #
85
85
  # Options:
86
86
  # :name - the name of the load balancer. Limted to 128 characters or less.
@@ -90,7 +90,7 @@ module CloudLB
90
90
  # the port on the target server, and the condition ("ENABLED", "DISABLED", "DRAINING"). Optionally supply a :weight for use
91
91
  # in the WEIGHTED_ algorithms.
92
92
  # {:address => "1.2.3.4", :port => "80", :condition => "ENABLED", :weight => 1}
93
- # :port - the port that the load balancer listens on. Defaults to the standard port for the protocol.
93
+ # :port - the port that the load balancer listens on. *required*
94
94
  # :algorithm - A valid balancing algorithm. Use the algorithms method to get the list. Valid in the current documentation
95
95
  # are RANDOM (default), LEAST_CONNECTIONS, ROUND_ROBIN, WEIGHTED_LEAST_CONNECTIONS, WEIGHTED_ROUND_ROBIN
96
96
  # :virtual_ip_id - If you have existing virtual IPs and would like to reuse them in a different balancer (for example, to
@@ -104,10 +104,10 @@ module CloudLB
104
104
  (raise CloudLB::Exception::Syntax, "Load balancer name must be 128 characters or less") if options[:name].size > 128
105
105
  (raise CloudLB::Exception::Syntax, "Must provide at least one node in the :nodes array") if (!options[:nodes].is_a?(Array) || options[:nodes].size < 1)
106
106
  body[:protocol] = options[:protocol] or raise CloudLB::Exception::MissingArgument, "Must provide a protocol to create a load balancer"
107
+ body[:protocol].upcase! if body[:protocol]
107
108
  body[:port] = options[:port] if options[:port]
108
109
  body[:nodes] = options[:nodes]
109
- body[:protocol].upcase! if body[:protocol]
110
- body[:algorithm].upcase! if body[:algorithm]
110
+ body[:algorithm] = options[:algorithm].upcase if options[:algorithm]
111
111
  if options[:virtual_ip_id]
112
112
  body['virtualIps'] = [{:id => options[:virtual_ip_id]}]
113
113
  elsif options[:virtual_ip_type]
@@ -159,7 +159,7 @@ module CloudLB
159
159
  :body => data,
160
160
  :method => method.downcase.to_sym,
161
161
  :headers => hdrhash,
162
- # :user_agent => "CloudLB Ruby API #{VERSION}",
162
+ :user_agent => "Cloud Load Balancers Ruby API #{VERSION}",
163
163
  :verbose => ENV['LOADBALANCERS_VERBOSE'] ? true : false)
164
164
  CloudLB.hydra.queue(request)
165
165
  CloudLB.hydra.run
@@ -14,6 +14,8 @@ module CloudLB
14
14
 
15
15
  end
16
16
 
17
+ class ServiceFault < CloudLBError # :nodoc:
18
+ end
17
19
  class LoadBalancerFault < CloudLBError # :nodoc:
18
20
  end
19
21
  class ServiceUnavailable < CloudLBError # :nodoc:
@@ -22,8 +24,16 @@ module CloudLB
22
24
  end
23
25
  class BadRequest < CloudLBError # :nodoc:
24
26
  end
27
+ class ItemNotFound < CloudLBError # :nodoc:
28
+ end
25
29
  class OverLimit < CloudLBError # :nodoc:
26
30
  end
31
+ class OutOfVirtualIps < CloudLBError # :nodoc:
32
+ end
33
+ class ImmutableEntity < CloudLBError # :nodoc:
34
+ end
35
+ class UnprocessableEntity < CloudLBError # :nodoc:
36
+ end
27
37
  class Other < CloudLBError # :nodoc:
28
38
  end
29
39
 
@@ -0,0 +1,3 @@
1
+ module CloudLB
2
+ VERSION = '0.1.0'
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudlb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - H. Wade Minter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-25 00:00:00 -05:00
18
+ date: 2011-11-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,7 +56,6 @@ extensions: []
56
56
  extra_rdoc_files: []
57
57
 
58
58
  files:
59
- - VERSION
60
59
  - COPYING
61
60
  - .gitignore
62
61
  - README.rdoc
@@ -69,6 +68,7 @@ files:
69
68
  - lib/cloudlb/node.rb
70
69
  - lib/cloudlb/health_monitor.rb
71
70
  - lib/cloudlb/connection_throttle.rb
71
+ - lib/cloudlb/version.rb
72
72
  has_rdoc: true
73
73
  homepage: http://github.com/rackspace/ruby-cloudlb
74
74
  licenses: []
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements: []
102
102
 
103
103
  rubyforge_project:
104
- rubygems_version: 1.5.0
104
+ rubygems_version: 1.6.0
105
105
  signing_key:
106
106
  specification_version: 3
107
107
  summary: Ruby API into the Rackspace Cloud Load Balancers product
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.1