use of org.ovirt.engine.core.common.businessentities.storage.LUNs 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.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method isConnectSucceeded.
@Override
public boolean isConnectSucceeded(final Map<String, String> returnValue, List<StorageServerConnections> connections) {
boolean result = true;
List<String> failedConnectionsList = returnValue.keySet().stream().filter(a -> !"0".equals(returnValue.get(a))).collect(Collectors.toList());
for (String failedConnection : failedConnectionsList) {
List<LUNs> failedLuns = lunDao.getAllForStorageServerConnection(failedConnection);
if (!failedLuns.isEmpty()) {
for (LUNs lun : failedLuns) {
// TODO: check if LUNs in the same pool.
List<String> strings = storageServerConnectionLunMapDao.getAll(lun.getLUNId()).stream().map(LUNStorageServerConnectionMap::getStorageServerConnection).collect(Collectors.toList());
if (CollectionUtils.subtract(strings, failedConnectionsList).size() == 0) {
// At case of failure the appropriate log message will be
// added
log.info("The lun with id '{}' was reported as problematic", lun.getPhysicalVolumeId());
for (String connectionFailed : failedConnectionsList) {
String connectionField = addToAuditLogErrorMessage(connectionFailed, returnValue.get(connectionFailed), connections, lun);
printLog(log, connectionField, returnValue.get(connectionFailed));
}
return false;
}
}
} else {
result = false;
printLog(log, failedConnection, returnValue.get(failedConnection));
}
}
return result;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class RemoveStorageServerConnectionCommand method validate.
@Override
protected boolean validate() {
String connectionId = getConnection().getId();
List<StorageDomain> domains = null;
if (StringUtils.isEmpty(connectionId)) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY);
}
StorageServerConnections connection = storageServerConnectionDao.get(connectionId);
if (connection == null) {
return failValidation(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST);
}
// if user passed only the connection id for removal, vdsm still needs few more details in order to disconnect, so
// bringing them from db and repopulating them in the connection object received in input parameters
populateMissingFields(connection);
StorageType storageType = connection.getStorageType();
if (storageType.isFileDomain()) {
// go to storage domain static, get all storage domains where storage field = storage connection id
domains = getStorageDomainsByConnId(connectionId);
if (domains.size() > 0) {
String domainNames = createDomainNamesListFromStorageDomains(domains);
return prepareFailureMessageForDomains(domainNames);
}
} else if (storageType.equals(StorageType.ISCSI)) {
List<String> domainNames = new ArrayList<>();
List<String> diskNames = new ArrayList<>();
// go to luns to storage connections map table, get it from there
List<LUNs> luns = lunDao.getAllForStorageServerConnection(connectionId);
if (!luns.isEmpty()) {
String volumeGroupId = null;
for (LUNs lun : luns) {
volumeGroupId = lun.getVolumeGroupId();
if (StringUtils.isNotEmpty(volumeGroupId)) {
// non empty vg id indicates there's a storage domain using the lun
String domainName = lun.getStorageDomainName();
domainNames.add(domainName);
} else {
// empty vg id indicates there's a lun disk using the lun
String lunDiskName = lun.getDiskAlias();
diskNames.add(lunDiskName);
}
}
String domainNamesForMessage = null;
if (!domainNames.isEmpty()) {
// Build domain names list to display in the error
domainNamesForMessage = prepareEntityNamesForMessage(domainNames);
if (diskNames.isEmpty()) {
return prepareFailureMessageForDomains(domainNamesForMessage);
} else {
String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
return prepareFailureMessageForDomainsAndDisks(domainNamesForMessage, diskNamesForMessage);
}
} else if (!diskNames.isEmpty()) {
String diskNamesForMessage = prepareEntityNamesForMessage(diskNames);
return prepareFailureMessageForDisks(diskNamesForMessage);
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class LunDaoTest method generateNewEntity.
@Override
protected LUNs generateNewEntity() {
LUNs newLUN = new LUNs();
newLUN.setLUNId("oicu812");
newLUN.setVolumeGroupId("");
return newLUN;
}
use of org.ovirt.engine.core.common.businessentities.storage.LUNs in project ovirt-engine by oVirt.
the class AddDiskCommand method createDiskBasedOnLun.
private void createDiskBasedOnLun() {
final LUNs lun;
if (lunFromStorage == null) {
lun = ((LunDisk) getParameters().getDiskInfo()).getLun();
} else {
lun = lunFromStorage;
}
TransactionSupport.executeInNewTransaction(() -> {
lunHelper.proceedDirectLUNInDb(lun, lun.getLunType());
baseDiskDao.save(getParameters().getDiskInfo());
diskLunMapDao.save(new DiskLunMap(getParameters().getDiskInfo().getId(), lun.getLUNId()));
if (getVm() != null) {
// The disk VM element has to be added before the VM device since as a part of the VM device creation the
// boot order is determined so the VM device creation depends on the existence of the disk VM element
addDiskVmElementForDisk(getDiskVmElement());
addManagedDeviceForDisk(getParameters().getDiskInfo().getId());
vmStaticDao.incrementDbGeneration(getVmId());
}
return null;
});
getReturnValue().setActionReturnValue(getParameters().getDiskInfo().getId());
plugDiskToVmIfNeeded();
setSucceeded(true);
}
Aggregations