Search in sources :

Example 1 with GetVncPortAnswer

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

the class LibvirtComputingResource method execute.

protected GetVncPortAnswer execute(GetVncPortCommand cmd) {
    try {
        Connect conn = LibvirtConnection.getConnection();
        Integer vncPort = getVncPort(conn, cmd.getName());
        return new GetVncPortAnswer(cmd, _privateIp, 5900 + vncPort);
    } catch (Exception e) {
        return new GetVncPortAnswer(cmd, e.toString());
    }
}
Also used : GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) Connect(org.libvirt.Connect) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) URISyntaxException(java.net.URISyntaxException) LibvirtException(org.libvirt.LibvirtException) FileNotFoundException(java.io.FileNotFoundException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException)

Example 2 with GetVncPortAnswer

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

the class VmwareResource method execute.

protected Answer execute(GetVncPortCommand cmd) {
    try {
        VmwareContext context = getServiceContext();
        VmwareHypervisorHost hyperHost = getHyperHost(context);
        assert (hyperHost instanceof HostMO);
        VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
        VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getName());
        if (vmMo == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Unable to find the owner VM for GetVncPortCommand on host " + hyperHost.getHyperHostName() + ", try within datacenter");
            }
            vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getName());
            if (vmMo == null) {
                throw new Exception("Unable to find VM in vSphere, vm: " + cmd.getName());
            }
        }
        Pair<String, Integer> portInfo = vmMo.getVncPort(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
        if (s_logger.isTraceEnabled()) {
            s_logger.trace("Found vnc port info. vm: " + cmd.getName() + " host: " + portInfo.first() + ", vnc port: " + portInfo.second());
        }
        return new GetVncPortAnswer(cmd, portInfo.first(), portInfo.second());
    } catch (Throwable e) {
        return new GetVncPortAnswer(cmd, createLogMessageException(e, cmd));
    }
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) HostMO(com.cloud.hypervisor.vmware.mo.HostMO) VmwareManager(com.cloud.hypervisor.vmware.manager.VmwareManager) VirtualMachineMO(com.cloud.hypervisor.vmware.mo.VirtualMachineMO) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) 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 3 with GetVncPortAnswer

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

the class LibvirtGetVncPortCommandWrapper method execute.

@Override
public Answer execute(final GetVncPortCommand command, final LibvirtComputingResource libvirtComputingResource) {
    try {
        final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
        final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(command.getName());
        final Integer vncPort = libvirtComputingResource.getVncPort(conn, command.getName());
        return new GetVncPortAnswer(command, libvirtComputingResource.getPrivateIp(), 5900 + vncPort);
    } catch (final LibvirtException e) {
        return new GetVncPortAnswer(command, e.toString());
    }
}
Also used : GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect)

Example 4 with GetVncPortAnswer

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

the class ResourceManagerImpl method setKVMVncAccess.

/**
 * Add VNC details as user VM details for each VM in 'vms' (KVM hosts only)
 */
protected void setKVMVncAccess(long hostId, List<VMInstanceVO> vms) {
    for (VMInstanceVO vm : vms) {
        GetVncPortAnswer vmVncPortAnswer = (GetVncPortAnswer) _agentMgr.easySend(hostId, new GetVncPortCommand(vm.getId(), vm.getInstanceName()));
        if (vmVncPortAnswer != null) {
            userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.KVM_VNC_ADDRESS, vmVncPortAnswer.getAddress(), true);
            userVmDetailsDao.addDetail(vm.getId(), VmDetailConstants.KVM_VNC_PORT, String.valueOf(vmVncPortAnswer.getPort()), true);
        }
    }
}
Also used : GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) GetVncPortCommand(com.cloud.agent.api.GetVncPortCommand) VMInstanceVO(com.cloud.vm.VMInstanceVO)

Example 5 with GetVncPortAnswer

use of com.cloud.agent.api.GetVncPortAnswer in project cosmic by MissionCriticalCloud.

the class LibvirtGetVncPortCommandWrapper method execute.

@Override
public Answer execute(final GetVncPortCommand command, final LibvirtComputingResource libvirtComputingResource) {
    try {
        final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
        final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(command.getName());
        final Integer vncPort = libvirtComputingResource.getVncPort(conn, command.getName());
        return new GetVncPortAnswer(command, libvirtComputingResource.getPrivateIp(), 5900 + vncPort);
    } catch (final LibvirtException e) {
        return new GetVncPortAnswer(command, e.toString());
    }
}
Also used : GetVncPortAnswer(com.cloud.agent.api.GetVncPortAnswer) LibvirtException(org.libvirt.LibvirtException) Connect(org.libvirt.Connect)

Aggregations

GetVncPortAnswer (com.cloud.agent.api.GetVncPortAnswer)10 GetVncPortCommand (com.cloud.agent.api.GetVncPortCommand)3 Connect (org.libvirt.Connect)3 LibvirtException (org.libvirt.LibvirtException)3 ConsoleAccessAuthenticationAnswer (com.cloud.agent.api.ConsoleAccessAuthenticationAnswer)2 InternalErrorException (com.cloud.exception.InternalErrorException)2 HostVO (com.cloud.host.HostVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 VirtualMachine (com.cloud.vm.VirtualMachine)2 Connection (com.xensource.xenapi.Connection)2 VM (com.xensource.xenapi.VM)2 IOException (java.io.IOException)2 Date (java.util.Date)2 ConfigurationException (javax.naming.ConfigurationException)2 CloudException (com.cloud.exception.CloudException)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