@Override public boolean rebootProxy(long proxyVmId) { final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId); if (proxy == null || proxy.getState() == State.Destroyed) { return false; } if (proxy.getState() == State.Running && proxy.getHostId() != null) { final RebootCommand cmd = new RebootCommand(proxy.getInstanceName(), _itMgr.getExecuteInSequence(proxy.getHypervisorType())); final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd); if (answer != null && answer.getResult()) { if (s_logger.isDebugEnabled()) { s_logger.debug("Successfully reboot console proxy " + proxy.getHostName()); } SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this, new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(), proxy, null)); return true; } else { if (s_logger.isDebugEnabled()) { s_logger.debug("failed to reboot console proxy : " + proxy.getHostName()); } return false; } } else { return startProxy(proxyVmId, false) != null; } }
@Override public boolean destroyProxy(long vmId) { ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId); try { //expunge the vm _itMgr.expunge(proxy.getUuid()); proxy.setPublicIpAddress(null); proxy.setPublicMacAddress(null); proxy.setPublicNetmask(null); proxy.setPrivateMacAddress(null); proxy.setPrivateIpAddress(null); _consoleProxyDao.update(proxy.getId(), proxy); _consoleProxyDao.remove(vmId); HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(), Host.Type.ConsoleProxy); if (host != null) { s_logger.debug("Removing host entry for proxy id=" + vmId); return _hostDao.remove(host.getId()); } return true; } catch (ResourceUnavailableException e) { s_logger.warn("Unable to expunge " + proxy, e); return false; } }
public ConsoleProxyDaoImpl() { DataCenterStatusSearch = createSearchBuilder(); DataCenterStatusSearch.and("dc", DataCenterStatusSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DataCenterStatusSearch.and("states", DataCenterStatusSearch.entity().getState(), SearchCriteria.Op.IN); DataCenterStatusSearch.done(); StateSearch = createSearchBuilder(); StateSearch.and("states", StateSearch.entity().getState(), SearchCriteria.Op.IN); StateSearch.done(); HostSearch = createSearchBuilder(); HostSearch.and("host", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ); HostSearch.done(); LastHostSearch = createSearchBuilder(); LastHostSearch.and("lastHost", LastHostSearch.entity().getLastHostId(), SearchCriteria.Op.EQ); LastHostSearch.and("state", LastHostSearch.entity().getState(), SearchCriteria.Op.EQ); LastHostSearch.done(); HostUpSearch = createSearchBuilder(); HostUpSearch.and("host", HostUpSearch.entity().getHostId(), SearchCriteria.Op.EQ); HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.NIN); HostUpSearch.done(); StateChangeSearch = createSearchBuilder(); StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ); StateChangeSearch.and("states", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ); StateChangeSearch.and("host", StateChangeSearch.entity().getHostId(), SearchCriteria.Op.EQ); StateChangeSearch.and("update", StateChangeSearch.entity().getUpdated(), SearchCriteria.Op.EQ); StateChangeSearch.done(); _updateTimeAttr = _allAttributes.get("updateTime"); assert _updateTimeAttr != null : "Couldn't get this updateTime attribute"; }