Search in sources :

Example 6 with GetVncPortAnswer

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

the class CitrixGetVncPortCommandWrapper method execute.

@Override
public Answer execute(final GetVncPortCommand command, final CitrixResourceBase citrixResourceBase) {
    final Connection conn = citrixResourceBase.getConnection();
    try {
        final Set<VM> vms = VM.getByNameLabel(conn, command.getName());
        if (vms.size() == 1) {
            String consoleurl;
            consoleurl = "consoleurl=" + citrixResourceBase.getVncUrl(conn, vms.iterator().next()) + "&" + "sessionref=" + conn.getSessionReference();
            return new GetVncPortAnswer(command, consoleurl, -1);
        } else {
            return new GetVncPortAnswer(command, "There are " + vms.size() + " VMs named " + command.getName());
        }
    } catch (final Exception e) {
        final String msg = "Unable to get vnc port due to " + e.toString();
        s_logger.warn(msg, e);
        return new GetVncPortAnswer(command, msg);
    }
}
Also used : GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) VM(com.xensource.xenapi.VM) Connection(com.xensource.xenapi.Connection)

Aggregations

GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)6 InternalErrorException (com.cloud.exception.InternalErrorException)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 IOException (java.io.IOException)2 ConfigurationException (javax.naming.ConfigurationException)2 Connect (org.libvirt.Connect)2 LibvirtException (org.libvirt.LibvirtException)2 ConsoleAccessAuthenticationAnswer (com.cloud.agent.api.ConsoleAccessAuthenticationAnswer)1 GetVncPortCommand (com.cloud.agent.api.GetVncPortCommand)1 CloudException (com.cloud.exception.CloudException)1 HostVO (com.cloud.host.HostVO)1 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)1 Xen (com.cloud.hypervisor.ovm3.objects.Xen)1 VmwareManager (com.cloud.hypervisor.vmware.manager.VmwareManager)1 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)1 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)1 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)1 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 VirtualMachine (com.cloud.vm.VirtualMachine)1 Connection (com.xensource.xenapi.Connection)1