Class: Saklient::Cloud::Resources::LbServer

Inherits:
Object
  • Object
show all
Defined in:
lib/saklient/cloud/resources/lb_server.rb

Overview

ロードバランサの監視対象サーバ設定.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj = nil) ⇒ LbServer

Returns a new instance of LbServer.

Parameters:

  • obj (any) (defaults to: nil)


278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/saklient/cloud/resources/lb_server.rb', line 278

def initialize(obj = nil)
  obj = {} if (obj).nil?
  health = Saklient::Util::get_by_path_any([obj], [
    'HealthCheck',
    'healthCheck',
    'health_check',
    'health'
  ])
  enabled = Saklient::Util::get_by_path_any([obj], ['Enabled', 'enabled'])
  @_enabled = nil
  if !(enabled).nil?
    enabledStr = enabled
    @_enabled = enabledStr.downcase() == 'true'
  end
  @_ip_address = Saklient::Util::get_by_path_any([obj], [
    'IPAddress',
    'ipAddress',
    'ip_address',
    'ip'
  ])
  @_protocol = Saklient::Util::get_by_path_any([health, obj], ['Protocol', 'protocol'])
  @_path_to_check = Saklient::Util::get_by_path_any([health, obj], [
    'Path',
    'path',
    'pathToCheck',
    'path_to_check'
  ])
  port = Saklient::Util::get_by_path_any([obj], ['Port', 'port'])
  @_port = nil
  @_port = (port).to_s().to_i(10) if !(port).nil?
  @_port = nil if @_port == 0
  responseExpected = Saklient::Util::get_by_path_any([health, obj], [
    'Status',
    'status',
    'responseExpected',
    'response_expected'
  ])
  @_response_expected = nil
  @_response_expected = (responseExpected).to_s().to_i(10) if !(responseExpected).nil?
  @_response_expected = nil if @_response_expected == 0
  @_active_connections = 0
  @_status = nil
end

Instance Attribute Details

#active_connectionsFixnum (readonly)

現在の接続数

Returns:

  • (Fixnum)


247
248
249
# File 'lib/saklient/cloud/resources/lb_server.rb', line 247

def active_connections
  @active_connections
end

#enabledbool

有効状態

Returns:

  • (bool)


40
41
42
# File 'lib/saklient/cloud/resources/lb_server.rb', line 40

def enabled
  @enabled
end

#ip_addressString

IPアドレス

Returns:

  • (String)


76
77
78
# File 'lib/saklient/cloud/resources/lb_server.rb', line 76

def ip_address
  @ip_address
end

#path_to_checkString

監視対象パス

Returns:

  • (String)


184
185
186
# File 'lib/saklient/cloud/resources/lb_server.rb', line 184

def path_to_check
  @path_to_check
end

#portFixnum

ポート番号

Returns:

  • (Fixnum)


112
113
114
# File 'lib/saklient/cloud/resources/lb_server.rb', line 112

def port
  @port
end

#protocolString

監視方法

Returns:

  • (String)


148
149
150
# File 'lib/saklient/cloud/resources/lb_server.rb', line 148

def protocol
  @protocol
end

#response_expectedFixnum

監視時に期待されるレスポンスコード

Returns:

  • (Fixnum)


220
221
222
# File 'lib/saklient/cloud/resources/lb_server.rb', line 220

def response_expected
  @response_expected
end

#statusString (readonly)

現在の状態

Returns:

  • (String)


270
271
272
# File 'lib/saklient/cloud/resources/lb_server.rb', line 270

def status
  @status
end

Instance Method Details

#get_active_connectionsFixnum

Returns:

  • (Fixnum)


240
241
242
# File 'lib/saklient/cloud/resources/lb_server.rb', line 240

def get_active_connections
  return @_active_connections
end

#get_enabledbool

Returns:

  • (bool)


24
25
26
# File 'lib/saklient/cloud/resources/lb_server.rb', line 24

def get_enabled
  return @_enabled
end

#get_ip_addressString

Returns:

  • (String)


60
61
62
# File 'lib/saklient/cloud/resources/lb_server.rb', line 60

def get_ip_address
  return @_ip_address
end

#get_path_to_checkString

Returns:

  • (String)


168
169
170
# File 'lib/saklient/cloud/resources/lb_server.rb', line 168

def get_path_to_check
  return @_path_to_check
end

#get_portFixnum

Returns:

  • (Fixnum)


96
97
98
# File 'lib/saklient/cloud/resources/lb_server.rb', line 96

def get_port
  return @_port
end

#get_protocolString

Returns:

  • (String)


132
133
134
# File 'lib/saklient/cloud/resources/lb_server.rb', line 132

def get_protocol
  return @_protocol
end

#get_response_expectedFixnum

Returns:

  • (Fixnum)


204
205
206
# File 'lib/saklient/cloud/resources/lb_server.rb', line 204

def get_response_expected
  return @_response_expected
end

#get_statusString

Returns:

  • (String)


263
264
265
# File 'lib/saklient/cloud/resources/lb_server.rb', line 263

def get_status
  return @_status
end

#set_enabled(v) ⇒ bool

Parameters:

  • v (bool)

Returns:

  • (bool)


31
32
33
34
35
# File 'lib/saklient/cloud/resources/lb_server.rb', line 31

def set_enabled(v)
  Saklient::Util::validate_type(v, 'bool')
  @_enabled = v
  return @_enabled
end

#set_ip_address(v) ⇒ String

Parameters:

  • v (String)

Returns:

  • (String)


67
68
69
70
71
# File 'lib/saklient/cloud/resources/lb_server.rb', line 67

def set_ip_address(v)
  Saklient::Util::validate_type(v, 'String')
  @_ip_address = v
  return @_ip_address
end

#set_path_to_check(v) ⇒ String

Parameters:

  • v (String)

Returns:

  • (String)


175
176
177
178
179
# File 'lib/saklient/cloud/resources/lb_server.rb', line 175

def set_path_to_check(v)
  Saklient::Util::validate_type(v, 'String')
  @_path_to_check = v
  return @_path_to_check
end

#set_port(v) ⇒ Fixnum

Parameters:

  • v (Fixnum)

Returns:

  • (Fixnum)


103
104
105
106
107
# File 'lib/saklient/cloud/resources/lb_server.rb', line 103

def set_port(v)
  Saklient::Util::validate_type(v, 'Fixnum')
  @_port = v
  return @_port
end

#set_protocol(v) ⇒ String

Parameters:

  • v (String)

Returns:

  • (String)


139
140
141
142
143
# File 'lib/saklient/cloud/resources/lb_server.rb', line 139

def set_protocol(v)
  Saklient::Util::validate_type(v, 'String')
  @_protocol = v
  return @_protocol
end

#set_response_expected(v) ⇒ Fixnum

Parameters:

  • v (Fixnum)

Returns:

  • (Fixnum)


211
212
213
214
215
# File 'lib/saklient/cloud/resources/lb_server.rb', line 211

def set_response_expected(v)
  Saklient::Util::validate_type(v, 'Fixnum')
  @_response_expected = v
  return @_response_expected
end

#to_raw_settingsany

Returns:

  • (any)


323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/saklient/cloud/resources/lb_server.rb', line 323

def to_raw_settings
  return {
    Enabled: (@_enabled).nil? ? nil : (@_enabled ? 'True' : 'False'),
    IPAddress: @_ip_address,
    Port: @_port,
    HealthCheck: {
      Protocol: @_protocol,
      Path: @_path_to_check,
      Status: @_response_expected
    }
  }
end

#update_status(obj) ⇒ LbServer

Parameters:

  • obj (any)

Returns:



339
340
341
342
343
344
345
346
# File 'lib/saklient/cloud/resources/lb_server.rb', line 339

def update_status(obj)
  connStr = obj[:ActiveConn]
  @_active_connections = 0
  @_active_connections = (connStr).to_s().to_i(10) if !(connStr).nil?
  status = obj[:Status]
  @_status = (status).nil? ? nil : status.downcase()
  return self
end