Search in sources :

Example 1 with DDShareInfo

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

the class DataDomainFileStorageDevice method ddCreateShare.

private void ddCreateShare(DataDomainClient ddClient, String storagePoolId, SMBFileShare smbFileShare, String sharePath) throws DataDomainApiException {
    String shareName = smbFileShare.getName();
    int maxUsers = smbFileShare.getMaxUsers();
    String desc = smbFileShare.getDescription();
    String permissionType = smbFileShare.getPermissionType();
    String permission = smbFileShare.getPermission();
    DDShareInfo ddShareInfo = ddClient.createShare(storagePoolId, shareName, sharePath, maxUsers, desc, permissionType, permission);
    if (ddShareInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
        DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePoolId, ddShareInfo.getId());
        throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(sharePath);
    }
    smbFileShare.setNativeId(ddShareInfo.getId());
}
Also used : DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo)

Example 2 with DDShareInfo

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

the class DataDomainCommunicationInterface method discoverUnManagedCifsShares.

private void discoverUnManagedCifsShares(DataDomainClient ddClient, StorageSystem storageSystem) throws DataDomainApiException {
    storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
    String detailedStatusMessage = "Discovery of Data Domain Unmanaged Cifs Shares started";
    storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
    // Used to cache UMFS once retrieved from DB
    Map<String, UnManagedFileSystem> existingUnManagedFileSystems = new HashMap<String, UnManagedFileSystem>();
    // Used to Save the CIFS ACLs to DB
    List<UnManagedCifsShareACL> newUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
    List<UnManagedCifsShareACL> oldUnManagedCifsACLs = new ArrayList<UnManagedCifsShareACL>();
    try {
        // Get exports on the array and loop through each export.
        DDShareList shareList = ddClient.getShares(storageSystem.getNativeGuid());
        for (DDShareInfo shareInfo : shareList.getShares()) {
            DDShareInfoDetail share = ddClient.getShare(storageSystem.getNativeGuid(), shareInfo.getId());
            if (share.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
                continue;
            }
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), share.getMtreeId());
            // Get UMFS from cache if possible, otherwise try to retrieve from DB
            UnManagedFileSystem unManagedFS = existingUnManagedFileSystems.get(fsUnManagedFsNativeGuid);
            if (unManagedFS == null) {
                unManagedFS = getUnManagedFileSystemFromDB(fsUnManagedFsNativeGuid);
            }
            if (unManagedFS != null) {
                // Add UMFS to cache
                existingUnManagedFileSystems.put(fsUnManagedFsNativeGuid, unManagedFS);
                StringSet storagePortIds = unManagedFS.getFileSystemInformation().get(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
                StoragePort storagePort = null;
                for (String portId : storagePortIds) {
                    StoragePort sp = _dbClient.queryObject(StoragePort.class, URI.create(portId));
                    if (sp != null && !sp.getInactive()) {
                        storagePort = sp;
                        break;
                    }
                }
                associateCifsExportWithFS(unManagedFS, share, storagePort);
                unManagedFS.setHasShares(true);
                unManagedFS.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                _log.debug("Export map for VNX UMFS {} = {}", unManagedFS.getLabel(), unManagedFS.getUnManagedSmbShareMap());
                List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(unManagedFS, share, storagePort);
                _log.info("Number of export rules discovered for file system {} is {}", unManagedFS.getId() + ":" + unManagedFS.getLabel(), cifsACLs.size());
                for (UnManagedCifsShareACL cifsAcl : cifsACLs) {
                    _log.info("Unmanaged File share acls : {}", cifsAcl);
                    String fsShareNativeId = cifsAcl.getFileSystemShareACLIndex();
                    _log.info("UMFS Share ACL index {}", fsShareNativeId);
                    String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
                    _log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
                    cifsAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
                    // Check whether the CIFS share ACL was present in ViPR DB.
                    UnManagedCifsShareACL existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, cifsAcl.getNativeGuid());
                    if (existingACL == null) {
                        newUnManagedCifsACLs.add(cifsAcl);
                    } else {
                        newUnManagedCifsACLs.add(cifsAcl);
                        existingACL.setInactive(true);
                        oldUnManagedCifsACLs.add(existingACL);
                    }
                }
                // Update the UnManaged file system
                _dbClient.persistObject(unManagedFS);
            }
            if (newUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
                // create new UnManagedCifsShareACL
                _log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
                _dbClient.createObject(newUnManagedCifsACLs);
                newUnManagedCifsACLs.clear();
            }
            if (oldUnManagedCifsACLs.size() >= VNXFileConstants.VNX_FILE_BATCH_SIZE) {
                // Update existing UnManagedCifsShareACL
                _log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
                _dbClient.persistObject(oldUnManagedCifsACLs);
                oldUnManagedCifsACLs.clear();
            }
        }
        if (!newUnManagedCifsACLs.isEmpty()) {
            // create new UnManagedCifsShareACL
            _log.info("Saving Number of New UnManagedCifsShareACL(s) {}", newUnManagedCifsACLs.size());
            _dbClient.createObject(newUnManagedCifsACLs);
            newUnManagedCifsACLs.clear();
        }
        if (!oldUnManagedCifsACLs.isEmpty()) {
            // Update existing UnManagedCifsShareACL
            _log.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldUnManagedCifsACLs.size());
            _dbClient.persistObject(oldUnManagedCifsACLs);
            oldUnManagedCifsACLs.clear();
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeded
        detailedStatusMessage = String.format("Discovery completed successfully for Data Domain: %s", storageSystem.getId().toString());
        storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
    } catch (DataDomainApiException dde) {
        _log.error("discoverStorage failed.  Storage system: " + storageSystem.getId());
    } catch (Exception e) {
        _log.error("discoverStorage failed. Storage system: " + storageSystem.getId(), e);
    } finally {
        if (storageSystem != null) {
            try {
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) 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) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) DDShareInfoDetail(com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail) StringSet(com.emc.storageos.db.client.model.StringSet) DDShareList(com.emc.storageos.datadomain.restapi.model.DDShareList) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Example 3 with DDShareInfo

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

the class DataDomainFileStorageDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doShare() - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doShare failed, provider unreachable");
            String op = "FS share create";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        // Check if this is a new share or update of the existing share
        SMBShareMap smbShareMap = args.getFileObjShares();
        SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
        String shareId;
        DDShareInfo ddShareInfo;
        // Cannot send empty description, send the share name in that case
        if (smbFileShare.getDescription() == null || smbFileShare.getDescription().isEmpty()) {
            _log.debug("SMB Share creation was called with empty description and setting name as desc");
            smbFileShare.setDescription(smbFileShare.getName());
        }
        if (existingShare != null) {
            shareId = existingShare.getNativeId();
            // modify share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            DDShareInfoDetail ddShareInfoDetail = ddClient.getShare(storagePool.getNativeId(), shareId);
            if (ddShareInfoDetail.getPathStatus() == 0) {
                DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePool.getNativeId(), shareId);
                throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(ddShareInfoDetail.getPath());
            }
            ddShareInfo = ddClient.modifyShare(storagePool.getNativeId(), shareId, smbFileShare.getDescription());
        } else {
            // new share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            ddCreateShare(ddClient, storagePool.getNativeId(), smbFileShare, smbFileShare.getPath());
        }
        // init file share map
        if (args.getFileObjShares() == null) {
            args.initFileObjShares();
        }
        args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
        _log.info("DataDomainFileStorageDevice doShare() - complete");
        // Set MountPoint
        smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doShare failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) DDShareInfoDetail(com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo)

Aggregations

DDShareInfo (com.emc.storageos.datadomain.restapi.model.DDShareInfo)3 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)2 DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)2 DDShareInfoDetail (com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail)2 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)1 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)1 DDShareList (com.emc.storageos.datadomain.restapi.model.DDShareList)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)1 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1