Search in sources :

Example 6 with CheckRouterAnswer

use of com.cloud.agent.api.CheckRouterAnswer in project cloudstack by apache.

the class HypervDirectConnectResource method execute.

protected Answer execute(final CheckRouterCommand cmd) {
    final String command = String.format("%s%s", "/opt/cloud/bin/", VRScripts.RVR_CHECK);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Executing resource CheckRouterCommand: " + s_gson.toJson(cmd));
        s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + command);
    }
    Pair<Boolean, String> result;
    try {
        final String controlIp = getRouterSshControlIp(cmd);
        result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, command);
        if (!result.first()) {
            s_logger.error("check router command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: " + result.second());
            return new CheckRouterAnswer(cmd, "CheckRouter failed due to " + result.second());
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("check router command on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
        }
    } catch (final Throwable e) {
        final String msg = "CheckRouterCommand failed due to " + e.getMessage();
        s_logger.error(msg, e);
        return new CheckRouterAnswer(cmd, msg);
    }
    return new CheckRouterAnswer(cmd, result.second(), true);
}
Also used : CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer)

Aggregations

CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)6 Answer (com.cloud.agent.api.Answer)4 CheckRouterCommand (com.cloud.agent.api.CheckRouterCommand)4 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)2 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)2 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)2 VirtualRoutingResource (com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource)2 ManagementServerHostVO (com.cloud.cluster.ManagementServerHostVO)2 HostVO (com.cloud.host.HostVO)2 LibvirtRequestWrapper (com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper)2 RedundantState (com.cloud.network.router.VirtualRouter.RedundantState)2 Test (org.junit.Test)2 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)1 UnsupportedAnswer (com.cloud.agent.api.UnsupportedAnswer)1 GetRouterMonitorResultsAnswer (com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer)1 GroupAnswer (com.cloud.agent.api.routing.GroupAnswer)1 MockVm (com.cloud.simulator.MockVm)1 AttachAnswer (com.cloud.storage.command.AttachAnswer)1 DomainRouterVO (com.cloud.vm.DomainRouterVO)1