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());
}
}
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;
}
}
Aggregations