Search in sources :

Example 6 with SmbShareResponse

use of com.emc.storageos.model.file.SmbShareResponse in project coprhd-controller by CoprHD.

the class FileProvider method getFileShares.

@Asset("fileShares")
@AssetDependencies("fileFilesystem")
public List<AssetOption> getFileShares(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (SmbShareResponse share : listFileShares(ctx, fileFilesystem)) {
        String label = String.format("%s [%s]", share.getShareName(), share.getMountPoint());
        options.add(new AssetOption(share.getShareName(), label));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with SmbShareResponse

use of com.emc.storageos.model.file.SmbShareResponse in project coprhd-controller by CoprHD.

the class FileProvider method getNFSFileShares.

@Asset("fileShares")
@AssetDependencies("fileNFSFilesystem")
public List<AssetOption> getNFSFileShares(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (SmbShareResponse share : listFileShares(ctx, fileFilesystem)) {
        String label = String.format("%s [%s]", share.getShareName(), share.getMountPoint());
        options.add(new AssetOption(share.getShareName(), label));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 8 with SmbShareResponse

use of com.emc.storageos.model.file.SmbShareResponse in project coprhd-controller by CoprHD.

the class FileProvider method getCIFSFileShares.

@Asset("fileShares")
@AssetDependencies("fileCIFSFilesystem")
public List<AssetOption> getCIFSFileShares(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (SmbShareResponse share : listFileShares(ctx, fileFilesystem)) {
        String label = String.format("%s [%s]", share.getShareName(), share.getMountPoint());
        options.add(new AssetOption(share.getShareName(), label));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 9 with SmbShareResponse

use of com.emc.storageos.model.file.SmbShareResponse in project coprhd-controller by CoprHD.

the class FileSnapshotService method getFileSystemShareList.

/**
 * Lists all SMB shares for the specified snapshot.
 *
 * @param id
 *            the URN of a ViPR Snapshot
 * @brief List file snapshot SMB shares
 * @return List of SMB 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 snapshot: %1$s", id));
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    Snapshot snap = queryResource(id);
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    if (snap.getInactive()) {
        return fileShareListResponse;
    }
    // Get SMB share map from snapshot
    SMBShareMap smbShareMap = snap.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(FileService.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 : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) 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) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

SmbShareResponse (com.emc.storageos.model.file.SmbShareResponse)9 Asset (com.emc.sa.asset.annotation.Asset)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 FileSystemShareList (com.emc.storageos.model.file.FileSystemShareList)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ArrayList (java.util.ArrayList)2 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)1 Snapshot (com.emc.storageos.db.client.model.Snapshot)1