Class: Bosh::Director::ProblemHandlers::UnresponsiveAgent

Inherits:
Base
  • Object
show all
Defined in:
lib/bosh/director/problem_handlers/unresponsive_agent.rb

Constant Summary

Constants included from CloudcheckHelper

CloudcheckHelper::DEFAULT_AGENT_TIMEOUT

Instance Attribute Summary

Attributes inherited from Base

#data, #job

Instance Method Summary collapse

Methods inherited from Base

action, action_for, #apply_resolution, auto_resolution, #auto_resolution, #auto_resolve, #checkpoint, #cloud, create_by_type, create_from_model, get_auto_resolution, inherited, init_dsl_data, plan, plan_for, register_as, resolution, #resolution_plan, #resolutions

Methods included from CloudcheckHelper

#agent_client, #agent_timeout_guard, #cloud, #delete_vm_reference, #handler_error, #instance_name, #reboot_vm, #recreate_vm

Constructor Details

#initialize(vm_id, data) ⇒ UnresponsiveAgent

Returns a new instance of UnresponsiveAgent.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 8

def initialize(vm_id, data)
  super
  @vm = Models::Vm[vm_id]

  if @vm.nil?
    handler_error("VM `#{vm_id}' is no longer in the database")
  end

  if @vm.agent_id.nil?
    handler_error("VM `#{vm_id}' doesn't have an agent id")
  end
end

Instance Method Details

#agent_alive?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 45

def agent_alive?
  agent_client(@vm).ping
  true
rescue Bosh::Director::RpcTimeout
  false
end

#delete_vmObject



72
73
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 72

def delete_vm
end

#descriptionObject



21
22
23
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 21

def description
  "#{instance_name(@vm)} (#{@vm.cid}) is not responding"
end

#ensure_cidObject



52
53
54
55
56
57
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 52

def ensure_cid
  if @vm.cid.nil?
    handler_error("VM `#{@vm.id}' doesn't have a cloud id, " +
        'only resolution is to delete the VM reference.')
  end
end

#ensure_no_cidObject



59
60
61
62
63
64
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 59

def ensure_no_cid
  if @vm.cid
    handler_error("VM `#{@vm.id}' has a cloud id, " +
        'please use a different resolution.')
  end
end

#validateObject



66
67
68
69
70
# File 'lib/bosh/director/problem_handlers/unresponsive_agent.rb', line 66

def validate
  if agent_alive?
    handler_error('Agent is responding now, skipping resolution')
  end
end