Search in sources :

Example 6 with SMBShareMap

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

the class FileService method getFileSystemShareList.

/**
 * Get list of SMB shares for the specified file system.
 *
 * @param id
 *            the URN of a ViPR File system
 * @brief List file system SMB shares
 * @return List of file system shares.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public FileSystemShareList getFileSystemShareList(@PathParam("id") URI id) {
    _log.info(String.format("Get list of SMB file shares for file system: %1$s", id));
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fileShare = queryResource(id);
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    if (fileShare.getInactive()) {
        return fileShareListResponse;
    }
    SMBShareMap smbShareMap = fileShare.getSMBFileShares();
    Collection<SMBFileShare> smbShares = new ArrayList<SMBFileShare>();
    if (smbShareMap != null) {
        smbShares = smbShareMap.values();
    }
    // Process each share from the map and add its data to shares in response list.
    for (SMBFileShare smbShare : smbShares) {
        SmbShareResponse 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());
        fileShareListResponse.getShareList().add(shareParam);
    }
    return fileShareListResponse;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileSystemShareList(com.emc.storageos.model.file.FileSystemShareList) ArrayList(java.util.ArrayList) 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 SMBShareMap

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

the class FileService method failoverProtection.

/**
 * Request to failover the protection link associated with the param.copyID.
 *
 * NOTE: This is an asynchronous operation.
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source fileshare
 * @param param
 *            FileReplicationParam to failover to
 *
 * @brief Failover the fileShare protection link
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@PathParam("id") URI id, FileReplicationParam param) throws ControllerException {
    doMirrorOperationValidation(id, ProtectionOp.FAILOVER.toString());
    TaskResourceRep taskResp = null;
    StoragePort storageportNFS = null;
    StoragePort storageportCIFS = null;
    TaskList taskList = new TaskList();
    String task = UUID.randomUUID().toString();
    FileShare fs = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, id, task, ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER);
    op.setDescription("failover source file system to target system");
    boolean replicateConfiguration = param.isReplicateConfiguration();
    if (replicateConfiguration) {
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(fs.getMirrorfsTargets());
        FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        SMBShareMap smbShareMap = fs.getSMBFileShares();
        if (smbShareMap != null) {
            storageportCIFS = _fileScheduler.placeFileShareExport(targetFileShare, StorageProtocol.File.CIFS.name(), null);
        }
        FSExportMap nfsExportMap = fs.getFsExports();
        if (nfsExportMap != null) {
            storageportNFS = _fileScheduler.placeFileShareExport(targetFileShare, StorageProtocol.File.NFS.name(), null);
        }
    }
    FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
    try {
        fileServiceApi.failoverFileShare(id, storageportNFS, storageportCIFS, replicateConfiguration, task);
    } catch (InternalException e) {
        if (_log.isErrorEnabled()) {
            _log.error("", e);
        }
        FileShare fileShare = _dbClient.queryObject(FileShare.class, fs.getId());
        op = fs.getOpStatus().get(task);
        op.error(e);
        fileShare.getOpStatus().updateTaskStatus(task, op);
        _dbClient.updateObject(fs);
        throw e;
    }
    taskResp = toTask(fs, task, op);
    taskList.getTaskList().add(taskResp);
    return taskList;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) TaskList(com.emc.storageos.model.TaskList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with SMBShareMap

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

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

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

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