Class: Bosh::Director::ProblemHandlers::MountInfoMismatch

Inherits:
Base
  • Object
show all
Defined in:
lib/bosh/director/problem_handlers/mount_info_mismatch.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, #delete_vm_reference, #handler_error, #instance_name, #reboot_vm, #recreate_vm

Constructor Details

#initialize(disk_id, data) ⇒ MountInfoMismatch

Returns a new instance of MountInfoMismatch.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bosh/director/problem_handlers/mount_info_mismatch.rb', line 10

def initialize(disk_id, data)
  @disk = Models::PersistentDisk[disk_id]
  @data = data

  if @disk.nil?
    handler_error("Disk `#{disk_id}' is no longer in the database")
  end

  @disk_cid = @disk.disk_cid
  @vm_cid = @disk.instance.vm.cid if @disk.instance && @disk.instance.vm
  handler_error("Can't find corresponding vm-cid for disk `#{@disk_cid}'") if @vm_cid.nil?

  @instance = @disk.instance
  @vm = @instance.vm

  @disk_owners = @data['owner_vms']
end

Instance Method Details

#descriptionObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bosh/director/problem_handlers/mount_info_mismatch.rb', line 28

def description
  out =  "Inconsistent mount information:\n"
  out += "Record shows that disk '#{@disk_cid}' should be mounted on #{@vm_cid}.\n"
  out += "However it is currently :\n"

  if @disk_owners.size == 0
    out += "\tNot mounted in any VM"
  else
    out += "\tMounted on: #{@disk_owners.join(", ")}"
  end
  out
end

#reattach_disk(reboot = false) ⇒ Object



56
57
58
59
# File 'lib/bosh/director/problem_handlers/mount_info_mismatch.rb', line 56

def reattach_disk(reboot = false)
  cloud.attach_disk(@vm_cid, @disk_cid)
  reboot ? reboot_vm(@vm) : agent_timeout_guard(@vm) { |agent| agent.mount_disk(@disk_cid) }
end