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

#delete_vm, #delete_vm_from_cloud, #delete_vm_reference, #reboot_vm, #recreate_vm, #recreate_vm_skip_post_start

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
# 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
  handler_error("Can't find corresponding vm-cid for disk '#{@disk_cid}'") if @vm_cid.nil?

  @instance = @disk.instance

  @disk_owners = @data['owner_vms']
end

Instance Method Details

#descriptionObject



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

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



55
56
57
58
59
60
61
62
63
64
# File 'lib/bosh/director/problem_handlers/mount_info_mismatch.rb', line 55

def reattach_disk(reboot = false)
  cloud.attach_disk(@vm_cid, @disk_cid)
  if reboot
    reboot_vm(@instance)
  else
    agent_timeout_guard(@instance.vm_cid, @instance.credentials, @instance.agent_id) do |agent|
      agent.mount_disk(@disk_cid)
    end
  end
end