Sha256: f044ed6efca0116b6fc3eff133868b18d779ccb2cd025b793c64c73fe192459e
Contents?: true
Size: 1.86 KB
Versions: 2
Compression:
Stored size: 1.86 KB
Contents
# -*- coding: utf-8 -*- require 'isono' module Dcmgr module NodeModules class InstanceHA < Isono::NodeModules::Base include Dcmgr::Logger initialize_hook do @thread_pool = Isono::ThreadPool.new event = Isono::NodeModules::EventChannel.new(node) event.subscribe('hva/fault_instance', '#') { |args| @thread_pool.pass { inst_id = args[0] inst = Models::Instance[inst_id] # check if the instance has HA enable. next if inst.ha_enabled == 0 myinstance.restart_instance(inst) } } end terminate_hook do @thread_pool.shutdown end def restart_instance(inst) # terminate and cleanup begin jobrpc.run("kvm-handle.#{inst.host_pool.node_id}", 'cleanup', inst.canonical_uuid) rescue => e # termination may fail end # TODO: pick a new host node Isono::NodeModules::DataStore.barrier { inst.state = :failingover inst.save } # start a new backup instance case inst.image.boot_dev_type when Models::Image::BOOT_DEV_SAN boot_vol = inst.volume.find {|v| v.boot_dev == 1 } res = jobrpc.submit("kvm-handle.#{inst.host_pool.node_id}", 'run_vol_store', inst.canonical_uuid, boot_vol.canonical_uuid) when Models::Image::BOOT_DEV_LOCAL res = jobrpc.submit("kvm-handle.#{inst.host_pool.node_id}", 'run_local_store', inst.canonical_uuid) else raise "Unknown boot type" end logger.info("#{inst.canonical_uuid} has been restarted") end private def event @event ||= Isono::NodeModules::EventChannel.new(node) end def jobrpc @jobrpc ||= Isono::NodeModules::JobChannel.new(node) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
wakame-vdc-dcmgr-10.12.0 | lib/dcmgr/node_modules/instance_ha.rb |
wakame-vdc-agents-10.12.0 | lib/dcmgr/node_modules/instance_ha.rb |