use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method runConnectHostToPoolEvent.
private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) {
EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
StoragePool storagePool = storagePoolDao.get(storagePoolId);
StorageDomain masterDomain = storageDomainDao.getStorageDomains(storagePoolId, StorageDomainType.Master).get(0);
List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == StorageDomainStatus.Inactive || masterDomain.getStatus() == StorageDomainStatus.Unknown;
VDSError error = null;
try {
VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomain.getId(), storagePoolIsoMap));
if (!vdsReturnValue.getSucceeded()) {
error = vdsReturnValue.getVdsError();
}
} catch (EngineException e) {
error = e.getVdsError();
}
if (error != null) {
if (error.getCode() != EngineError.CannotConnectMultiplePools && masterDomainInactiveOrUnknown) {
log.info("Could not connect host '{}' to pool '{}', as the master domain is in inactive/unknown" + " status - not failing the operation", vds.getName(), storagePool.getName());
} else {
log.error("Could not connect host '{}' to pool '{}': {}", vds.getName(), storagePool.getName(), error.getMessage());
result.setSuccess(false);
}
}
if (result.isSuccess()) {
Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown, storagePool);
result.setSuccess(vdsStatsResults.getFirst());
if (!result.isSuccess()) {
result.setResultData(vdsStatsResults.getSecond());
auditLogDirector.log(this, AuditLogType.VDS_STORAGE_VDS_STATS_FAILED);
}
}
return result;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class RemoveNetworkParametersBuilder method buildParameters.
public ArrayList<ActionParametersBase> buildParameters(Network network, List<VdsNetworkInterface> labeledNics) {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
if (managementNetworkUtil.isManagementNetwork(network.getId())) {
return parameters;
}
for (VdsNetworkInterface nic : labeledNics) {
PersistentHostSetupNetworksParameters setupNetworkParams = createHostSetupNetworksParameters(nic.getVdsId());
setupNetworkParams.setNetworkNames(network.getName());
Map<String, VdsNetworkInterface> nicByNetworkName = NetworkUtils.hostInterfacesByNetworkName(getNics(nic.getVdsId()));
VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(nic.getVdsId()), nic.getId());
if (nicToConfigure == null) {
throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
}
NetworkAttachment networkAttachment = getNetworkIdToAttachmentMap(nic.getVdsId()).get(network.getId());
if (networkAttachment != null) {
if (networkAttachment.getNicId().equals(nicToConfigure.getId())) {
setupNetworkParams.getRemovedNetworkAttachments().add(networkAttachment.getId());
}
} else {
VdsNetworkInterface nicWithNetwork = nicByNetworkName.get(network.getName());
if (nicWithNetwork != null && NetworkCommonUtils.stripVlan(nicWithNetwork).equals(nic.getName())) {
setupNetworkParams.getRemovedUnmanagedNetworks().add(network.getName());
}
}
parameters.add(setupNetworkParams);
}
return parameters;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class AddNetworksByLabelParametersBuilder method buildParameters.
/**
* Adds a list of labeled networks to a host
*/
public PersistentHostSetupNetworksParameters buildParameters(Guid hostId, List<Network> labeledNetworks, Map<String, VdsNetworkInterface> nicsByLabel) {
PersistentHostSetupNetworksParameters parameters = createHostSetupNetworksParameters(hostId);
Set<Network> networksToAdd = getNetworksToConfigure(getNics(hostId), labeledNetworks);
for (Network network : networksToAdd) {
VdsNetworkInterface labeledNic = nicsByLabel.get(network.getLabel());
VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(hostId), labeledNic.getId());
if (nicToConfigure == null) {
throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
}
// configure the network on the nic
addAttachmentToParameters(nicToConfigure, network, parameters);
}
parameters.setNetworkNames(networksToAdd.stream().map(Network::getName).collect(Collectors.joining(", ")));
return parameters;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class HostedEngineConfigFetcher method downloadDisk.
private byte[] downloadDisk(Guid spId, Guid sdId, DiskImage diskImage) {
long downloadSize = Config.<Integer>getValue(ConfigValues.HostedEngineConfigDiskSizeInBytes);
log.info("Found the HE configuration disk. Downloading the content in size of {} bytes", downloadSize);
ActionReturnValue returnValue = backend.runInternalAction(ActionType.RetrieveImageData, new RetrieveImageDataParameters(spId, sdId, diskImage.getId(), diskImage.getImageId(), downloadSize));
if (returnValue.getSucceeded()) {
return (byte[]) returnValue.getActionReturnValue();
} else {
throw new EngineException(EngineError.ENGINE, "Failed to download the HE configuration disk");
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class SyncMacsOfDbNicsWithSnapshot method reallocateMacsWhichCouldntBeAddedToMacPool.
private void reallocateMacsWhichCouldntBeAddedToMacPool(List<String> macsFailedToBeAdded, List<? extends NetworkInterface> snapshotedNics) {
if (macsFailedToBeAdded.isEmpty()) {
return;
}
// not to ruin original for error reporting.
List<String> macsFailedToBeAddedCopy = new ArrayList<>(macsFailedToBeAdded);
try {
List<Pair<String, String>> macReplacements = new ArrayList<>();
for (NetworkInterface vmInterface : snapshotedNics) {
String originalMacAddress = vmInterface.getMacAddress();
if (macsFailedToBeAddedCopy.contains(originalMacAddress)) {
macsFailedToBeAddedCopy.remove(originalMacAddress);
String replacingMac = macPool.allocateNewMac();
vmInterface.setMacAddress(replacingMac);
macReplacements.add(new Pair<>(originalMacAddress, replacingMac));
}
}
auditLogPerformedReplacements(macReplacements);
} catch (EngineException ex) {
if (EngineError.MAC_POOL_NO_MACS_LEFT.equals(ex.getErrorCode())) {
auditLogImpossibilityToReplaceDuplicateMacs(macsFailedToBeAdded);
}
throw ex;
}
}
Aggregations