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
- #https_redirect ⇒ 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 46 47 48 49 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 39 def access_rules unless @access_rules @access_rules = Fog::Rackspace::LoadBalancers::AccessRules.new({ :service => service, :load_balancer => self}) # prevents loading access rules from non-existent load balancers @access_rules.clear unless persisted? end @access_rules end |
#access_rules=(new_access_rules = []) ⇒ Object
51 52 53 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 51 def access_rules=(new_access_rules=[]) access_rules.load(new_access_rules) end |
#connection_throttling ⇒ Object
161 162 163 164 165 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 161 def connection_throttling requires :identity throttle = service.get_connection_throttling(identity).body['connectionThrottle'] throttle.count == 0 ? nil : throttle end |
#content_caching ⇒ Object
126 127 128 129 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 126 def content_caching requires :identity service.get_content_caching(identity).body['contentCaching']['enabled'] end |
#destroy ⇒ Object
197 198 199 200 201 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 197 def destroy requires :identity service.delete_load_balancer(identity) true end |
#disable_connection_logging ⇒ Object
137 138 139 140 141 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 137 def disable_connection_logging requires :identity service.set_connection_logging identity, false attributes[:connection_logging] = false end |
#disable_connection_throttling ⇒ Object
173 174 175 176 177 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 173 def disable_connection_throttling requires :identity service.remove_connection_throttling(identity) true end |
#disable_content_caching ⇒ Object
120 121 122 123 124 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 120 def disable_content_caching requires :identity service.set_content_caching identity, false true end |
#disable_health_monitor ⇒ Object
155 156 157 158 159 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 155 def disable_health_monitor requires :identity service.remove_monitor(identity) true end |
#disable_session_persistence ⇒ Object
191 192 193 194 195 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 191 def disable_session_persistence requires :identity service.remove_session_persistence(identity) true end |
#disable_ssl_termination ⇒ Object
95 96 97 98 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 95 def disable_ssl_termination requires :identity service.remove_ssl_termination(identity) end |
#enable_connection_logging ⇒ Object
131 132 133 134 135 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 131 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
167 168 169 170 171 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 167 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
114 115 116 117 118 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 114 def enable_content_caching requires :identity service.set_content_caching identity, true true end |
#enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) ⇒ Object
149 150 151 152 153 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 149 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
185 186 187 188 189 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 185 def enable_session_persistence(type) requires :identity service.set_session_persistence(identity, type) true end |
#enable_ssl_termination(securePort, privatekey, certificate, options = {}) ⇒ Object
90 91 92 93 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 90 def enable_ssl_termination(securePort, privatekey, certificate, = {}) requires :identity service.set_ssl_termination(identity, securePort, privatekey, certificate, ) end |
#error_page ⇒ Object
226 227 228 229 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 226 def error_page requires :identity service.get_error_page(identity).body['errorpage']['content'] end |
#error_page=(content) ⇒ Object
231 232 233 234 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 231 def error_page=(content) requires :identity service.set_error_page identity, content end |
#health_monitor ⇒ Object
143 144 145 146 147 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 143 def health_monitor requires :identity monitor = service.get_monitor(identity).body['healthMonitor'] monitor.count == 0 ? nil : monitor end |
#https_redirect ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 71 def https_redirect if @https_redirect.nil? requires :identity @https_redirect = begin service.get_load_balancer(identity).body['loadBalancer']['httpsRedirect'] rescue => e nil end end @https_redirect end |
#nodes ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 55 def nodes if @nodes.nil? @nodes = Fog::Rackspace::LoadBalancers::Nodes.new({ :service => service, :load_balancer => self}) # prevents loading nodes from non-existent load balancers @nodes.clear unless persisted? end @nodes end |
#nodes=(new_nodes = []) ⇒ Object
67 68 69 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 67 def nodes=(new_nodes=[]) nodes.load(new_nodes) end |
#ready? ⇒ Boolean
203 204 205 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 203 def ready? state == ACTIVE end |
#reset_error_page ⇒ Object
236 237 238 239 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 236 def reset_error_page requires :identity service.remove_error_page identity end |
#save ⇒ Object
207 208 209 210 211 212 213 214 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 207 def save if persisted? update else create end true end |
#session_persistence ⇒ Object
179 180 181 182 183 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 179 def session_persistence requires :identity persistence = service.get_session_persistence(identity).body['sessionPersistence'] persistence.count == 0 ? nil : persistence end |
#ssl_termination ⇒ Object
83 84 85 86 87 88 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 83 def ssl_termination requires :identity ssl_termination = service.get_ssl_termination(identity).body['sslTermination'] rescue Fog::Rackspace::LoadBalancers::NotFound nil end |
#stats ⇒ Object
221 222 223 224 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 221 def stats requires :identity service.get_stats(identity).body end |
#usage(options = {}) ⇒ Object
216 217 218 219 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 216 def usage( = {}) requires :identity service.get_load_balancer_usage(identity, ).body end |
#virtual_ips ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 100 def virtual_ips if @virtual_ips.nil? @virtual_ips = Fog::Rackspace::LoadBalancers::VirtualIps.new({ :service => service, :load_balancer => self}) @virtual_ips.clear unless persisted? end @virtual_ips end |
#virtual_ips=(new_virtual_ips = []) ⇒ Object
110 111 112 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 110 def virtual_ips=(new_virtual_ips=[]) virtual_ips.load(new_virtual_ips) end |