@Override public Boolean isVmAlive(VirtualMachine vm, Host host) { if (!vm.getType().isUsedBySystem()) { s_logger.debug("Not a System Vm, unable to determine state of " + vm + " returning null"); } if (s_logger.isDebugEnabled()) { s_logger.debug("Testing if " + vm + " is alive"); } if (vm.getHostId() == null) { s_logger.debug("There's no host id for " + vm); return null; } HostVO vmHost = _hostDao.findById(vm.getHostId()); if (vmHost == null) { s_logger.debug("Unable to retrieve the host by using id " + vm.getHostId()); return null; } List<? extends Nic> nics = _networkMgr.getNicsForTraffic(vm.getId(), TrafficType.Management); if (nics.size() == 0) { if (s_logger.isDebugEnabled()) { s_logger.debug( "Unable to find a management nic, cannot ping this system VM, unable to determine state of " + vm + " returning null"); } return null; } for (Nic nic : nics) { if (nic.getIp4Address() == null) { continue; } // get the data center IP address, find a host on the pod, use that host to ping the data // center IP address List<Long> otherHosts = findHostByPod(vmHost.getPodId(), vm.getHostId()); for (Long otherHost : otherHosts) { Status vmState = testIpAddress(otherHost, nic.getIp4Address()); if (vmState == null) { // can't get information from that host, try the next one continue; } if (vmState == Status.Up) { if (s_logger.isDebugEnabled()) { s_logger.debug( "successfully pinged vm's private IP (" + vm.getPrivateIpAddress() + "), returning that the VM is up"); } return Boolean.TRUE; } else if (vmState == Status.Down) { // We can't ping the VM directly...if we can ping the host, then report the VM down. // If we can't ping the host, then we don't have enough information. Status vmHostState = testIpAddress(otherHost, vmHost.getPrivateIpAddress()); if ((vmHostState != null) && (vmHostState == Status.Up)) { if (s_logger.isDebugEnabled()) { s_logger.debug( "successfully pinged vm's host IP (" + vmHost.getPrivateIpAddress() + "), but could not ping VM, returning that the VM is down"); } return Boolean.FALSE; } } } } if (s_logger.isDebugEnabled()) { s_logger.debug("unable to determine state of " + vm + " returning null"); } return null; }