use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method executeCommand.
@Override
protected void executeCommand() {
if (noChangesDetected()) {
log.info("No changes were detected in setup networks for host '{}' (ID: '{}')", getVdsName(), getVdsId());
setSucceeded(true);
return;
}
try (EngineLock monitoringLock = acquireMonitorLock("Host setup networks")) {
int timeout = getSetupNetworksTimeout();
FutureVDSCall<VDSReturnValue> setupNetworksTask = invokeSetupNetworksCommand(timeout);
try {
VDSReturnValue retVal = setupNetworksTask.get(timeout, TimeUnit.SECONDS);
if (retVal != null) {
if (!retVal.getSucceeded() && retVal.getVdsError() == null && getParameters().rollbackOnFailure()) {
throw new EngineException(EngineError.SETUP_NETWORKS_ROLLBACK, retVal.getExceptionString());
}
VdsHandler.handleVdsResult(retVal);
if (retVal.getSucceeded()) {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetCapabilities, new VdsIdAndVdsVDSCommandParametersBase(getVds()));
VDS updatedHost = (VDS) returnValue.getReturnValue();
persistNetworkChanges(updatedHost);
}
setSucceeded(true);
}
} catch (TimeoutException e) {
log.debug("Host Setup networks command timed out for {} seconds", timeout);
}
}
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class CommitNetworkChangesCommand method executeCommand.
@Override
protected void executeCommand() {
VDSReturnValue retVal = runVdsCommand(VDSCommandType.SetSafeNetworkConfig, new VdsIdVDSCommandParametersBase(getParameters().getVdsId()));
vdsDynamicDao.updateNetConfigDirty(getParameters().getVdsId(), false);
setSucceeded(retVal.getSucceeded());
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class VdsCommandsHelper method runVdsCommand.
private VDSReturnValue runVdsCommand(VDSCommandType vdsCommandType, VdsIdVDSCommandParametersBase params, Guid storagePoolId, CommandBase<?> cmd, boolean performFailover) {
Set<Guid> executedHosts = new HashSet<>();
VDSReturnValue returnValue = null;
if (params.getVdsId() == null) {
chooseHostForExecution(params, storagePoolId, cmd, Collections.emptyList());
if (params.getVdsId() == null) {
throw new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND, "No host was found to perform the operation");
}
}
int attempts = 0;
while (attempts <= Config.<Integer>getValue(ConfigValues.HsmCommandFailOverRetries)) {
try {
attempts++;
returnValue = resourceManager.runVdsCommand(vdsCommandType, params);
if (returnValue != null && returnValue.getSucceeded()) {
return returnValue;
}
} catch (EngineException e) {
returnValue = e.getVdsReturnValue();
}
executedHosts.add(params.getVdsId());
if (!performFailover || (returnValue != null && !returnValue.isCanTryOnDifferentVds())) {
break;
}
chooseHostForExecution(params, storagePoolId, cmd, executedHosts);
if (params.getVdsId() == null) {
break;
}
}
return VdsHandler.handleVdsResult(returnValue);
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class ExportRepoImageCommand method executeCommand.
@Override
protected void executeCommand() {
DiskImage diskImage = getDiskImage();
OpenStackImageProviderProxy proxy = getProviderProxy();
acquireImageDbLock();
String newImageId = proxy.createImageFromDiskImage(diskImage);
getParameters().setParentCommand(ActionType.ExportRepoImage);
Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
getParameters().setEntityInfo(new EntityInfo(VdcObjectType.Disk, getParameters().getImageGroupID()));
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.UploadImage, new UploadImageVDSCommandParameters(getStorageDomain().getStoragePoolId(), getStorageDomain().getId(), diskImage.getId(), diskImage.getImageId(), new HttpLocationInfo(getProviderProxy().getImageUrl(newImageId), getProviderProxy().getUploadHeaders())));
if (vdsReturnValue.getSucceeded()) {
getReturnValue().getVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Disk, getParameters().getImageGroupID(), getParameters().getDestinationDomainId()));
}
getReturnValue().setActionReturnValue(newImageId);
setSucceeded(true);
}
use of org.ovirt.engine.core.common.vdscommands.VDSReturnValue in project ovirt-engine by oVirt.
the class SPMAsyncTask method clearAsyncTask.
@Override
public void clearAsyncTask(boolean forceDelete) {
VDSReturnValue vdsReturnValue = null;
try {
log.info("SPMAsyncTask::ClearAsyncTask: Attempting to clear task '{}'", getVdsmTaskId());
vdsReturnValue = coco.clearTask(getStoragePoolID(), getVdsmTaskId());
} catch (RuntimeException e) {
log.error("SPMAsyncTask::ClearAsyncTask: Error during clearing task '{}': {}", getVdsmTaskId(), e.getMessage());
log.error("Exception", e);
}
boolean shouldGracefullyDeleteTask = false;
if (!isTaskStateError(vdsReturnValue)) {
if (vdsReturnValue == null || !vdsReturnValue.getSucceeded()) {
setState(AsyncTaskState.ClearFailed);
onTaskCleanFailure();
} else {
setState(AsyncTaskState.Cleared);
shouldGracefullyDeleteTask = true;
}
}
// A task should be removed from DB if forceDelete is set to true, or if it was cleared successfully.
if (shouldGracefullyDeleteTask || forceDelete) {
removeTaskFromDB();
}
}
Aggregations