use of com.cloud.legacymodel.communication.command.PingTestCommand in project cosmic by MissionCriticalCloud.
the class UserVmDomRInvestigator method testUserVM.
private Boolean testUserVM(final VirtualMachine vm, final Nic nic, final VirtualRouter router) {
final String privateIp = nic.getIPv4Address();
final String routerPrivateIp = router.getPrivateIpAddress();
List<Long> otherHosts = new ArrayList<>();
if (vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.KVM) {
otherHosts.add(router.getHostId());
} else {
otherHosts = findHostByPod(router.getPodIdToDeployIn(), null);
}
for (final Long hostId : otherHosts) {
try {
final Answer pingTestAnswer = _agentMgr.easySend(hostId, new PingTestCommand(routerPrivateIp, privateIp));
if (pingTestAnswer != null && pingTestAnswer.getResult()) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("user vm's " + vm.getHostName() + " ip address " + privateIp + " has been successfully pinged from the Virtual Router " + router.getHostName() + ", returning that vm is alive");
}
return Boolean.TRUE;
}
} catch (final Exception e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Couldn't reach due to", e);
}
continue;
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug(vm + " could not be pinged, returning that it is unknown");
}
return null;
}
Aggregations