Class: Fog::Rackspace::LoadBalancers::LoadBalancer
- Inherits:
-
Model
- Object
- Model
- Fog::Rackspace::LoadBalancers::LoadBalancer
- Defined in:
- lib/fog/rackspace/models/load_balancers/load_balancer.rb
Constant Summary collapse
- ACTIVE =
States
'ACTIVE'
- ERROR =
'ERROR'
- PENDING_UPDATE =
'PENDING_UPDATE'
- PENDING_DELTE =
'PENDING_DELETE'
- SUSPENDED =
'SUSPENDED'
- DELETED =
'DELETED'
- BUILD =
'BUILD'
Instance Method Summary collapse
- #access_rules ⇒ Object
- #access_rules=(new_access_rules = []) ⇒ Object
- #connection_throttling ⇒ Object
- #content_caching ⇒ Object
- #destroy ⇒ Object
- #disable_connection_logging ⇒ Object
- #disable_connection_throttling ⇒ Object
- #disable_content_caching ⇒ Object
- #disable_health_monitor ⇒ Object
- #disable_session_persistence ⇒ Object
- #disable_ssl_termination ⇒ Object
- #enable_connection_logging ⇒ Object
- #enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval) ⇒ Object
- #enable_content_caching ⇒ Object
- #enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) ⇒ Object
- #enable_session_persistence(type) ⇒ Object
- #enable_ssl_termination(securePort, privatekey, certificate, options = {}) ⇒ Object
- #error_page ⇒ Object
- #error_page=(content) ⇒ Object
- #health_monitor ⇒ Object
-
#initialize(attributes) ⇒ LoadBalancer
constructor
A new instance of LoadBalancer.
- #nodes ⇒ Object
- #nodes=(new_nodes = []) ⇒ Object
- #ready? ⇒ Boolean
- #reset_error_page ⇒ Object
- #save ⇒ Object
- #session_persistence ⇒ Object
- #ssl_termination ⇒ Object
- #stats ⇒ Object
- #usage(options = {}) ⇒ Object
- #virtual_ips ⇒ Object
- #virtual_ips=(new_virtual_ips = []) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ LoadBalancer
Returns a new instance of LoadBalancer.
32 33 34 35 36 37 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 32 def initialize(attributes) #HACK - Since we are hacking how sub-collections work, we have to make sure the service is valid first. # Old 'connection' is renamed as service and should be used instead @service = attributes[:service] || attributes[:connection] super end |
Instance Method Details
#access_rules ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 39 def access_rules @access_rules ||= begin Fog::Rackspace::LoadBalancers::AccessRules.new({ :service => service, :load_balancer => self}) end end |
#access_rules=(new_access_rules = []) ⇒ Object
47 48 49 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 47 def access_rules=(new_access_rules=[]) access_rules.load(new_access_rules) end |
#connection_throttling ⇒ Object
139 140 141 142 143 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 139 def connection_throttling requires :identity throttle = service.get_connection_throttling(identity).body['connectionThrottle'] throttle.count == 0 ? nil : throttle end |
#content_caching ⇒ Object
104 105 106 107 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 104 def content_caching requires :identity service.get_content_caching(identity).body['contentCaching']['enabled'] end |
#destroy ⇒ Object
175 176 177 178 179 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 175 def destroy requires :identity service.delete_load_balancer(identity) true end |
#disable_connection_logging ⇒ Object
115 116 117 118 119 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 115 def disable_connection_logging requires :identity service.set_connection_logging identity, false attributes[:connection_logging] = false end |
#disable_connection_throttling ⇒ Object
151 152 153 154 155 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 151 def disable_connection_throttling requires :identity service.remove_connection_throttling(identity) true end |
#disable_content_caching ⇒ Object
98 99 100 101 102 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 98 def disable_content_caching requires :identity service.set_content_caching identity, false true end |
#disable_health_monitor ⇒ Object
133 134 135 136 137 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 133 def disable_health_monitor requires :identity service.remove_monitor(identity) true end |
#disable_session_persistence ⇒ Object
169 170 171 172 173 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 169 def disable_session_persistence requires :identity service.remove_session_persistence(identity) true end |
#disable_ssl_termination ⇒ Object
75 76 77 78 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 75 def disable_ssl_termination requires :identity service.remove_ssl_termination(identity) end |
#enable_connection_logging ⇒ Object
109 110 111 112 113 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 109 def enable_connection_logging requires :identity service.set_connection_logging identity, true attributes[:connection_logging] = true end |
#enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval) ⇒ Object
145 146 147 148 149 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 145 def enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval) requires :identity service.set_connection_throttling(identity, max_connections, min_connections, max_connection_rate, rate_interval) true end |
#enable_content_caching ⇒ Object
92 93 94 95 96 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 92 def enable_content_caching requires :identity service.set_content_caching identity, true true end |
#enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) ⇒ Object
127 128 129 130 131 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 127 def enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, = {}) requires :identity service.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, ) true end |
#enable_session_persistence(type) ⇒ Object
163 164 165 166 167 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 163 def enable_session_persistence(type) requires :identity service.set_session_persistence(identity, type) true end |
#enable_ssl_termination(securePort, privatekey, certificate, options = {}) ⇒ Object
70 71 72 73 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 70 def enable_ssl_termination(securePort, privatekey, certificate, = {}) requires :identity service.set_ssl_termination(identity, securePort, privatekey, certificate, ) end |
#error_page ⇒ Object
204 205 206 207 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 204 def error_page requires :identity service.get_error_page(identity).body['errorpage']['content'] end |
#error_page=(content) ⇒ Object
209 210 211 212 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 209 def error_page=(content) requires :identity service.set_error_page identity, content end |
#health_monitor ⇒ Object
121 122 123 124 125 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 121 def health_monitor requires :identity monitor = service.get_monitor(identity).body['healthMonitor'] monitor.count == 0 ? nil : monitor end |
#nodes ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 51 def nodes @nodes ||= begin Fog::Rackspace::LoadBalancers::Nodes.new({ :service => service, :load_balancer => self}) end end |
#nodes=(new_nodes = []) ⇒ Object
59 60 61 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 59 def nodes=(new_nodes=[]) nodes.load(new_nodes) end |
#ready? ⇒ Boolean
181 182 183 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 181 def ready? state == ACTIVE end |
#reset_error_page ⇒ Object
214 215 216 217 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 214 def reset_error_page requires :identity service.remove_error_page identity end |
#save ⇒ Object
185 186 187 188 189 190 191 192 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 185 def save if persisted? update else create end true end |
#session_persistence ⇒ Object
157 158 159 160 161 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 157 def session_persistence requires :identity persistence = service.get_session_persistence(identity).body['sessionPersistence'] persistence.count == 0 ? nil : persistence end |
#ssl_termination ⇒ Object
63 64 65 66 67 68 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 63 def ssl_termination requires :identity ssl_termination = service.get_ssl_termination(identity).body['sslTermination'] rescue Fog::Rackspace::LoadBalancers::NotFound nil end |
#stats ⇒ Object
199 200 201 202 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 199 def stats requires :identity service.get_stats(identity).body end |
#usage(options = {}) ⇒ Object
194 195 196 197 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 194 def usage( = {}) requires :identity service.get_load_balancer_usage(identity, ).body end |
#virtual_ips ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 80 def virtual_ips @virtual_ips ||= begin Fog::Rackspace::LoadBalancers::VirtualIps.new({ :service => service, :load_balancer => self}) end end |
#virtual_ips=(new_virtual_ips = []) ⇒ Object
88 89 90 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 88 def virtual_ips=(new_virtual_ips=[]) virtual_ips.load(new_virtual_ips) end |