Search in sources :

Example 1 with ConsoleProxyInfo

use of com.cloud.info.ConsoleProxyInfo in project cosmic by MissionCriticalCloud.

the class AgentBasedConsoleProxyManager method assignProxy.

@Override
public ConsoleProxyInfo assignProxy(final long dataCenterId, final long userVmId) {
    final UserVmVO userVm = _userVmDao.findById(userVmId);
    if (userVm == null) {
        s_logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId);
        return null;
    }
    final HostVO host = findHost(userVm);
    if (host != null) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Assign embedded console proxy running at " + host.getName() + " to user vm " + userVmId + " with public IP " + host.getPublicIpAddress());
        }
        // only private IP, public IP, host id have meaningful values, rest
        // of all are place-holder values
        String publicIp = host.getPublicIpAddress();
        if (publicIp == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Host " + host.getName() + "/" + host.getPrivateIpAddress() + " does not have public interface, we will return its private IP for cosole proxy.");
            }
            publicIp = host.getPrivateIpAddress();
        }
        int urlPort = _consoleProxyUrlPort;
        if (host.getProxyPort() != null && host.getProxyPort().intValue() > 0) {
            urlPort = host.getProxyPort().intValue();
        }
        return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain);
    } else {
        s_logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable.");
    }
    return null;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) ConsoleProxyInfo(com.cloud.info.ConsoleProxyInfo) HostVO(com.cloud.host.HostVO)

Example 2 with ConsoleProxyInfo

use of com.cloud.info.ConsoleProxyInfo in project cosmic by MissionCriticalCloud.

the class ConsoleProxyManagerImpl method assignProxy.

@Override
public ConsoleProxyInfo assignProxy(final long dataCenterId, final long vmId) {
    final ConsoleProxyVO proxy = doAssignProxy(dataCenterId, vmId);
    if (proxy == null) {
        return null;
    }
    if (proxy.getPublicIpAddress() == null) {
        logger.warn("Assigned console proxy does not have a valid public IP address");
        return null;
    }
    final KeystoreVO ksVo = _ksDao.findByName(ConsoleProxyManager.CERTIFICATE_NAME);
    if (proxy.isSslEnabled() && ksVo == null) {
        logger.warn("SSL enabled for console proxy but no server certificate found in database");
    }
    if (_staticPublicIp == null) {
        return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort, proxy.getPort(), _consoleProxyUrlDomain);
    } else {
        return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort, _staticPort, _consoleProxyUrlDomain);
    }
}
Also used : ConsoleProxyInfo(com.cloud.info.ConsoleProxyInfo) KeystoreVO(com.cloud.framework.security.keystore.KeystoreVO) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Example 3 with ConsoleProxyInfo

use of com.cloud.info.ConsoleProxyInfo in project cloudstack by apache.

the class ConsoleProxyManagerImpl method assignProxy.

@Override
public ConsoleProxyInfo assignProxy(final long dataCenterId, final long vmId) {
    ConsoleProxyVO proxy = doAssignProxy(dataCenterId, vmId);
    if (proxy == null) {
        return null;
    }
    if (proxy.getPublicIpAddress() == null) {
        s_logger.warn(String.format("Assigned console proxy [%s] does not have a valid public IP address.", proxy.toString()));
        return null;
    }
    KeystoreVO ksVo = _ksDao.findByName(ConsoleProxyManager.CERTIFICATE_NAME);
    if (proxy.isSslEnabled() && ksVo == null) {
        s_logger.warn(String.format("SSL is enabled for console proxy [%s] but no server certificate found in database.", proxy.toString()));
    }
    if (staticPublicIp == null) {
        return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), consoleProxyPort, proxy.getPort(), consoleProxyUrlDomain);
    } else {
        return new ConsoleProxyInfo(proxy.isSslEnabled(), staticPublicIp, consoleProxyPort, staticPort, consoleProxyUrlDomain);
    }
}
Also used : ConsoleProxyInfo(com.cloud.info.ConsoleProxyInfo) KeystoreVO(org.apache.cloudstack.framework.security.keystore.KeystoreVO) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO)

Example 4 with ConsoleProxyInfo

use of com.cloud.info.ConsoleProxyInfo in project cloudstack by apache.

the class AgentBasedStandaloneConsoleProxyManager method assignProxy.

@Override
public ConsoleProxyInfo assignProxy(long dataCenterId, long userVmId) {
    UserVmVO userVm = _userVmDao.findById(userVmId);
    if (userVm == null) {
        s_logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId);
        return null;
    }
    HostVO host = findHost(userVm);
    if (host != null) {
        HostVO allocatedHost = null;
        /*Is there a consoleproxy agent running on the same machine?*/
        List<HostVO> hosts = _hostDao.listAllIncludingRemoved();
        for (HostVO hv : hosts) {
            if (hv.getType() == Host.Type.ConsoleProxy && hv.getPublicIpAddress().equalsIgnoreCase(host.getPublicIpAddress())) {
                allocatedHost = hv;
                break;
            }
        }
        if (allocatedHost == null) {
            /*Is there a consoleproxy agent running in the same pod?*/
            for (HostVO hv : hosts) {
                if (hv.getType() == Host.Type.ConsoleProxy && hv.getPodId().equals(host.getPodId())) {
                    allocatedHost = hv;
                    break;
                }
            }
        }
        if (allocatedHost == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Failed to find a console proxy at host: " + host.getName() + " and in the pod: " + host.getPodId() + " to user vm " + userVmId);
            }
            return null;
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Assign standalone console proxy running at " + allocatedHost.getName() + " to user vm " + userVmId + " with public IP " + allocatedHost.getPublicIpAddress());
        }
        // only private IP, public IP, host id have meaningful values, rest of all are place-holder values
        String publicIp = allocatedHost.getPublicIpAddress();
        if (publicIp == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Host " + allocatedHost.getName() + "/" + allocatedHost.getPrivateIpAddress() + " does not have public interface, we will return its private IP for cosole proxy.");
            }
            publicIp = allocatedHost.getPrivateIpAddress();
        }
        int urlPort = _consoleProxyUrlPort;
        if (allocatedHost.getProxyPort() != null && allocatedHost.getProxyPort().intValue() > 0) {
            urlPort = allocatedHost.getProxyPort().intValue();
        }
        return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain);
    } else {
        s_logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable.");
    }
    return null;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) ConsoleProxyInfo(com.cloud.info.ConsoleProxyInfo) HostVO(com.cloud.host.HostVO)

Example 5 with ConsoleProxyInfo

use of com.cloud.info.ConsoleProxyInfo in project cloudstack by apache.

the class AgentBasedConsoleProxyManager method assignProxy.

@Override
public ConsoleProxyInfo assignProxy(long dataCenterId, long userVmId) {
    UserVmVO userVm = _userVmDao.findById(userVmId);
    if (userVm == null) {
        s_logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId);
        return null;
    }
    HostVO host = findHost(userVm);
    if (host != null) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Assign embedded console proxy running at " + host.getName() + " to user vm " + userVmId + " with public IP " + host.getPublicIpAddress());
        }
        // only private IP, public IP, host id have meaningful values, rest
        // of all are place-holder values
        String publicIp = host.getPublicIpAddress();
        if (publicIp == null) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Host " + host.getName() + "/" + host.getPrivateIpAddress() + " does not have public interface, we will return its private IP for cosole proxy.");
            }
            publicIp = host.getPrivateIpAddress();
        }
        int urlPort = _consoleProxyUrlPort;
        if (host.getProxyPort() != null && host.getProxyPort().intValue() > 0) {
            urlPort = host.getProxyPort().intValue();
        }
        return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain);
    } else {
        s_logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable.");
    }
    return null;
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) ConsoleProxyInfo(com.cloud.info.ConsoleProxyInfo) HostVO(com.cloud.host.HostVO)

Aggregations

ConsoleProxyInfo (com.cloud.info.ConsoleProxyInfo)5 HostVO (com.cloud.host.HostVO)3 UserVmVO (com.cloud.vm.UserVmVO)3 ConsoleProxyVO (com.cloud.vm.ConsoleProxyVO)2 KeystoreVO (com.cloud.framework.security.keystore.KeystoreVO)1 KeystoreVO (org.apache.cloudstack.framework.security.keystore.KeystoreVO)1