Search in sources :

Example 1 with DDMTreeInfo

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfo in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doExpandFS {} - start", args.getFsId());
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doExpandFS failed, provider unreachable");
            String op = "FS expand";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        Long newSize = args.getNewFSCapacity();
        Long currSize;
        if ((args.getFsCapacity() != null) && (args.getFsCapacity() > 0)) {
            currSize = args.getFsCapacity();
        } else {
            ServiceError serviceError = DeviceControllerErrors.datadomain.doFailedToGetCurrSize();
            return BiosCommandResult.createErrorResult(serviceError);
        }
        if (currSize >= newSize) {
            ServiceError serviceError = DeviceControllerErrors.datadomain.doShrinkFSFailed(currSize, newSize);
            return BiosCommandResult.createErrorResult(serviceError);
        }
        // Modify mtree
        // Data Domain expects capacity in Bytes
        DDMTreeInfo ddMtreeInfo = ddClient.expandMTree(args.getStoragePool().getNativeId(), args.getFs().getNativeId(), newSize);
        if (args.getFsExtensions() == null) {
            args.initFsExtensions();
        }
        args.getFsExtensions().put(DataDomainApiConstants.TOTAL_PHYSICAL_CAPACITY, String.valueOf(newSize));
        _log.info("DataDomainFileStorageDevice doExpandFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doExpandFS failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("doExpandFS failed.", e);
        ServiceError serviceError = DeviceControllerErrors.datadomain.doExpandFSFailed(e.getMessage());
        return BiosCommandResult.createErrorResult(serviceError);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DDMTreeInfo(com.emc.storageos.datadomain.restapi.model.DDMTreeInfo) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)

Example 2 with DDMTreeInfo

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfo in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method discoverUnManagedFileSystems.

private void discoverUnManagedFileSystems(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
    String detailedStatusMessage = "Discovery of DataDomain Unmanaged FileSystem started";
    List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
    StoragePool pool = getPoolFromDB(storageSystem);
    StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
    DDMTreeInfoDetail mtree = null;
    try {
        DDMTreeList mtreeList = ddClient.getMTreeList(storageSystem.getNativeGuid());
        for (DDMTreeInfo mtreeInfo : mtreeList.mtree) {
            mtree = ddClient.getMTree(storageSystem.getNativeGuid(), mtreeInfo.getId());
            if (mtree == null || mtree.delStatus == DataDomainApiConstants.FILE_DELETED) {
                continue;
            }
            // Filtering mtrees that are not supporting either of NFS & CIFS
            if ((mtree.protocolName == null) || (mtree.protocolName.isEmpty())) {
                _log.info("Mtree: {} doesn't contain any protocol defined so ignoring it", mtree.name);
                continue;
            } else {
                if ((mtree.protocolName.contains(DataDomainApiConstants.NFS_PROTOCOL)) || (mtree.protocolName.contains(DataDomainApiConstants.CIFS_PROTOCOL))) {
                    _log.info("Mtree: {} contains supported protocol:{} so discovering it", mtree.name, mtree.protocolName.toArray());
                } else {
                    _log.info("Mtree: {} contains unsupported protocol:{} so ignoring it", mtree.name, mtree.protocolName.toArray());
                    continue;
                }
            }
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
            // If the filesystem already exists in db..just continue.
            // No Need to create an UnManaged Filesystems.
            URIQueryResultList result = new URIQueryResultList();
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemNativeGUIdConstraint(fsNativeGuid), result);
            if (result.iterator().hasNext()) {
                continue;
            }
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), mtreeInfo.getId());
            UnManagedFileSystem unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
            boolean alreadyExist = unManagedFS == null ? false : true;
            unManagedFS = createUnManagedFileSystem(unManagedFS, fsUnManagedFsNativeGuid, mtree, storageSystem, pool, matchedVPools);
            if (alreadyExist) {
                existingUnManagedFileSystems.add(unManagedFS);
            } else {
                newUnManagedFileSystems.add(unManagedFS);
            }
            allDiscoveredUnManagedFileSystems.add(unManagedFS.getId());
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
        markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
        if (newUnManagedFileSystems != null && !newUnManagedFileSystems.isEmpty()) {
            // Add UnManagedFileSystem
            _dbClient.createObject(newUnManagedFileSystems);
            _log.info("{} {} Records inserted to DB", newUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
        }
        if (existingUnManagedFileSystems != null && !existingUnManagedFileSystems.isEmpty()) {
            _dbClient.updateAndReindexObject(existingUnManagedFileSystems);
            _log.info("{} {} Records updated to DB", existingUnManagedFileSystems.size(), UNMANAGED_FILESYSTEM);
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for DataDomain system: %s", storageSystem.getId().toString());
    } catch (DataDomainApiException dde) {
        detailedStatusMessage = "DiscoverStorage failed" + dde.getMessage();
        _log.error("discoverStorage failed.  Storage system: " + storageSystem.getId().toString());
        throw dde;
    } catch (Exception e) {
        detailedStatusMessage = "DiscoverStorage failed" + e.getMessage();
        _log.error("discoverStorage failed. Storage system: " + storageSystem.getId().toString(), e);
        throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) DDMTreeList(com.emc.storageos.datadomain.restapi.model.DDMTreeList) ArrayList(java.util.ArrayList) DDMTreeInfoDetail(com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDMTreeInfo(com.emc.storageos.datadomain.restapi.model.DDMTreeInfo) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) HashSet(java.util.HashSet)

Example 3 with DDMTreeInfo

use of com.emc.storageos.datadomain.restapi.model.DDMTreeInfo in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("DataDomainFileStorageDevice doCreateFS {} with name {} - start", args.getFsId(), args.getFsName());
    // TODO
    try {
        _log.info("DataDomainFileStorageDevice doCreateFS {} with name {} - start", args.getFsId(), args.getFsName());
        DataDomainClient ddclient = getDataDomainClient(storage);
        if (ddclient == null) {
            _log.error("doCreateFS failed, provider unreachable");
            String op = "FS create";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        // Update path and mountPath
        // TODO: try to mount export
        String path = args.getFsName();
        String mountPath;
        if (!path.startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
            mountPath = DataDomainApiConstants.FS_PATH_BASE + path;
        } else {
            mountPath = path;
        }
        _log.info("Mount path to mount the DataDomain File System {}", mountPath);
        args.setFsMountPath(mountPath);
        args.setFsPath(mountPath);
        // Create MTree
        // Data Domain expects capacity in Bytes
        Long mtreeCapacity = args.getFsCapacity();
        // TODO: Following two values are hard-coded for now, until they are implemented in UI
        Boolean enableRetention = false;
        String retentionMode = "compliance";
        DDMTreeInfo ddMtreeInfo = ddclient.createMTree(args.getStoragePool().getNativeId(), mountPath, mtreeCapacity, enableRetention, retentionMode);
        args.setFsNativeId(ddMtreeInfo.getId());
        String serialNumber = storage.getSerialNumber();
        if (serialNumber == null) {
            serialNumber = storage.getModel();
        }
        String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storage.getSystemType(), serialNumber.toUpperCase(), ddMtreeInfo.getId());
        args.setFsNativeGuid(fsNativeGuid);
        args.setNewFSCapacity(args.getFsCapacity());
        if (args.getFsExtensions() == null) {
            args.initFsExtensions();
        }
        args.getFsExtensions().put(DataDomainApiConstants.TOTAL_PHYSICAL_CAPACITY, String.valueOf(args.getFsCapacity()));
        _log.info("DataDomainFileStorageDevice doCreateFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doCreateFS failed, device error...attempting to delete FS to rollback.", e);
        // rollback this operation to prevent partial result of file share create
        BiosCommandResult rollbackResult = doDeleteFS(storage, args);
        if (rollbackResult.isCommandSuccess()) {
            _log.info("DataDomainFileStorageDevice doCreateFS {} - rollback completed.", args.getFsId());
        } else {
            _log.error("DataDomainFileStorageDevice doCreateFS {} - rollback failed,  message: {} .", args.getFsId(), rollbackResult.getMessage());
        }
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDMTreeInfo(com.emc.storageos.datadomain.restapi.model.DDMTreeInfo) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Aggregations

DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)3 DDMTreeInfo (com.emc.storageos.datadomain.restapi.model.DDMTreeInfo)3 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)2 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)2 DDMTreeInfoDetail (com.emc.storageos.datadomain.restapi.model.DDMTreeInfoDetail)1 DDMTreeList (com.emc.storageos.datadomain.restapi.model.DDMTreeList)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1