use of org.ovirt.engine.core.vdsbroker.VdsManager in project ovirt-engine by oVirt.
the class SshSoftFencingCommand method checkIfHostBecomeUp.
/**
* Check if host become Up after successful SSH Soft Fencing execution until grace period is over
*
* @return {@code true} if host became Up during grace period, otherwise {@code false}
*/
private boolean checkIfHostBecomeUp() {
VdsManager vdsManager = getResourceManager().getVdsManager(getVdsId());
long sleepInterval = TimeUnit.SECONDS.toMillis(Config.<Long>getValue(ConfigValues.VdsRefreshRate));
while (vdsManager.isHostInGracePeriod(true)) {
if (vdsManager.getCopyVds().getStatus() == VDSStatus.Up) {
// host became Up during grace period
return true;
}
// wait until next host monitoring attempt
ThreadUtils.sleep(sleepInterval);
}
return false;
}
use of org.ovirt.engine.core.vdsbroker.VdsManager in project ovirt-engine by oVirt.
the class HttpImageTaskVDSCommand method executeHttpMethod.
protected void executeHttpMethod(final T method) {
int responseCode = -1;
VdsManager manager = resourceManager.getVdsManager(getParameters().getVdsId());
final HttpClient httpclient = manager.getVdsProxy().getHttpClient();
try {
FutureTask<Integer> futureTask = new FutureTask(() -> httpclient.executeMethod(method));
Future<Integer> f = ThreadPoolUtil.execute(futureTask);
if (f.get(Config.<Integer>getValue(getConfigValueTimeLimitForOperation()), TimeUnit.MINUTES) == null) {
responseCode = futureTask.get();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (Exception e) {
log.debug("Exception", e);
throw createNetworkException(e);
}
if (responseCode == getSuccessCode()) {
Guid createdTask = Guid.createGuidFromString(processResponseHeaderValue(getMethod(), "Task-Id", null));
getVDSReturnValue().setCreationInfo(new AsyncTaskCreationInfo(createdTask, getCreatedTaskType(), getParameters().getStoragePoolId()));
handleOkResponse();
getVDSReturnValue().setSucceeded(true);
return;
}
processResponseHeaderValue(getMethod(), "Content-type", "application/json");
String response;
try {
response = getMethod().getResponseBodyAsString();
} catch (Exception e) {
throw createNetworkException(e);
}
Map<String, Object> resultMap = null;
try {
resultMap = new ObjectMapper().readValue(response, HashMap.class);
status = new StatusOnlyReturn(resultMap);
} catch (Exception e) {
throwVdsErrorException("failed to parse response " + response, EngineError.GeneralException);
}
proceedProxyReturnValue();
}
use of org.ovirt.engine.core.vdsbroker.VdsManager in project ovirt-engine by oVirt.
the class VdsBrokerCommand method initializeVdsBroker.
protected IVdsServer initializeVdsBroker(Guid vdsId) {
VdsManager vdsmanager = Injector.get(ResourceManager.class).getVdsManager(vdsId);
if (vdsmanager == null) {
throw new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND, String.format("Vds with id: %1$s was not found", vdsId));
}
setVdsAndVdsStatic(vdsmanager.getCopyVds());
return vdsmanager.getVdsProxy();
}
use of org.ovirt.engine.core.vdsbroker.VdsManager in project ovirt-engine by oVirt.
the class HostUpdatesChecker method checkForUpdates.
public HostUpgradeManagerResult checkForUpdates(VDS host) {
AuditLogable auditLog = new AuditLogableImpl();
auditLog.setVdsName(host.getName());
auditLog.setVdsId(host.getId());
if (!vdsDynamicDao.get(host.getId()).getStatus().isEligibleForOnDemandCheckUpdates()) {
log.warn("Check for available updates is skipped for host '{}' due to unsupported host status '{}' ", host.getName(), host.getStatus());
auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_SKIPPED_UNSUPPORTED_STATUS);
return null;
}
HostUpgradeManagerResult updatesResult = null;
try {
updatesResult = availableUpdatesFinder.checkForUpdates(host);
if (updatesResult.isUpdatesAvailable()) {
List<String> availablePackages = updatesResult.getAvailablePackages();
String message;
if (availablePackages.size() > HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES) {
message = String.format("%1$s and %2$s others. To see all packages check engine.log.", StringUtils.join(availablePackages.subList(0, HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES), ", "), availablePackages.size() - HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES);
} else {
message = String.format("found updates for packages %s", StringUtils.join(updatesResult.getAvailablePackages(), ", "));
}
auditLog.addCustomValue("Message", message);
} else {
auditLog.addCustomValue("Message", "no updates found.");
}
auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FINISHED);
} catch (IllegalStateException e) {
log.warn(e.getMessage());
auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_PROCESS_IS_ALREADY_RUNNING);
} catch (Exception e) {
log.error("Failed to check if updates are available for host '{}' with error message '{}'", host.getName(), e.getMessage());
log.debug("Exception", e);
auditLog.addCustomValue("Message", StringUtils.defaultString(e.getMessage(), e.getCause() == null ? null : e.getCause().toString()));
auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FAILED);
}
if (updatesResult != null && updatesResult.isUpdatesAvailable() != host.isUpdateAvailable()) {
VdsManager hostManager = resourceManager.getVdsManager(host.getId());
synchronized (hostManager) {
hostManager.updateUpdateAvailable(updatesResult.isUpdatesAvailable());
}
}
return updatesResult;
}
use of org.ovirt.engine.core.vdsbroker.VdsManager in project ovirt-engine by oVirt.
the class PendingResourceManager method notifyHostManagers.
/**
* Notify host manager that the pending memory and CPU data have changed.
* This is automatically called when a VM or Host are cleared, however the user is responsible
* for calling it after finished with adding all new pending resources for a VM.
* @param hostId - it of the affected host
*/
public void notifyHostManagers(Guid hostId) {
if (resourceManager == null) {
return;
}
VdsManager vdsManager = resourceManager.getVdsManager(hostId);
int pendingCpus = PendingCpuCores.collectForHost(this, hostId);
int pendingMemory = PendingOvercommitMemory.collectForHost(this, hostId);
vdsManager.updatePendingData(pendingMemory, pendingCpus);
}
Aggregations