Search in sources :

Example 1 with ConsoleAccessAuthenticationCommand

use of com.cloud.agent.api.ConsoleAccessAuthenticationCommand in project CloudStack-archive by CloudStack-extras.

the class ConsoleProxyResource method authenticateConsoleAccess.

public String authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket, Boolean isReauthentication) {
    ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket);
    cmd.setReauthenticating(isReauthentication);
    ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();
    result.setSuccess(false);
    result.setReauthentication(isReauthentication);
    try {
        AgentControlAnswer answer = getAgentControl().sendRequest(cmd, 10000);
        if (answer != null) {
            ConsoleAccessAuthenticationAnswer authAnswer = (ConsoleAccessAuthenticationAnswer) answer;
            result.setSuccess(authAnswer.succeeded());
            result.setHost(authAnswer.getHost());
            result.setPort(authAnswer.getPort());
            result.setTunnelUrl(authAnswer.getTunnelUrl());
            result.setTunnelSession(authAnswer.getTunnelSession());
        } else {
            s_logger.error("Authentication failed for vm: " + vmId + " with sid: " + sid);
        }
    } catch (AgentControlChannelException e) {
        s_logger.error("Unable to send out console access authentication request due to " + e.getMessage(), e);
    }
    return new Gson().toJson(result);
}
Also used : ConsoleAccessAuthenticationCommand(com.cloud.agent.api.ConsoleAccessAuthenticationCommand) AgentControlChannelException(com.cloud.exception.AgentControlChannelException) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) Gson(com.google.gson.Gson) ConsoleAccessAuthenticationAnswer(com.cloud.agent.api.ConsoleAccessAuthenticationAnswer)

Example 2 with ConsoleAccessAuthenticationCommand

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

the class ConsoleProxyResource method authenticateConsoleAccess.

public String authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket, Boolean isReauthentication) {
    ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket);
    cmd.setReauthenticating(isReauthentication);
    ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();
    result.setSuccess(false);
    result.setReauthentication(isReauthentication);
    try {
        AgentControlAnswer answer = getAgentControl().sendRequest(cmd, 10000);
        if (answer != null) {
            ConsoleAccessAuthenticationAnswer authAnswer = (ConsoleAccessAuthenticationAnswer) answer;
            result.setSuccess(authAnswer.succeeded());
            result.setHost(authAnswer.getHost());
            result.setPort(authAnswer.getPort());
            result.setTunnelUrl(authAnswer.getTunnelUrl());
            result.setTunnelSession(authAnswer.getTunnelSession());
        } else {
            s_logger.error("Authentication failed for vm: " + vmId + " with sid: " + sid);
        }
    } catch (AgentControlChannelException e) {
        s_logger.error("Unable to send out console access authentication request due to " + e.getMessage(), e);
    }
    return new Gson().toJson(result);
}
Also used : ConsoleAccessAuthenticationCommand(com.cloud.agent.api.ConsoleAccessAuthenticationCommand) AgentControlChannelException(com.cloud.exception.AgentControlChannelException) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) Gson(com.google.gson.Gson) ConsoleAccessAuthenticationAnswer(com.cloud.agent.api.ConsoleAccessAuthenticationAnswer)

Aggregations

AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2 ConsoleAccessAuthenticationAnswer (com.cloud.agent.api.ConsoleAccessAuthenticationAnswer)2 ConsoleAccessAuthenticationCommand (com.cloud.agent.api.ConsoleAccessAuthenticationCommand)2 AgentControlChannelException (com.cloud.exception.AgentControlChannelException)2 Gson (com.google.gson.Gson)2