use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class InitVdsOnUpCommand method proceedVdsStats.
private Pair<Boolean, List<StorageDomainStatic>> proceedVdsStats(boolean shouldCheckReportedDomains, StoragePool storagePool) {
Pair<Boolean, List<StorageDomainStatic>> returnValue = new Pair<>(true, null);
try {
runVdsCommand(VDSCommandType.GetStats, new VdsIdAndVdsVDSCommandParametersBase(getVds()));
if (shouldCheckReportedDomains) {
List<Guid> problematicDomainsIds = fetchDomainsReportedAsProblematic(getVds().getDomains(), storagePool);
for (Guid domainId : problematicDomainsIds) {
StorageDomainStatic domainInfo = storageDomainStaticDao.get(domainId);
log.error("Storage Domain '{}' of pool '{}' is in problem in host '{}'", domainInfo != null ? domainInfo.getStorageName() : domainId, getStoragePool().getName(), getVds().getName());
if (domainInfo == null || domainInfo.getStorageDomainType().isDataDomain()) {
returnValue.setFirst(false);
if (returnValue.getSecond() == null) {
returnValue.setSecond(new ArrayList<>());
}
returnValue.getSecond().add(domainInfo);
}
}
}
} catch (EngineException e) {
log.error("Could not get Host statistics for Host '{}': {}", getVds().getName(), e.getMessage());
log.debug("Exception", e);
returnValue.setFirst(false);
}
return returnValue;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class AddNetworkCommand method getExclusiveLocks.
@Override
protected Map<String, Pair<String, String>> getExclusiveLocks() {
final Network network = getNetwork();
Map<String, Pair<String, String>> locks = new HashMap<>();
if (getNetworkName() != null) {
locks.put(getNetworkName(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.NETWORK, EngineMessage.ACTION_TYPE_FAILED_NETWORK_IS_USED));
}
if (network.isExternal() && !isInternalExecution()) {
locks.putAll(networkLocking.getNetworkProviderLock(network.getProvidedBy().getProviderId()));
}
return locks;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class RemoveDiskCommand method createSharedLocksForVmDisk.
private Map<String, Pair<String, String>> createSharedLocksForVmDisk() {
List<VM> listVms = getVmsForDiskId();
if (listVms.isEmpty()) {
return null;
}
Map<String, Pair<String, String>> result = new HashMap<>();
for (VM vm : listVms) {
result.put(vm.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM, getDiskIsBeingRemovedLockMessage()));
}
return result;
}
use of org.ovirt.engine.core.common.utils.Pair 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;
}
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class UpdateStorageServerConnectionCommand method getExclusiveLocks.
@Override
protected Map<String, Pair<String, String>> getExclusiveLocks() {
Map<String, Pair<String, String>> locks = new HashMap<>();
domains = getStorageDomainsByConnId(getConnection().getId());
if (!domains.isEmpty()) {
for (StorageDomain domain : domains) {
locks.put(domain.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
}
}
if (getConnection().getStorageType().isFileDomain()) {
// lock the path to avoid at the same time if some other user tries to
// add new storage connection to same path or edit another storage server connection to point to same path
locks.put(getConnection().getConnection(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
} else {
// for block domains, locking the target details
locks.put(getConnection().getConnection() + ";" + getConnection().getIqn() + ";" + getConnection().getPort() + ";" + getConnection().getUserName(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
// lock lun disks and domains, not VMs , no need to load from db.
if (getLuns() != null) {
for (LUNs lun : getLuns()) {
Guid diskId = lun.getDiskId();
Guid storageDomainId = lun.getStorageDomainId();
if (diskId != null) {
locks.put(diskId.toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.DISK, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
}
if (storageDomainId != null) {
locks.put(storageDomainId.toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
}
}
}
}
// lock connection's id to avoid editing or removing this connection at the same time
// by another user
locks.put(getConnection().getId(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.STORAGE_CONNECTION, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
return locks;
}
Aggregations