Module: CloudLB

Defined in:
lib/cloudlb.rb,
lib/cloudlb/node.rb,
lib/cloudlb/version.rb,
lib/cloudlb/balancer.rb,
lib/cloudlb/exception.rb,
lib/cloudlb/connection.rb,
lib/cloudlb/authentication.rb,
lib/cloudlb/health_monitor.rb,
lib/cloudlb/connection_throttle.rb

Overview

Cloud Load Balancers API

Connects Ruby Applications to Rackspace’s Cloud Load Balancers service

By H. Wade Minter <[email protected]>

See COPYING for license information. Copyright © 2011, Rackspace US, Inc.


Documentation & Examples

To begin reviewing the available methods and examples, peruse the README.rodc file, or begin by looking at documentation for the CloudLB::Connection class.

The CloudLB class is the base class. Not much of note aside from housekeeping happens here. To create a new CloudLB connection, use the CloudLB::Connection.new method.

Defined Under Namespace

Classes: Authentication, Balancer, Connection, ConnectionThrottle, Exception, HealthMonitor, Node

Constant Summary collapse

AUTH_USA =
"https://auth.api.rackspacecloud.com/v1.0"
AUTH_UK =
"https://lon.auth.api.rackspacecloud.com/v1.0"
VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.escape(str, extra_exclude_chars = '') ⇒ Object

CGI.escape, but without special treatment on spaces



84
85
86
87
88
# File 'lib/cloudlb.rb', line 84

def self.escape(str,extra_exclude_chars = '')
  str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end
end

.hydraObject



79
80
81
# File 'lib/cloudlb.rb', line 79

def self.hydra
  @@hydra ||= Typhoeus::Hydra.new
end

.paginate(options = {}) ⇒ Object



90
91
92
93
94
95
# File 'lib/cloudlb.rb', line 90

def self.paginate(options = {})
  path_args = []
  path_args.push(URI.encode("limit=#{options[:limit]}")) if options[:limit]
  path_args.push(URI.encode("offset=#{options[:offset]}")) if options[:offset]
  path_args.join("&")
end

.symbolize_keys(obj) ⇒ Object

Helper method to recursively symbolize hash keys.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cloudlb.rb', line 45

def self.symbolize_keys(obj)
  case obj
  when Array
    obj.inject([]){|res, val|
      res << case val
      when Hash, Array
        symbolize_keys(val)
      else
        val
      end
      res
    }
  when Hash
    obj.inject({}){|res, (key, val)|
      nkey = case key
      when String
        key.to_sym
      else
        key
      end
      nval = case val
      when Hash, Array
        symbolize_keys(val)
      else
        val
      end
      res[nkey] = nval
      res
    }
  else
    obj
  end
end