Search in sources :

Example 51 with LUNs

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()));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) EngineException(org.ovirt.engine.core.common.errors.EngineException) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HotPlugDiskVDSParameters(org.ovirt.engine.core.common.vdscommands.HotPlugDiskVDSParameters)

Example 52 with LUNs

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;
}
Also used : ConnectHostToStoragePoolServersParameters(org.ovirt.engine.core.common.action.ConnectHostToStoragePoolServersParameters) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) ArrayList(java.util.ArrayList) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) CollectionUtils(org.apache.commons.collections.CollectionUtils) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Map(java.util.Map) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) Pair(org.ovirt.engine.core.common.utils.Pair) StorageServerConnectionLunMapDao(org.ovirt.engine.core.dao.StorageServerConnectionLunMapDao) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) SyncLunsInfoForBlockStorageDomainParameters(org.ovirt.engine.core.common.action.SyncLunsInfoForBlockStorageDomainParameters) Logger(org.slf4j.Logger) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) HostStoragePoolParametersBase(org.ovirt.engine.core.common.action.HostStoragePoolParametersBase) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) InterfaceDao(org.ovirt.engine.core.dao.network.InterfaceDao) Collections(java.util.Collections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 53 with LUNs

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;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) List(java.util.List) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 54 with LUNs

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;
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 55 with LUNs

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);
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) DiskLunMap(org.ovirt.engine.core.common.businessentities.storage.DiskLunMap)

Aggregations

LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)105 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)33 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)26 Guid (org.ovirt.engine.core.compat.Guid)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)17 List (java.util.List)16 HashMap (java.util.HashMap)14 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VM (org.ovirt.engine.core.common.businessentities.VM)7 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)7 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)7 Map (java.util.Map)6 LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)6 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 GetDeviceListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)5 HashSet (java.util.HashSet)4