Search in sources :

Example 31 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 32 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 33 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 34 with SMBFileShare

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

the class FileSMBShare method getSMBFileShare.

public SMBFileShare getSMBFileShare() {
    SMBFileShare smbShare = new SMBFileShare(_name, _description, _permissionType.toString(), _permission.toString(), _maxUsers, _mountPoint);
    smbShare.setNativeId(_nativeId);
    smbShare.setPortGroup(_storagePortGroup);
    smbShare.setPath(_path);
    smbShare.setSubDir(_isSubDirPath);
    smbShare.setStoragePortName(_storagePortName);
    smbShare.setStoragePortNetworkId(_storagePortNetworkId);
    smbShare.setNetBIOSName(_NetBIOSName);
    return smbShare;
}
Also used : SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 35 with SMBFileShare

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

the class VNXFileCommApi method deleteAllExportsAndShares.

private XMLApiResult deleteAllExportsAndShares(StorageSystem system, StorageHADomain dataMover, FileShare fs, Snapshot snapshot) {
    FSExportMap exports;
    SMBShareMap shares;
    XMLApiResult result = new XMLApiResult();
    result.setCommandSuccess();
    String fileId = fs.getId().toString();
    FileObject fObj = fs;
    _log.info("deleteAllExportsAndShares for {} {}", fs.getName(), snapshot);
    boolean fileOperation = false;
    if (snapshot == null) {
        // FileShare operation
        _log.info("deleteAllExportsAndShares FileShare delete operation");
        exports = fs.getFsExports();
        shares = fs.getSMBFileShares();
        fileOperation = true;
        fObj = fs;
    } else {
        _log.info("deleteAllExportsAndShares Snapshot delete operation");
        exports = snapshot.getFsExports();
        shares = snapshot.getSMBFileShares();
        fObj = snapshot;
        fileId = snapshot.getId().toString();
    }
    int exportsToUnExport = 0;
    Set<String> keys = new HashSet();
    if (exports != null) {
        exportsToUnExport = exports.size();
        keys = exports.keySet();
    }
    int noOfShares = 0;
    if (shares != null) {
        noOfShares = shares.size();
    }
    _log.info("Number of NFS exports {}  SMB Shares found {} for File/Snapshot Id {}", new Object[] { exportsToUnExport, noOfShares, fileId });
    // To avoid concurrent modification exceptions
    Set<String> exportKeys = new HashSet();
    exportKeys.addAll(keys);
    FileDeviceInputOutput args = new FileDeviceInputOutput();
    args.setFileOperation(fileOperation);
    args.addFSFileObject(fs);
    if (fileOperation) {
        args.setFileOperation(true);
        args.addFSFileObject(fs);
    } else {
        args.setFileOperation(false);
        args.addFSFileObject(fs);
        args.addSnapshot(snapshot);
    }
    for (String key : exportKeys) {
        FileExport exp = exports.get(key);
        VNXFileExport fileExport = new VNXFileExport(exp.getClients(), exp.getStoragePortName(), exp.getPath(), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getSubDirectory(), exp.getComments());
        fileExport.setStoragePort(fs.getStoragePort().toString());
        boolean deleteMount = false;
        if (exportsToUnExport == 1 && noOfShares == 0 && fileOperation) {
            deleteMount = true;
        }
        XMLApiResult status = doUnexport(system, fileExport, args, deleteMount);
        if (!status.isCommandSuccess()) {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
            return result;
        } else {
            fObj.getFsExports().remove(key);
            _log.info("Export removed : " + key);
            exportsToUnExport--;
        }
        // Persist the object after exports removed
        _dbClient.persistObject(fObj);
    }
    // Now Let Handle SMB/CIFS Shares
    keys = new HashSet<>();
    int noOfSharesToDelete = 0;
    if (shares != null) {
        keys = shares.keySet();
        noOfSharesToDelete = keys.size();
    }
    int noOfExports = 0;
    if (exports != null) {
        noOfExports = exports.size();
    }
    _log.info("Number of CIFS/SMB Shares {}  NFS Exports found {} for File/Snapshot Id {}", new Object[] { noOfSharesToDelete, noOfExports, fileId });
    // To avoid concurrent modification exceptions
    Set<String> shareKeys = new HashSet();
    shareKeys.addAll(keys);
    for (String key : shareKeys) {
        SMBFileShare share = shares.get(key);
        _log.info("Delete SMB/CIFS Share {} from FS/Snapshot {}", share.getName(), fileId);
        boolean deleteMount = false;
        if (noOfSharesToDelete == 1 && noOfExports == 0 && fileOperation) {
            deleteMount = true;
        }
        XMLApiResult status = doDeleteShare(system, dataMover, share.getName(), fs.getMountPath(), deleteMount, args);
        if (!status.isCommandSuccess()) {
            _log.info("SMBFileShare deletion failed key {} : {} ", key, share.getName());
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
            return result;
        } else {
            fObj.getSMBFileShares().remove(key);
            _log.info("SMBFileShare removed : " + key);
            noOfSharesToDelete--;
        }
        // Persist the object after SMBShares removed
        _dbClient.persistObject(fObj);
    }
    return result;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) FileExport(com.emc.storageos.db.client.model.FileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) FileObject(com.emc.storageos.db.client.model.FileObject) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) HashSet(java.util.HashSet)

Aggregations

SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)46 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)26 FileShare (com.emc.storageos.db.client.model.FileShare)21 Snapshot (com.emc.storageos.db.client.model.Snapshot)16 ArrayList (java.util.ArrayList)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)9 URI (java.net.URI)9 FileExport (com.emc.storageos.db.client.model.FileExport)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 VNXeException (com.emc.storageos.vnxe.VNXeException)8 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)7 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)7 FileObject (com.emc.storageos.db.client.model.FileObject)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5