use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class BaseIscsiBondCommand method connectAllHostsToStorage.
protected void connectAllHostsToStorage(List<String> connectionIds) {
List<Callable<Void>> tasks = new ArrayList<>();
final List<StorageServerConnections> connections = storageServerConnectionDao.getByIds(connectionIds);
List<VDS> hosts = vdsDao.getAllForStoragePoolAndStatus(getIscsiBond().getStoragePoolId(), VDSStatus.Up);
for (final VDS host : hosts) {
tasks.add(() -> {
try {
final List<StorageServerConnections> conns = iscsiStorageHelper.updateIfaces(connections, host.getId());
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(host.getId(), Guid.Empty, StorageType.ISCSI, conns));
final Map<String, String> iscsiMap = (Map<String, String>) returnValue.getReturnValue();
List<String> failedConnectionsList = iscsiMap.entrySet().stream().filter(e -> !"0".equals(e.getValue())).map(Map.Entry::getKey).collect(Collectors.toList());
if (!failedConnectionsList.isEmpty()) {
log.error("Host '{}' - '{}' encounter problems to connect to the iSCSI Storage" + " Server. The following connections were problematic" + "" + " (connectionid=vdsm result): {}", host.getName(), host.getId(), iscsiMap.toString());
encounterConnectionProblems = true;
}
} catch (EngineException e) {
log.error("Could not connect Host '{}' - '{}' to Iscsi Storage Server: {}", host.getName(), host.getId(), e.getMessage());
log.debug("Exception", e);
encounterConnectionProblems = true;
}
return null;
});
}
ThreadPoolUtil.invokeAll(tasks);
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class AbstractDiskVmCommand method performPlugCommand.
protected void performPlugCommand(VDSCommandType commandType, Disk disk, VmDevice vmDevice) {
if (disk.getDiskStorageType() == DiskStorageType.LUN) {
LunDisk lunDisk = (LunDisk) disk;
if (commandType == VDSCommandType.HotPlugDisk) {
LUNs lun = lunDisk.getLun();
updateLUNConnectionsInfo(lun);
lun.getLunConnections().stream().map(StorageServerConnections::getStorageType).distinct().forEach(t -> {
if (!getStorageHelper(t).connectStorageToLunByVdsId(null, getVm().getRunOnVds(), lun, getVm().getStoragePoolId())) {
throw new EngineException(EngineError.StorageServerConnectionError);
}
});
}
} else if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
CinderDisk cinderDisk = (CinderDisk) disk;
setStorageDomainId(cinderDisk.getStorageIds().get(0));
getCinderBroker().updateConnectionInfoForDisk(cinderDisk);
}
Map<String, String> diskAddressMap = getDiskAddressMap(vmDevice, getDiskVmElement().getDiskInterface());
runVdsCommand(commandType, new HotPlugDiskVDSParameters(getVm().getRunOnVds(), getVm(), disk, vmDevice, diskAddressMap, getDiskVmElement().getDiskInterface(), getDiskVmElement().isPassDiscard()));
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class AddVdsCommand method executeCommand.
@Override
protected void executeCommand() {
Guid oVirtId = getParameters().getVdsForUniqueId();
if (oVirtId != null) {
// if fails to remove deprecated entry, we might attempt to add new oVirt host with an existing unique-id.
if (!removeDeprecatedOvirtEntry(oVirtId)) {
log.error("Failed to remove duplicated oVirt entry with id '{}'. Abort adding oVirt Host type", oVirtId);
throw new EngineException(EngineError.HOST_ALREADY_EXISTS);
}
}
completeOpenstackNetworkProviderId();
TransactionSupport.executeInNewTransaction(() -> {
addVdsStaticToDb();
addVdsDynamicToDb();
addVdsStatisticsToDb();
addAffinityLabels();
getCompensationContext().stateChanged();
return null;
});
if (getParameters().isProvisioned()) {
HostProviderProxy proxy = providerProxyFactory.create(getHostProvider());
proxy.provisionHost(getParameters().getvds(), getParameters().getHostGroup(), getParameters().getComputeResource(), getParameters().getHostMac(), getParameters().getDiscoverName(), getParameters().getPassword(), getParameters().getDiscoverIp());
addCustomValue("HostGroupName", getParameters().getHostGroup().getName());
auditLogDirector.log(this, AuditLogType.VDS_PROVISION);
}
// set vds spm id
if (getCluster().getStoragePoolId() != null) {
VdsActionParameters tempVar = new VdsActionParameters(getVdsIdRef());
tempVar.setSessionId(getParameters().getSessionId());
tempVar.setCompensationEnabled(true);
ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, tempVar, cloneContext().withoutLock().withoutExecutionContext());
if (!addVdsSpmIdReturn.getSucceeded()) {
setSucceeded(false);
getReturnValue().setFault(addVdsSpmIdReturn.getFault());
return;
}
}
TransactionSupport.executeInNewTransaction(() -> {
initializeVds(true);
alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
testVdsPowerManagementStatus(getParameters().getVdsStaticData());
setSucceeded(true);
setActionReturnValue(getVdsIdRef());
// If the installation failed, we don't want to compensate for the failure since it will remove the
// host, but instead the host should be left in an "install failed" status.
getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand();
return null;
});
// clients). they are installed as part of the approve process or automatically after provision
if (Config.<Boolean>getValue(ConfigValues.InstallVds) && !getParameters().isPending() && !getParameters().isProvisioned()) {
final InstallVdsParameters installVdsParameters = new InstallVdsParameters(getVdsId(), getParameters().getPassword());
installVdsParameters.setAuthMethod(getParameters().getAuthMethod());
installVdsParameters.setOverrideFirewall(getParameters().getOverrideFirewall());
installVdsParameters.setActivateHost(getParameters().getActivateHost());
installVdsParameters.setNetworkProviderId(getParameters().getVdsStaticData().getOpenstackNetworkProviderId());
installVdsParameters.setNetworkMappings(getParameters().getNetworkMappings());
installVdsParameters.setEnableSerialConsole(getParameters().getEnableSerialConsole());
if (getParameters().getHostedEngineDeployConfiguration() != null) {
Map<String, String> vdsDeployParams = hostedEngineHelper.createVdsDeployParams(getVdsId(), getParameters().getHostedEngineDeployConfiguration().getDeployAction());
installVdsParameters.setHostedEngineConfiguration(vdsDeployParams);
}
Map<String, String> values = new HashMap<>();
values.put(VdcObjectType.VDS.name().toLowerCase(), getParameters().getvds().getName());
Step installStep = executionHandler.addSubStep(getExecutionContext(), getExecutionContext().getJob().getStep(StepEnum.EXECUTING), StepEnum.INSTALLING_HOST, ExecutionMessageDirector.resolveStepMessage(StepEnum.INSTALLING_HOST, values));
final ExecutionContext installCtx = new ExecutionContext();
installCtx.setJob(getExecutionContext().getJob());
installCtx.setStep(installStep);
installCtx.setMonitored(true);
installCtx.setShouldEndJob(true);
ThreadPoolUtil.execute(() -> runInternalAction(ActionType.InstallVdsInternal, installVdsParameters, cloneContextAndDetachFromParent().withExecutionContext(installCtx)));
ExecutionHandler.setAsyncJob(getExecutionContext(), true);
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class AttachDiskToVmCommand method updateDiskVmSnapshotId.
private void updateDiskVmSnapshotId() {
Guid snapshotId = snapshotDao.getId(getVmId(), SnapshotType.ACTIVE);
if (disk.getDiskStorageType().isInternal()) {
DiskImage diskImage = (DiskImage) disk;
imageDao.updateImageVmSnapshotId(diskImage.getImageId(), snapshotId);
} else {
throw new EngineException(EngineError.StorageException, "update of snapshot id was initiated for unsupported disk type");
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class CreateSnapshotDiskCommand method executeCommand.
@Override
protected void executeCommand() {
for (DiskImage disk : getDisksList()) {
if (disk.getDiskStorageType() == DiskStorageType.CINDER) {
CreateCinderSnapshotParameters params = buildChildCommandParameters(disk);
params.setQuotaId(disk.getQuotaId());
Future<ActionReturnValue> future = commandCoordinatorUtil.executeAsyncCommand(ActionType.CreateCinderSnapshot, params, cloneContext().withoutCompensationContext().withoutLock());
try {
ActionReturnValue actionReturnValue = future.get();
if (!actionReturnValue.getSucceeded()) {
log.error("Error creating snapshot for Cinder disk '{}'", disk.getDiskAlias());
throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
}
} catch (InterruptedException | ExecutionException e) {
log.error("Error creating snapshot for Cinder disk '{}': {}", disk.getDiskAlias(), e.getMessage());
throw new EngineException(EngineError.CINDER_ERROR, "Failed to create snapshot!");
}
continue;
}
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshot, buildCreateSnapshotParameters(disk), ExecutionHandler.createDefaultContextForTasks(getContext()));
if (actionReturnValue.getSucceeded()) {
getTaskIdList().addAll(actionReturnValue.getInternalVdsmTaskIdList());
} else {
throw new EngineException(actionReturnValue.getFault().getError(), "Failed to create snapshot!");
}
}
setSucceeded(true);
}
Aggregations