Search in sources :

Example 1 with GetVmVncTicketAnswer

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

the class VmwareResource method execute.

private GetVmVncTicketAnswer execute(GetVmVncTicketCommand cmd) {
    String vmInternalName = cmd.getVmInternalName();
    s_logger.info("Getting VNC ticket for VM " + vmInternalName);
    try {
        String ticket = acquireVirtualMachineVncTicket(vmInternalName);
        boolean result = StringUtils.isNotBlank(ticket);
        return new GetVmVncTicketAnswer(ticket, result, result ? "" : "Empty ticket obtained");
    } catch (Exception e) {
        s_logger.error("Error getting VNC ticket for VM " + vmInternalName, e);
        return new GetVmVncTicketAnswer(null, false, e.getLocalizedMessage());
    }
}
Also used : GetVmVncTicketAnswer(com.cloud.agent.api.GetVmVncTicketAnswer) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Example 2 with GetVmVncTicketAnswer

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

the class ConsoleProxyServlet method acquireVncTicketForVmwareVm.

/**
 * Acquires a ticket to be used for console proxy as described in 'Removal of VNC Server from ESXi' on:
 * https://docs.vmware.com/en/VMware-vSphere/7.0/rn/vsphere-esxi-vcenter-server-70-release-notes.html
 */
private String acquireVncTicketForVmwareVm(VirtualMachine vm) {
    try {
        s_logger.info("Acquiring VNC ticket for VM = " + vm.getHostName());
        GetVmVncTicketCommand cmd = new GetVmVncTicketCommand(vm.getInstanceName());
        Answer answer = agentManager.send(vm.getHostId(), cmd);
        GetVmVncTicketAnswer ans = (GetVmVncTicketAnswer) answer;
        if (!ans.getResult()) {
            s_logger.info("VNC ticket could not be acquired correctly: " + ans.getDetails());
        }
        return ans.getTicket();
    } catch (AgentUnavailableException | OperationTimedoutException e) {
        s_logger.error("Error acquiring ticket", e);
        return null;
    }
}
Also used : GetVmVncTicketCommand(com.cloud.agent.api.GetVmVncTicketCommand) Answer(com.cloud.agent.api.Answer) GetVmVncTicketAnswer(com.cloud.agent.api.GetVmVncTicketAnswer) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) GetVmVncTicketAnswer(com.cloud.agent.api.GetVmVncTicketAnswer)

Aggregations

GetVmVncTicketAnswer (com.cloud.agent.api.GetVmVncTicketAnswer)2 Answer (com.cloud.agent.api.Answer)1 GetVmVncTicketCommand (com.cloud.agent.api.GetVmVncTicketCommand)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConnectException (java.net.ConnectException)1 RemoteException (java.rmi.RemoteException)1 ConfigurationException (javax.naming.ConfigurationException)1