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.
31 32 33 34 35 36 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 31 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
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 38 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
50 51 52 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 50 def access_rules=(new_access_rules=[]) access_rules.load(new_access_rules) end |
#connection_throttling ⇒ Object
146 147 148 149 150 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 146 def connection_throttling requires :identity throttle = service.get_connection_throttling(identity).body['connectionThrottle'] throttle.count == 0 ? nil : throttle end |
#content_caching ⇒ Object
111 112 113 114 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 111 def content_caching requires :identity service.get_content_caching(identity).body['contentCaching']['enabled'] end |
#destroy ⇒ Object
182 183 184 185 186 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 182 def destroy requires :identity service.delete_load_balancer(identity) true end |
#disable_connection_logging ⇒ Object
122 123 124 125 126 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 122 def disable_connection_logging requires :identity service.set_connection_logging identity, false attributes[:connection_logging] = false end |
#disable_connection_throttling ⇒ Object
158 159 160 161 162 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 158 def disable_connection_throttling requires :identity service.remove_connection_throttling(identity) true end |
#disable_content_caching ⇒ Object
105 106 107 108 109 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 105 def disable_content_caching requires :identity service.set_content_caching identity, false true end |
#disable_health_monitor ⇒ Object
140 141 142 143 144 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 140 def disable_health_monitor requires :identity service.remove_monitor(identity) true end |
#disable_session_persistence ⇒ Object
176 177 178 179 180 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 176 def disable_session_persistence requires :identity service.remove_session_persistence(identity) true end |
#disable_ssl_termination ⇒ Object
82 83 84 85 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 82 def disable_ssl_termination requires :identity service.remove_ssl_termination(identity) end |
#enable_connection_logging ⇒ Object
116 117 118 119 120 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 116 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
152 153 154 155 156 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 152 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
99 100 101 102 103 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 99 def enable_content_caching requires :identity service.set_content_caching identity, true true end |
#enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {}) ⇒ Object
134 135 136 137 138 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 134 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
170 171 172 173 174 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 170 def enable_session_persistence(type) requires :identity service.set_session_persistence(identity, type) true end |
#enable_ssl_termination(securePort, privatekey, certificate, options = {}) ⇒ Object
77 78 79 80 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 77 def enable_ssl_termination(securePort, privatekey, certificate, = {}) requires :identity service.set_ssl_termination(identity, securePort, privatekey, certificate, ) end |
#error_page ⇒ Object
211 212 213 214 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 211 def error_page requires :identity service.get_error_page(identity).body['errorpage']['content'] end |
#error_page=(content) ⇒ Object
216 217 218 219 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 216 def error_page=(content) requires :identity service.set_error_page identity, content end |
#health_monitor ⇒ Object
128 129 130 131 132 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 128 def health_monitor requires :identity monitor = service.get_monitor(identity).body['healthMonitor'] monitor.count == 0 ? nil : monitor end |
#nodes ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 54 def nodes unless @nodes @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
66 67 68 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 66 def nodes=(new_nodes=[]) nodes.load(new_nodes) end |
#ready? ⇒ Boolean
188 189 190 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 188 def ready? state == ACTIVE end |
#reset_error_page ⇒ Object
221 222 223 224 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 221 def reset_error_page requires :identity service.remove_error_page identity end |
#save ⇒ Object
192 193 194 195 196 197 198 199 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 192 def save if persisted? update else create end true end |
#session_persistence ⇒ Object
164 165 166 167 168 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 164 def session_persistence requires :identity persistence = service.get_session_persistence(identity).body['sessionPersistence'] persistence.count == 0 ? nil : persistence end |
#ssl_termination ⇒ Object
70 71 72 73 74 75 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 70 def ssl_termination requires :identity ssl_termination = service.get_ssl_termination(identity).body['sslTermination'] rescue Fog::Rackspace::LoadBalancers::NotFound nil end |
#stats ⇒ Object
206 207 208 209 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 206 def stats requires :identity service.get_stats(identity).body end |
#usage(options = {}) ⇒ Object
201 202 203 204 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 201 def usage( = {}) requires :identity service.get_load_balancer_usage(identity, ).body end |
#virtual_ips ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 87 def virtual_ips @virtual_ips ||= begin Fog::Rackspace::LoadBalancers::VirtualIps.new({ :service => service, :load_balancer => self}) end end |
#virtual_ips=(new_virtual_ips = []) ⇒ Object
95 96 97 |
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 95 def virtual_ips=(new_virtual_ips=[]) virtual_ips.load(new_virtual_ips) end |