Class: Proxy::DHCP::Infoblox::GridRestart

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/smart_proxy_dhcp_infoblox/grid_restart.rb

Constant Summary collapse

MAX_ATTEMPTS =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ GridRestart

Returns a new instance of GridRestart.



8
9
10
# File 'lib/smart_proxy_dhcp_infoblox/grid_restart.rb', line 8

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/smart_proxy_dhcp_infoblox/grid_restart.rb', line 6

def connection
  @connection
end

Instance Method Details

#restartObject



24
25
26
27
28
29
# File 'lib/smart_proxy_dhcp_infoblox/grid_restart.rb', line 24

def restart
  (@grid ||= ::Infoblox::Grid.get(@connection).first).restartservices
  true
rescue Exception => e
  false
end

#try_restartObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smart_proxy_dhcp_infoblox/grid_restart.rb', line 12

def try_restart
  logger.debug 'Restarting grid.'

  MAX_ATTEMPTS.times do |tries|
    sleep tries
    return if restart
  end

  logger.info 'Restarting Grid failed.'
  false
end