Class: Fog::Rackspace::LoadBalancers::LoadBalancer

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/load_balancers/load_balancer.rb

Constant Summary

ACTIVE =

States

'ACTIVE'
ERROR =
'ERROR'
PENDING_UPDATE =
'PENDING_UPDATE'
PENDING_DELTE =
'PENDING_DELETE'
SUSPENDED =
'SUSPENDED'
DELETED =
'DELETED'
BUILD =
'BUILD'

Instance Method Summary (collapse)

Constructor Details

- (LoadBalancer) initialize(attributes)



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

- (Object) access_rules



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

- (Object) access_rules=(new_access_rules = [])



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

- (Object) connection_throttling



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

- (Object) content_caching



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

- (Object) destroy



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

- (Object) disable_connection_logging



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

- (Object) disable_connection_throttling



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

- (Object) disable_content_caching



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

- (Object) disable_health_monitor



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

- (Object) disable_session_persistence



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

- (Object) disable_ssl_termination



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

- (Object) enable_connection_logging



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

- (Object) enable_connection_throttling(max_connections, min_connections, max_connection_rate, rate_interval)



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

- (Object) enable_content_caching



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

- (Object) enable_health_monitor(type, delay, timeout, attempsBeforeDeactivation, options = {})



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, options = {})
  requires :identity
  service.set_monitor(identity, type, delay, timeout, attempsBeforeDeactivation, options)
  true
end

- (Object) enable_session_persistence(type)



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

- (Object) enable_ssl_termination(securePort, privatekey, certificate, options = {})



90
91
92
93
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 90

def enable_ssl_termination(securePort, privatekey, certificate, options = {})
  requires :identity
  service.set_ssl_termination(identity, securePort, privatekey, certificate, options)
end

- (Object) error_page



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

- (Object) error_page=(content)



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

- (Object) health_monitor



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

- (Object) https_redirect



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

- (Object) nodes



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

- (Object) nodes=(new_nodes = [])



67
68
69
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 67

def nodes=(new_nodes=[])
  nodes.load(new_nodes)
end

- (Boolean) ready?



203
204
205
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 203

def ready?
  state == ACTIVE
end

- (Object) reset_error_page



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

- (Object) save



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

- (Object) session_persistence



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

- (Object) ssl_termination



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

- (Object) stats



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

- (Object) usage(options = {})



216
217
218
219
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 216

def usage(options = {})
  requires :identity
  service.get_load_balancer_usage(identity, options).body
end

- (Object) virtual_ips



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

- (Object) virtual_ips=(new_virtual_ips = [])



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