Search in sources :

Example 81 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doDeleteShare: {} - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doDeleteShare failed, provider unreachable");
            String op = "FS share delete";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        SMBShareMap currentShares = args.getFileObjShares();
        List<SMBFileShare> sharesToDelete = new ArrayList<SMBFileShare>();
        sharesToDelete.add(smbFileShare);
        ddDeleteShares(ddClient, storagePool.getNativeId(), currentShares, sharesToDelete);
        _log.info("DataDomainFileStorageDevice doDeleteShare {} - complete");
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doDeleteShare failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) StoragePool(com.emc.storageos.db.client.model.StoragePool) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) ArrayList(java.util.ArrayList) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI)

Example 82 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method doCreateClone.

@Override
public void doCreateClone(StorageSystem storageSystem, URI volume, URI clone, Boolean createInactive, TaskCompleter taskCompleter) {
    Volume cloneObject = null;
    DriverTask task = null;
    try {
        cloneObject = dbClient.queryObject(Volume.class, clone);
        BlockObject sourceVolume = BlockObject.fetch(dbClient, volume);
        VolumeClone driverClone = new VolumeClone();
        if (sourceVolume instanceof Volume) {
            driverClone.setSourceType(VolumeClone.SourceType.VOLUME);
        } else if (sourceVolume instanceof BlockSnapshot) {
            driverClone.setSourceType(VolumeClone.SourceType.SNAPSHOT);
        } else {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
            String errorMsg = String.format("doCreateClone -- Failed to create volume clone: unexpected source type %s .", sourceVolume.getClass().getSimpleName());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        // Prepare driver clone
        driverClone.setParentId(sourceVolume.getNativeId());
        driverClone.setStorageSystemId(storageSystem.getNativeId());
        driverClone.setDisplayName(cloneObject.getLabel());
        driverClone.setRequestedCapacity(cloneObject.getCapacity());
        driverClone.setThinlyProvisioned(cloneObject.getThinlyProvisioned());
        // Call driver
        BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
        List<VolumeClone> driverClones = new ArrayList<>();
        driverClones.add(driverClone);
        task = driver.createVolumeClone(Collections.unmodifiableList(driverClones), null);
        if (!isTaskInTerminalState(task.getStatus())) {
            // If the task is not in a terminal state and will be completed asynchronously
            // create a job to monitor the progress of the request and update the clone
            // volume and call the completer as appropriate based on the result of the request.
            CreateVolumeCloneExternalDeviceJob job = new CreateVolumeCloneExternalDeviceJob(storageSystem.getId(), clone, task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // Update clone
            String msg = String.format("doCreateClone -- Created volume clone: %s .", task.getMessage());
            _log.info(msg);
            VolumeClone driverCloneResult = driverClones.get(0);
            ExternalDeviceUtils.updateNewlyCreatedClone(cloneObject, driverCloneResult, dbClient);
            taskCompleter.ready(dbClient);
        } else {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
            String errorMsg = String.format("doCreateClone -- Failed to create volume clone: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        if (cloneObject != null) {
            cloneObject.setInactive(true);
            dbClient.updateObject(cloneObject);
        }
        _log.error("Failed to create volume clone. ", e);
        ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        try {
            if (task == null || isTaskInTerminalState(task.getStatus())) {
                StoragePool dbPool = dbClient.queryObject(StoragePool.class, cloneObject.getPool());
                updateStoragePoolCapacity(dbPool, storageSystem, Collections.singletonList(clone), dbClient);
            }
        } catch (Exception ex) {
            _log.error("Failed to update storage pool {} after create clone operation completion.", cloneObject.getPool(), ex);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) DriverTask(com.emc.storageos.storagedriver.DriverTask) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) CreateVolumeCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.CreateVolumeCloneExternalDeviceJob) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageBlockObject(com.emc.storageos.storagedriver.model.StorageBlockObject) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver)

Example 83 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method doCreateGroupClone.

@Override
public void doCreateGroupClone(StorageSystem storageSystem, List<URI> cloneURIs, Boolean createInactive, TaskCompleter taskCompleter) {
    BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
    List<VolumeClone> driverClones = new ArrayList<>();
    Map<VolumeClone, Volume> driverCloneToCloneMap = new HashMap<>();
    Set<URI> consistencyGroups = new HashSet<>();
    List<Volume> clones = null;
    DriverTask task = null;
    try {
        clones = dbClient.queryObject(Volume.class, cloneURIs);
        // We assume here that all volumes belong to the same consistency group
        URI parentUri = clones.get(0).getAssociatedSourceVolume();
        Volume parentVolume = dbClient.queryObject(Volume.class, parentUri);
        BlockConsistencyGroup cg = null;
        if (!NullColumnValueGetter.isNullURI(parentVolume.getConsistencyGroup())) {
            cg = dbClient.queryObject(BlockConsistencyGroup.class, parentVolume.getConsistencyGroup());
        } else {
            String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone, parent volumes do not belong to consistency group." + " Clones: %s .", cloneURIs);
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
            return;
        }
        // Prepare driver consistency group of parent volume
        VolumeConsistencyGroup driverCG = new VolumeConsistencyGroup();
        driverCG.setDisplayName(cg.getLabel());
        driverCG.setNativeId(cg.getNativeId());
        driverCG.setStorageSystemId(storageSystem.getNativeId());
        // Prepare driver clones
        for (Volume clone : clones) {
            URI sourceVolumeUri = clone.getAssociatedSourceVolume();
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeUri);
            VolumeClone driverClone = new VolumeClone();
            driverClone.setParentId(sourceVolume.getNativeId());
            driverClone.setStorageSystemId(storageSystem.getNativeId());
            driverClone.setDisplayName(clone.getLabel());
            driverClone.setRequestedCapacity(clone.getCapacity());
            driverClone.setThinlyProvisioned(clone.getThinlyProvisioned());
            driverClones.add(driverClone);
            driverCloneToCloneMap.put(driverClone, clone);
        }
        // Call driver to create group snapshot
        task = driver.createConsistencyGroupClone(driverCG, Collections.unmodifiableList(driverClones), null);
        if (!isTaskInTerminalState(task.getStatus())) {
            // If the task is not in a terminal state and will be completed asynchronously
            // create a job to monitor the progress of the request and update the clone
            // volume and call the completer as appropriate based on the result of the request.
            CreateGroupCloneExternalDeviceJob job = new CreateGroupCloneExternalDeviceJob(storageSystem.getId(), cloneURIs, parentVolume.getConsistencyGroup(), task.getTaskId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(job));
        } else if (task.getStatus() == DriverTask.TaskStatus.READY) {
            // Update clone object with driver data
            String msg = String.format("doCreateGroupClone -- Created group clone: %s .", task.getMessage());
            _log.info(msg);
            List<Volume> cloneObjects = new ArrayList<>();
            for (VolumeClone driverCloneResult : driverClones) {
                Volume cloneObject = driverCloneToCloneMap.get(driverCloneResult);
                ExternalDeviceUtils.updateNewlyCreatedGroupClone(cloneObject, driverCloneResult, parentVolume.getConsistencyGroup(), dbClient);
                cloneObjects.add(cloneObject);
            }
            dbClient.updateObject(cloneObjects);
            taskCompleter.ready(dbClient);
        } else {
            // Process failure
            for (Volume cloneObject : clones) {
                cloneObject.setInactive(true);
            }
            dbClient.updateObject(clones);
            String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone: %s .", task.getMessage());
            _log.error(errorMsg);
            ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
            taskCompleter.error(dbClient, serviceError);
        }
    } catch (Exception e) {
        if (clones != null) {
            // Process failure
            for (Volume cloneObject : clones) {
                cloneObject.setInactive(true);
            }
            dbClient.updateObject(clones);
        }
        _log.error("Failed to create group clone. ", e);
        ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    } finally {
        try {
            if (task == null || isTaskInTerminalState(task.getStatus())) {
                // post process storage pool capacity for clone's pools
                // map clones to their storage pool
                Map<URI, List<URI>> dbPoolToClone = new HashMap<>();
                for (Volume clone : clones) {
                    URI dbPoolUri = clone.getPool();
                    List<URI> poolClones = dbPoolToClone.get(dbPoolUri);
                    if (poolClones == null) {
                        poolClones = new ArrayList<>();
                        dbPoolToClone.put(dbPoolUri, poolClones);
                    }
                    poolClones.add(clone.getId());
                }
                for (URI dbPoolUri : dbPoolToClone.keySet()) {
                    StoragePool dbPool = dbClient.queryObject(StoragePool.class, dbPoolUri);
                    updateStoragePoolCapacity(dbPool, storageSystem, dbPoolToClone.get(dbPoolUri), dbClient);
                }
            }
        } catch (Exception ex) {
            _log.error("Failed to update storage pool after create group clone operation completion.", ex);
        }
    }
}
Also used : VolumeConsistencyGroup(com.emc.storageos.storagedriver.model.VolumeConsistencyGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) DriverTask(com.emc.storageos.storagedriver.DriverTask) CreateGroupCloneExternalDeviceJob(com.emc.storageos.volumecontroller.impl.externaldevice.job.CreateGroupCloneExternalDeviceJob) StorageVolume(com.emc.storageos.storagedriver.model.StorageVolume) Volume(com.emc.storageos.db.client.model.Volume) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockStorageDriver(com.emc.storageos.storagedriver.BlockStorageDriver) HashSet(java.util.HashSet)

Example 84 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class XtremIOCommunicationInterface method discoverXtremIOSystem.

private void discoverXtremIOSystem(XtremIOClient restClient, StorageSystem systemInDB) {
    try {
        List<StoragePool> pools = new ArrayList<StoragePool>();
        XtremIOSystem clusterObject = restClient.getClusterDetails(systemInDB.getSerialNumber());
        updateStorageSystemAndPools(clusterObject, systemInDB, pools);
        Map<String, List<StoragePort>> portMap = discoverPorts(restClient, systemInDB);
        List<StoragePort> allPorts = new ArrayList<StoragePort>();
        allPorts.addAll(portMap.get(NEW));
        allPorts.addAll(portMap.get(EXISTING));
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, systemInDB.getId());
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(portMap.get(EXISTING));
        if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
            allExistingPorts.addAll(notVisiblePorts);
        }
        StoragePortAssociationHelper.runUpdatePortAssociationsProcess(portMap.get(NEW), allExistingPorts, _dbClient, _coordinator, pools);
        discoverInitiators(restClient, systemInDB);
    } catch (Exception e) {
        _logger.error("Error discovering XtremIO cluster", e);
        // throw exception only if system discovery failed.
        throw XtremIOApiException.exceptions.discoveryFailed(systemInDB.toString());
    }
}
Also used : XtremIOSystem(com.emc.storageos.xtremio.restapi.model.response.XtremIOSystem) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 85 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class UpdtableStoragePoolModel method updateStoragePoolObject.

/**
 * update the Storage Pool object with the available data came as part of
 * indication.
 *
 * @return
 */
private boolean updateStoragePoolObject(UpdtableStoragePoolModel spModel) {
    Long freeCapacity = spModel.getFreeCapacityInKB();
    String poolName = spModel.getPoolName();
    Long totalCapacity = spModel.getTotalCapacityInKB();
    Long subscribedCapacity = spModel.getSubscribedCapacityInKB();
    try {
        StoragePool pool = retriveStoragePoolFromDatabase();
        if (pool != null) {
            boolean isUpdateRequired = Boolean.FALSE;
            logMessage("==> Comparing Existing StoregPool Object with Recieved Information :\n freeCapacity: Existing Value [{}] - Recieved Value [{}], \n PoolName: Existing Value [{}] - Recieved Value [{}], \n TotalCapacity: Existing Value [{}] - Recieved Value [{}], \n SubscribedCapacity: Existing Value [{}] - Recieved Value [{}] \n", new Object[] { pool.calculateFreeCapacityWithoutReservations(), freeCapacity, pool.getPoolName(), poolName, pool.getTotalCapacity(), totalCapacity, pool.getSubscribedCapacity(), subscribedCapacity });
            if (freeCapacity != null && freeCapacity.longValue() != pool.calculateFreeCapacityWithoutReservations().longValue()) {
                logMessage("Updating Free Capacity : from {} to {}", new Object[] { pool.calculateFreeCapacityWithoutReservations(), freeCapacity });
                pool.setFreeCapacity(freeCapacity);
                isUpdateRequired = true;
            }
            if (poolName != null && !poolName.equals(pool.getPoolName())) {
                logMessage("Updating Pool Name : from {} to {}", new Object[] { pool.getPoolName(), poolName });
                pool.setPoolName(poolName);
                isUpdateRequired = true;
            }
            if (totalCapacity != null && totalCapacity.longValue() != pool.getTotalCapacity().longValue()) {
                logMessage("Updating Total Capacity : from {} to {}", new Object[] { pool.getTotalCapacity(), totalCapacity });
                pool.setTotalCapacity(totalCapacity);
                isUpdateRequired = true;
            }
            if (subscribedCapacity != null && subscribedCapacity.longValue() != pool.getSubscribedCapacity().longValue()) {
                logMessage("Updating Subscribed Capacity : from {} to {}", new Object[] { pool.getSubscribedCapacity(), subscribedCapacity });
                pool.setSubscribedCapacity(subscribedCapacity);
                isUpdateRequired = true;
            }
            if (isUpdateRequired) {
                _dbClient.persistObject(pool);
                logMessage("Storage Pool Object Updated", new Object[] {});
            }
            return isUpdateRequired;
        } else {
            _logger.debug("Indication not processed as no assosiated Storage Pool Object found");
        }
    } catch (IOException e) {
        _logger.error("Error occured while retriving StoragePool Object for Corresponding Indication {}", e.getMessage());
    } catch (NumberFormatException e) {
        _logger.error("Error occured while reading capacity data from Corresponding Indication {}", e.getMessage());
    }
    return Boolean.FALSE;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) IOException(java.io.IOException)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30