Search in sources :

Example 6 with GetDomRVersionAnswer

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

the class HypervDirectConnectResource method execute.

protected Answer execute(final GetDomRVersionCmd cmd) {
    final String command = String.format("%s%s", "/opt/cloud/bin/", VRScripts.VERSION);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Executing resource GetDomRVersionCmd: " + 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("GetDomRVersionCmd on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: " + result.second());
            return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed due to " + result.second());
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("GetDomRVersionCmd on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
        }
    } catch (final Throwable e) {
        final String msg = "GetDomRVersionCmd failed due to " + e;
        s_logger.error(msg, e);
        return new GetDomRVersionAnswer(cmd, msg);
    }
    final String[] lines = result.second().split("&");
    if (lines.length != 2) {
        return new GetDomRVersionAnswer(cmd, result.second());
    }
    return new GetDomRVersionAnswer(cmd, result.second(), lines[0], lines[1]);
}
Also used : GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer)

Aggregations

GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)6 Answer (com.cloud.agent.api.Answer)3 Network (com.cloud.network.Network)3 DomainRouterVO (com.cloud.vm.DomainRouterVO)3 Nic (com.cloud.vm.Nic)3 ArrayList (java.util.ArrayList)3 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)2 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)2 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)2 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 ExecutionResult (com.cloud.utils.ExecutionResult)2 NicProfile (com.cloud.vm.NicProfile)2 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)1 CheckSshAnswer (com.cloud.agent.api.check.CheckSshAnswer)1 GetRouterMonitorResultsAnswer (com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer)1 GroupAnswer (com.cloud.agent.api.routing.GroupAnswer)1 Zone (com.cloud.db.model.Zone)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 NetworkTopology (com.cloud.network.topology.NetworkTopology)1