use of com.cloud.legacymodel.communication.command.CheckOnHostCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testCheckOnHostCommand.
@Test
public void testCheckOnHostCommand() {
final com.cloud.legacymodel.dc.Host host = Mockito.mock(com.cloud.legacymodel.dc.Host.class);
final CheckOnHostCommand onHostCommand = new CheckOnHostCommand(host);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(onHostCommand, this.citrixResourceBase);
assertFalse(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.CheckOnHostCommand in project cosmic by MissionCriticalCloud.
the class XenServerInvestigator method isAgentAlive.
@Override
public HostStatus isAgentAlive(final Host agent) {
if (agent.getHypervisorType() != HypervisorType.XenServer) {
return null;
}
final CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
final List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
for (final HostVO neighbor : neighbors) {
if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
continue;
}
final Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
if (answer != null && answer.getResult()) {
final CheckOnHostAnswer ans = (CheckOnHostAnswer) answer;
if (!ans.isDetermined()) {
s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent);
continue;
}
// even it returns true, that means host is up, but XAPI may not work
return ans.isAlive() ? null : HostStatus.Down;
}
}
return null;
}
use of com.cloud.legacymodel.communication.command.CheckOnHostCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testCheckOnHostCommand.
@Test
public void testCheckOnHostCommand() {
final Host host = Mockito.mock(Host.class);
final CheckOnHostCommand command = new CheckOnHostCommand(host);
final KvmHaMonitor monitor = Mockito.mock(KvmHaMonitor.class);
when(this.libvirtComputingResource.getMonitor()).thenReturn(monitor);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getMonitor();
}
use of com.cloud.legacymodel.communication.command.CheckOnHostCommand in project cosmic by MissionCriticalCloud.
the class XenServer56WrapperTest method testCheckOnHostCommand.
@Test
public void testCheckOnHostCommand() {
final Host host = Mockito.mock(Host.class);
final CheckOnHostCommand onHostCommand = new CheckOnHostCommand(host);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(onHostCommand, this.xenServer56Resource);
assertTrue(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.CheckOnHostCommand in project cosmic by MissionCriticalCloud.
the class KvmInvestigator method isAgentAlive.
@Override
public HostStatus isAgentAlive(final Host agent) {
if (agent.getHypervisorType() != HypervisorType.KVM) {
return null;
}
HostStatus hostStatus = null;
HostStatus neighbourStatus = null;
final CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
try {
final Answer answer = agentMgr.easySend(agent.getId(), cmd);
if (answer != null) {
hostStatus = answer.getResult() ? HostStatus.Down : HostStatus.Up;
}
} catch (final Exception e) {
logger.debug("Failed to send command to host: " + agent.getId());
}
if (hostStatus == null) {
hostStatus = HostStatus.Disconnected;
}
final List<HostVO> neighbors = resourceMgr.listHostsInClusterByStatus(agent.getClusterId(), HostStatus.Up);
for (final HostVO neighbor : neighbors) {
if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.KVM) {
continue;
}
logger.debug("Investigating host:" + agent.getId() + " via neighbouring host:" + neighbor.getId());
try {
final Answer answer = agentMgr.easySend(neighbor.getId(), cmd);
if (answer != null) {
neighbourStatus = answer.getResult() ? HostStatus.Down : HostStatus.Up;
logger.debug("Neighbouring host:" + neighbor.getId() + " returned status:" + neighbourStatus + " for the investigated host:" + agent.getId());
if (neighbourStatus == HostStatus.Up) {
break;
}
}
} catch (final Exception e) {
logger.debug("Failed to send command to host: " + neighbor.getId());
}
}
if (neighbourStatus == HostStatus.Up && (hostStatus == HostStatus.Disconnected || hostStatus == HostStatus.Down)) {
hostStatus = HostStatus.Disconnected;
}
if (neighbourStatus == HostStatus.Down && (hostStatus == HostStatus.Disconnected || hostStatus == HostStatus.Down)) {
hostStatus = HostStatus.Down;
}
return hostStatus;
}
Aggregations