Search in sources :

Example 26 with SMBShareMap

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

the class DataDomainFileStorageDevice method doDeleteShares.

@Override
public BiosCommandResult doDeleteShares(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doDeleteShares: {} - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doDeleteShares failed, provider unreachable");
            String op = "FS shares 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.addAll(currentShares.values());
        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 27 with SMBShareMap

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

the class IsilonFileStorageDevice method isiShare.

/**
 * Create/modify Isilon SMB share.
 *
 * @param isi
 * @param args
 * @param smbFileShare
 * @throws IsilonException
 */
private void isiShare(IsilonApi isi, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws IsilonException {
    IsilonSMBShare isilonSMBShare = new IsilonSMBShare(smbFileShare.getName(), smbFileShare.getPath(), smbFileShare.getDescription());
    // 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;
    String zoneName = getZoneName(args.getvNAS());
    if (existingShare != null) {
        shareId = existingShare.getNativeId();
        // modify share
        if (zoneName != null) {
            isi.modifyShare(shareId, zoneName, isilonSMBShare);
        } else {
            isi.modifyShare(shareId, isilonSMBShare);
        }
    } else {
        /**
         * inheritablePathAcl - true: Apply Windows Default ACLs false: Do
         * not change existing permissions.
         */
        boolean inheritablePathAcl = true;
        if (configinfo != null && configinfo.containsKey("inheritablePathAcl")) {
            inheritablePathAcl = Boolean.parseBoolean(configinfo.get("inheritablePathAcl"));
            isilonSMBShare.setInheritablePathAcl(inheritablePathAcl);
        }
        // new share
        if (zoneName != null) {
            _log.debug("Share will be created in zone: {}", zoneName);
            shareId = isi.createShare(isilonSMBShare, zoneName);
        } else {
            shareId = isi.createShare(isilonSMBShare);
        }
    }
    smbFileShare.setNativeId(shareId);
    // Set Mount Point
    smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
    // int file share map
    if (args.getFileObjShares() == null) {
        args.initFileObjShares();
    }
    args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 28 with SMBShareMap

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

the class IsilonFileStorageDevice method isiDeleteShares.

private void isiDeleteShares(IsilonApi isi, FileDeviceInputOutput args) throws IsilonException {
    _log.info("IsilonFileStorageDevice:isiDeleteShares()");
    SMBShareMap currentShares = null;
    if (args.getFileOperation()) {
        FileShare fileObj = args.getFs();
        if (fileObj != null) {
            currentShares = fileObj.getSMBFileShares();
        }
    } else {
        Snapshot snap = args.getFileSnapshot();
        if (snap != null) {
            currentShares = snap.getSMBFileShares();
        }
    }
    if (currentShares == null || currentShares.isEmpty()) {
        return;
    }
    Set<String> deletedShares = new HashSet<String>();
    Iterator<Map.Entry<String, SMBFileShare>> it = currentShares.entrySet().iterator();
    String zoneName = getZoneName(args.getvNAS());
    try {
        while (it.hasNext()) {
            Map.Entry<String, SMBFileShare> entry = it.next();
            String key = entry.getKey();
            SMBFileShare smbFileShare = entry.getValue();
            _log.info("delete the share name {} and native id {}", smbFileShare.getName(), smbFileShare.getNativeId());
            if (zoneName != null) {
                isi.deleteShare(smbFileShare.getNativeId(), zoneName);
            } else {
                isi.deleteShare(smbFileShare.getNativeId());
            }
            // Safe removal from the backing map. Can not do this through
            // iterator since this does not track changes and is not
            // reflected in the database.
            deletedShares.add(key);
        }
    } finally {
        // remove shares from the map in database.
        for (String key : deletedShares) {
            currentShares.remove(key);
        }
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) Map(java.util.Map) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap) CifsServerMap(com.emc.storageos.db.client.model.CifsServerMap) HashSet(java.util.HashSet)

Example 29 with SMBShareMap

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

the class NetAppFileStorageDevice method doShare.

/**
 * Creates FileShare CIFS/SMB shares
 *
 * @param StorageSystem storage
 * @param SMBFileShare smbFileShare
 * @return BiosCommandResult
 * @throws ControllerException
 */
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    // To be in-sync with isilon implementation, currently forceGroup is
    // set to null which will set the group name as "everyone" by default.
    String forceGroup = null;
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doShare - start");
        SMBShareMap smbShareMap = args.getFileObjShares();
        SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
        Boolean modOrCreateShareSuccess;
        if (existingShare != null) {
            modOrCreateShareSuccess = modifyNtpShare(storage, args, smbFileShare, forceGroup, existingShare);
        } else {
            modOrCreateShareSuccess = createNtpShare(storage, args, smbFileShare, forceGroup);
        }
        if (modOrCreateShareSuccess.booleanValue() == true) {
            _log.info("NetAppFileStorageDevice doShare {} - complete", smbFileShare.getName());
            // Update the collection.
            if (args.getFileObjShares() == null) {
                args.initFileObjShares();
            }
            // set Mount Point
            smbFileShare.setMountPoint(smbFileShare.getNetBIOSName(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
            args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
            result = BiosCommandResult.createSuccessfulResult();
        } else {
            _log.error("NetAppFileStorageDevice doShare {} - failed", smbFileShare.getName());
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
            result = BiosCommandResult.createErrorResult(serviceError);
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doShare failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doShare failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 30 with SMBShareMap

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

the class FileDeviceInputOutput method isFileShareMounted.

public boolean isFileShareMounted() {
    FSExportMap exports = getFs().getFsExports();
    SMBShareMap shares = getFs().getSMBFileShares();
    boolean isMounted = true;
    if ((exports == null || (exports != null && exports.isEmpty())) && (shares == null || (shares != null && shares.isEmpty()))) {
        isMounted = false;
    }
    return isMounted;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Aggregations

SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)39 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)31 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)16 ArrayList (java.util.ArrayList)15 FileShare (com.emc.storageos.db.client.model.FileShare)14 URI (java.net.URI)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 ControllerException (com.emc.storageos.volumecontroller.ControllerException)11 Snapshot (com.emc.storageos.db.client.model.Snapshot)10 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)8 WorkflowException (com.emc.storageos.workflow.WorkflowException)6 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)5 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)4 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)4 FileObject (com.emc.storageos.db.client.model.FileObject)4 NetAppException (com.emc.storageos.netapp.NetAppException)4 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)3 FileExport (com.emc.storageos.db.client.model.FileExport)3 Operation (com.emc.storageos.db.client.model.Operation)3