Class: Bosh::Director::ProblemHandlers::UnboundInstanceVm
- Defined in:
- lib/bosh/director/problem_handlers/unbound_instance_vm.rb
Constant Summary
Constants included from CloudcheckHelper
CloudcheckHelper::DEFAULT_AGENT_TIMEOUT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(vm_id, data) ⇒ UnboundInstanceVm
constructor
A new instance of UnboundInstanceVm.
- #reassociate_vm ⇒ Object
- #validate ⇒ Object
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, #delete_vm_reference, #handler_error, #instance_name, #reboot_vm, #recreate_vm
Constructor Details
#initialize(vm_id, data) ⇒ UnboundInstanceVm
Returns a new instance of UnboundInstanceVm.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bosh/director/problem_handlers/unbound_instance_vm.rb', line 10 def initialize(vm_id, data) super @vm = Models::Vm[vm_id] @data = data 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 if @vm.cid.nil? handler_error("VM `#{vm_id}' doesn't have a cloud id") end end |
Instance Method Details
#description ⇒ Object
30 31 32 33 34 |
# File 'lib/bosh/director/problem_handlers/unbound_instance_vm.rb', line 30 def description job = @data["job"] || "unknown job" index = @data["index"] || "unknown index" "VM `#{@vm.cid}' reports itself as `#{job}/#{index}' but does not have a bound instance" end |
#reassociate_vm ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bosh/director/problem_handlers/unbound_instance_vm.rb', line 62 def reassociate_vm instances = Models::Instance. filter(:deployment_id => @vm.deployment_id, :job => @data["job"], :index => @data["index"]).all if instances.size > 1 handler_error("More than one instance in DB matches this VM") end if instances.empty? handler_error("No instances in DB match this VM") end instance = instances[0] if instance.vm handler_error("The corresponding instance is associated with another VM") end instance.update(:vm => @vm) end |
#validate ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bosh/director/problem_handlers/unbound_instance_vm.rb', line 51 def validate unless @vm.instance.nil? handler_error("Instance is now bound to VM") end state = agent_timeout_guard(@vm) { |agent| agent.get_state } if state["job"].nil? handler_error("VM now properly reports no job") end end |