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)

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

- (Object) access_rules



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

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



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

- (Object) connection_throttling



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

- (Object) content_caching



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

- (Object) destroy



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

- (Object) disable_connection_logging



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

- (Object) disable_connection_throttling



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

- (Object) disable_content_caching



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

- (Object) disable_health_monitor



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

- (Object) disable_session_persistence



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

- (Object) disable_ssl_termination



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

- (Object) enable_connection_logging



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

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



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

- (Object) enable_content_caching



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

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



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

- (Object) enable_session_persistence(type)



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

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



70
71
72
73
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 70

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

- (Object) error_page



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

- (Object) error_page=(content)



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

- (Object) health_monitor



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

- (Object) nodes



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

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



59
60
61
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 59

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

- (Boolean) ready?

Returns:

  • (Boolean)


181
182
183
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 181

def ready?
  state == ACTIVE
end

- (Object) reset_error_page



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

- (Object) save



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

- (Object) session_persistence



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

- (Object) ssl_termination



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

- (Object) stats



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

- (Object) usage(options = {})



194
195
196
197
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 194

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

- (Object) virtual_ips



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

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



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