@Override public String toString() { return String.format("[OOBM Task] Power operation:%s on Host:%d(%s)", powerOperation, host.getId(), host.getName()); }
protected AgentAttache createAttacheForDirectConnect(final Host host, final ServerResource resource) throws ConnectionException { s_logger.debug("create DirectAgentAttache for " + host.getId()); final DirectAgentAttache attache = new DirectAgentAttache(this, host.getId(), host.getName(), resource, host.isInMaintenanceStates()); AgentAttache old = null; synchronized (_agents) { old = _agents.put(host.getId(), attache); } if (old != null) { old.disconnect(Status.Removed); } return attache; }
@Override public void run() { try { service.executePowerOperation(host, powerOperation, null); } catch (Exception e) { LOG.warn(String.format("Out-of-band management background task operation=%s for host id=%d failed with: %s", powerOperation.name(), host.getId(), e.getMessage())); } } }
@Override public void fenceSubResources(final Host r) { if (r.getState() != Status.Down) { try { LOG.debug("Trying to disconnect the host without investigation and scheduling HA for the VMs on host id=" + r.getId()); agentManager.disconnectWithoutInvestigation(r.getId(), Event.HostDown); oldHighAvailabilityManager.scheduleRestartForVmsOnHost((HostVO)r, true); } catch (Exception e) { LOG.error("Failed to disconnect host and schedule HA restart of VMs after fencing the host: ", e); } } }
protected boolean hostCanAccessSPool(Host host, StoragePool pool) { boolean hostCanAccessSPool = false; StoragePoolHostVO hostPoolLinkage = _poolHostDao.findByPoolHost(pool.getId(), host.getId()); if (hostPoolLinkage != null) { hostCanAccessSPool = true; } s_logger.debug("Host: " + host.getId() + (hostCanAccessSPool ? " can" : " cannot") + " access pool: " + pool.getId()); return hostCanAccessSPool; }
private OutOfBandManagement getConfigForHost(final Host host) { final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId()); if (outOfBandManagementConfig == null) { throw new CloudRuntimeException("Out-of-band management is not configured for the host. Please configure the host before enabling/disabling it."); } return outOfBandManagementConfig; }
public boolean transitionPowerStateToDisabled(List<? extends Host> hosts) { boolean result = true; for (Host host : hosts) { result = result && transitionPowerState(OutOfBandManagement.PowerState.Event.Disabled, outOfBandManagementDao.findByHost(host.getId())); } return result; }
@Override public OpenDaylightControllerVO doInTransaction(TransactionStatus status) { OpenDaylightControllerVO controller = new OpenDaylightControllerVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), hostParams .get("name")); openDaylightControllerMappingDao.persist(controller); return controller; } });
@Override public BigSwitchBcfDeviceVO doInTransaction(TransactionStatus status) { BigSwitchBcfDeviceVO bigswitchBcfDevice = new BigSwitchBcfDeviceVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName, hostname, username, password, nat, BigSwitchBcfApi.HASH_IGNORE); _bigswitchBcfDao.persist(bigswitchBcfDevice); DetailVO detail = new DetailVO(host.getId(), "bigswitchbcfdeviceid", String.valueOf(bigswitchBcfDevice.getId())); _hostDetailsDao.persist(detail); return bigswitchBcfDevice; } });
@Override public NiciraNvpDeviceVO doInTransaction(TransactionStatus status) { NiciraNvpDeviceVO niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName); niciraNvpDao.persist(niciraNvpDevice); DetailVO detail = new DetailVO(host.getId(), "niciranvpdeviceid", String.valueOf(niciraNvpDevice.getId())); hostDetailsDao.persist(detail); return niciraNvpDevice; } });
@Override public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException { if (!(cmd instanceof StartupRoutingCommand)) { return; } PlannerHostReservationVO reservationEntry = _plannerHostReserveDao.findByHostId(host.getId()); if (reservationEntry == null) { // record the host in this table PlannerHostReservationVO newHost = new PlannerHostReservationVO(host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId()); _plannerHostReserveDao.persist(newHost); } }
@Override public String generateKeyStoreAndCsr(final Host host, final Map<String, String> sshAccessDetails) throws AgentUnavailableException, OperationTimedoutException { final SetupKeyStoreCommand cmd = new SetupKeyStoreCommand(CertValidityPeriod.value()); if (sshAccessDetails != null && !sshAccessDetails.isEmpty()) { cmd.setAccessDetail(sshAccessDetails); } CallContext.current().setEventDetails("generating keystore and CSR for host id: " + host.getId()); final SetupKeystoreAnswer answer = (SetupKeystoreAnswer)agentManager.send(host.getId(), cmd); return answer.getCsr(); }
@Override public List<HostJoinVO> newHostView(Host host) { SearchCriteria<HostJoinVO> sc = hostIdSearch.create(); sc.setParameters("id", host.getId()); return searchIncludingRemoved(sc, null, null, false); }
@Override public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance) { if (!(cmd instanceof StartupStorageCommand)) { return; } long agentId = agent.getId(); StartupStorageCommand storage = (StartupStorageCommand)cmd; if (storage.getResourceType() == Storage.StorageResourceType.STORAGE_HOST || storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) { uploadMonitor.handleUploadSync(agentId); } }
@Override public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) { if (host.getType().equals(Host.Type.TrafficMonitor) || host.getType().equals(Host.Type.SecondaryStorage)) { return; } // NOTE: We don't use pingBy here because we're initiating. _pingMap.put(host.getId(), InaccurateClock.getTimeInSeconds()); }
@Override @ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, eventDescription = "enabling out-of-band management on a host") public OutOfBandManagementResponse enableOutOfBandManagement(final Host host) { final OutOfBandManagement outOfBandManagementConfig = getConfigForHost(host); hostAlertCache.invalidate(host.getId()); outOfBandManagementConfig.setEnabled(true); boolean updateResult = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig); if (updateResult) { transitionPowerStateToDisabled(Collections.singletonList(host)); } return buildEnableDisableResponse(true); }
@Override public TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor) { Map<String, String> tmDetails = ApiDBUtils.findHostDetailsById(trafficMonitor.getId()); TrafficMonitorResponse response = new TrafficMonitorResponse(); response.setId(trafficMonitor.getUuid()); response.setIpAddress(trafficMonitor.getPrivateIpAddress()); response.setNumRetries(tmDetails.get("numRetries")); response.setTimeout(tmDetails.get("timeout")); return response; }
@Override public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { PhysicalNetwork pNtwk = _physicalNetworkDao.findById(provider.getPhysicalNetworkId()); Host host = getGloboDnsHost(pNtwk.getDataCenterId()); if (host != null) { _resourceMgr.deleteHost(host.getId(), true, false); } return true; }
public boolean isOutOfBandManagementEnabled(final Host host) { return host != null && isOutOfBandManagementEnabledForZone(host.getDataCenterId()) && isOutOfBandManagementEnabledForCluster(host.getClusterId()) && isOutOfBandManagementEnabledForHost(host.getId()); }
private Long findAgentId(VirtualMachineProfile profile, DeployDestination dest, DataStore dataStore) throws ResourceUnavailableException { Long agentId; if (dest.getHost() == null) { agentId = (profile.getVirtualMachine().getHostId() == null ? profile.getVirtualMachine().getLastHostId() : profile.getVirtualMachine().getHostId()); } else { agentId = dest.getHost().getId(); } if (!VirtualMachineManager.VmConfigDriveOnPrimaryPool.value()) { agentId = findAgentIdForImageStore(dataStore); } return agentId; }