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



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

- (Object) access_rules



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

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



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

- (Object) connection_throttling



148
149
150
151
152
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 148

def connection_throttling
  requires :identity
  throttle = service.get_connection_throttling(identity).body['connectionThrottle']
  throttle.count == 0 ? nil : throttle
end

- (Object) content_caching



113
114
115
116
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 113

def content_caching
  requires :identity
  service.get_content_caching(identity).body['contentCaching']['enabled']
end

- (Object) destroy



184
185
186
187
188
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 184

def destroy
  requires :identity
  service.delete_load_balancer(identity)
  true
end

- (Object) disable_connection_logging



124
125
126
127
128
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 124

def disable_connection_logging
  requires :identity
  service.set_connection_logging identity, false
  attributes[:connection_logging] = false
end

- (Object) disable_connection_throttling



160
161
162
163
164
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 160

def disable_connection_throttling
  requires :identity
  service.remove_connection_throttling(identity)
  true
end

- (Object) disable_content_caching



107
108
109
110
111
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 107

def disable_content_caching
  requires :identity
  service.set_content_caching identity, false
  true
end

- (Object) disable_health_monitor



142
143
144
145
146
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 142

def disable_health_monitor
  requires :identity
  service.remove_monitor(identity)
  true
end

- (Object) disable_session_persistence



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

def disable_session_persistence
  requires :identity
  service.remove_session_persistence(identity)
  true
end

- (Object) disable_ssl_termination



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

- (Object) enable_connection_logging



118
119
120
121
122
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 118

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)



154
155
156
157
158
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 154

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



101
102
103
104
105
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 101

def enable_content_caching
  requires :identity
  service.set_content_caching identity, true
  true
end

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



136
137
138
139
140
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 136

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)



172
173
174
175
176
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 172

def enable_session_persistence(type)
  requires :identity
  service.set_session_persistence(identity, type)
  true
end

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



77
78
79
80
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 77

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

- (Object) error_page



213
214
215
216
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 213

def error_page
  requires :identity
  service.get_error_page(identity).body['errorpage']['content']
end

- (Object) error_page=(content)



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

def error_page=(content)
  requires :identity
  service.set_error_page identity, content
end

- (Object) health_monitor



130
131
132
133
134
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 130

def health_monitor
  requires :identity
  monitor = service.get_monitor(identity).body['healthMonitor']
  monitor.count == 0 ? nil : monitor
end

- (Object) nodes



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
  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 = [])



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

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

- (Boolean) ready?

Returns:

  • (Boolean)


190
191
192
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 190

def ready?
  state == ACTIVE
end

- (Object) reset_error_page



223
224
225
226
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 223

def reset_error_page
  requires :identity
  service.remove_error_page identity
end

- (Object) save



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

def save
  if persisted?
    update
  else
    create
  end
  true
end

- (Object) session_persistence



166
167
168
169
170
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 166

def session_persistence
  requires :identity
  persistence = service.get_session_persistence(identity).body['sessionPersistence']
  persistence.count == 0 ? nil : persistence
end

- (Object) ssl_termination



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

- (Object) stats



208
209
210
211
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 208

def stats
  requires :identity
  service.get_stats(identity).body
end

- (Object) usage(options = {})



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

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

- (Object) virtual_ips



87
88
89
90
91
92
93
94
95
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 87

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 = [])



97
98
99
# File 'lib/fog/rackspace/models/load_balancers/load_balancer.rb', line 97

def virtual_ips=(new_virtual_ips=[])
  virtual_ips.load(new_virtual_ips)
end