Search in sources :

Example 6 with SMBFileShare

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

the class FileService method getFileSystemShare.

/**
 * Get the SMB share for the specified file system.
 *
 * @param id
 *            the URN of a ViPR File system
 * @param shareName
 *            file system share name
 * @brief Show specified share
 * @return List of file system shares.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public SmbShareResponse getFileSystemShare(@PathParam("id") URI id, @PathParam("shareName") String shareName) throws InternalException {
    _log.info(String.format("Get SMB file share %s for file system: %s", shareName, id.toString()));
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    FileShare fileShare = queryResource(id);
    SMBFileShare smbShare = null;
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    SmbShareResponse shareParam = null;
    if (fileShare.getSMBFileShares() != null) {
        _log.info("Number of SMBShares found {} and looking for share to read {} ", fileShare.getSMBFileShares().size(), shareName);
        _log.info(String.format("Get file system share: file system id: %1$s, share name %2$s", id, shareName));
        smbShare = fileShare.getSMBFileShares().get(shareName);
        if (smbShare == null) {
            _log.info("CIFS share does not exist {}", shareName);
        } else {
            shareParam = new SmbShareResponse();
            shareParam.setShareName(smbShare.getName());
            shareParam.setDescription(smbShare.getDescription());
            shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
            // Check for "unlimited"
            if (shareParam.getMaxUsers().equals("-1")) {
                shareParam.setMaxUsers(UNLIMITED_USERS);
            }
            shareParam.setPermissionType(smbShare.getPermissionType());
            shareParam.setPermission(smbShare.getPermission());
            shareParam.setMountPoint(smbShare.getMountPoint());
            shareParam.setPath(smbShare.getPath());
        }
    }
    return shareParam;
}
Also used : FileSystemShareList(com.emc.storageos.model.file.FileSystemShareList) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with SMBFileShare

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

the class FileQuotaDirectoryService method quotaDirectoryHasExportsOrShares.

/**
 * This method verifies the file system quota directory has any exports or shares
 *
 * @param fs - file system on which the QD present
 * @param quotaName - name of the QD
 * @return true - if there are any exports or shares, false otherwise.
 */
private boolean quotaDirectoryHasExportsOrShares(FileShare fs, String quotaName) {
    FSExportMap fsExportMap = fs.getFsExports();
    // Verify for NFS exports on quota directory
    if (fsExportMap != null && !fsExportMap.isEmpty()) {
        // check the quota directory is exported
        for (FileExport fileExport : fsExportMap.values()) {
            if (quotaName.equals(fileExport.getSubDirectory()) && fileExport.getPath().endsWith(quotaName)) {
                _log.info("quota directory {} on fs {} has NFS exports", quotaName, fs.getLabel());
                return true;
            }
        }
    }
    // Verify for CIFS shares on quota directory
    SMBShareMap smbShareMap = fs.getSMBFileShares();
    if (smbShareMap != null && !smbShareMap.isEmpty()) {
        for (SMBFileShare smbFileShare : smbShareMap.values()) {
            // check for quota name in native fs path
            if (smbFileShare.getPath().endsWith("/" + quotaName)) {
                _log.info("quota directory {} on fs {} has CIFS shares", quotaName, fs.getLabel());
                return true;
            }
        }
    }
    return false;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileExport(com.emc.storageos.db.client.model.FileExport) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Example 8 with SMBFileShare

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

the class PropertySetterUtil method convertUnManagedSMBMapToManaged.

/**
 * Extract SMB data from UnManaged to Managed
 *
 * @param unManagedSMBShareMap
 * @return
 */
public static SMBShareMap convertUnManagedSMBMapToManaged(UnManagedSMBShareMap unManagedSMBShareMap, StoragePort storagePort, StorageHADomain dataMover) {
    SMBShareMap smbShareMap = new SMBShareMap();
    if (unManagedSMBShareMap == null) {
        return smbShareMap;
    }
    SMBFileShare smbshare = null;
    for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBShareMap.values()) {
        smbshare = new SMBFileShare();
        smbshare.setName(unManagedSMBFileShare.getName());
        smbshare.setNativeId(unManagedSMBFileShare.getNativeId());
        smbshare.setDescription(unManagedSMBFileShare.getDescription());
        if (storagePort != null) {
            smbshare.setMountPoint("\\\\" + storagePort.getPortNetworkId() + "\\" + unManagedSMBFileShare.getName());
        } else {
            smbshare.setMountPoint(unManagedSMBFileShare.getMountPoint());
        }
        smbshare.setPath(unManagedSMBFileShare.getPath());
        // need to removed
        smbshare.setMaxUsers(unManagedSMBFileShare.getMaxUsers());
        smbshare.setPermission(unManagedSMBFileShare.getPermission());
        smbshare.setPermissionType(unManagedSMBFileShare.getPermissionType());
        smbshare.setPortGroup(storagePort.getPortGroup());
        // share name
        smbShareMap.put(unManagedSMBFileShare.getName(), smbshare);
    }
    return smbShareMap;
}
Also used : UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)

Example 9 with SMBFileShare

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

the class IsilonFileStorageDevice method isiDeleteShare.

private void isiDeleteShare(IsilonApi isi, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws IsilonException {
    SMBShareMap currentShares = args.getFileObjShares();
    // Do nothing if there are no shares
    if (currentShares == null || smbFileShare == null) {
        return;
    }
    SMBFileShare fileShare = currentShares.get(smbFileShare.getName());
    if (fileShare != null) {
        String nativeId = fileShare.getNativeId();
        String zoneName = getZoneName(args.getvNAS());
        _log.info("delete the share {} with native id {}", smbFileShare.getName(), nativeId);
        if (zoneName != null) {
            isi.deleteShare(nativeId, zoneName);
        } else {
            isi.deleteShare(nativeId);
        }
        currentShares.remove(smbFileShare.getName());
    }
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 10 with SMBFileShare

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

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