@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;
  }