Class: Dcmgr::NodeModules::InstanceMonitor

Inherits:
Isono::NodeModules::Base
  • Object
show all
Includes:
Logger
Defined in:
lib/dcmgr/node_modules/instance_monitor.rb

Instance Method Summary collapse

Methods included from Logger

create, default_logdev, included

Instance Method Details

#check_instanceObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dcmgr/node_modules/instance_monitor.rb', line 22

def check_instance()
  instlst = rpc.request('hva-collector', 'get_alive_instances', manifest.node_id)
  instlst.find_all{|i| i[:state] == 'running' }.each { |i|
    begin
      case i[:host_node][:hypervisor]
      when 'kvm'
        check_kvm_process(i)
      when 'lxc'
        check_lxc_process(i)
      else
        raise "Unknown hypervisor type: #{i[:host_node][:hypervisor]}"
      end
    rescue Exception => e
      if i[:status] == 'online'
        logger.error("#{e.class}, #{e.message}")

        rpc.request('hva-collector', 'update_instance', i[:uuid], {:status=>:offline}) { |req|
          req.oneshot = true
        }
        event.publish('hva/fault_instance', :args=>[i[:uuid]])
      end
      next
    end

    if i[:status] != 'online'
      rpc.request('hva-collector', 'update_instance', i[:uuid], {:status=>:online}) { |req|
        req.oneshot = true
      }
    end
  }
end