Search in sources :

Example 1 with MirrorList

use of com.emc.storageos.model.block.MirrorList in project coprhd-controller by CoprHD.

the class FileService method getNativeContinuousCopies.

/**
 * List FileShare mirrors
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR FileShare to list mirrors
 *
 * @brief List fileShare mirrors
 * @return FileShare mirror response containing a list of mirror identifiers
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public MirrorList getNativeContinuousCopies(@PathParam("id") URI id) {
    MirrorList list = new MirrorList();
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare sourceFileShare = _dbClient.queryObject(FileShare.class, id);
    StringSet sourceFileShareMirrors = sourceFileShare.getMirrorfsTargets();
    if (sourceFileShareMirrors == null || sourceFileShareMirrors.isEmpty()) {
        return list;
    }
    for (String uriStr : sourceFileShareMirrors) {
        FileShare fileMirror = _dbClient.queryObject(FileShare.class, URI.create(uriStr));
        if (fileMirror == null || fileMirror.getInactive()) {
            _log.warn("Stale mirror {} found for fileShare {}", uriStr, sourceFileShare.getId());
            continue;
        }
        list.getMirrorList().add(toNamedRelatedResource(fileMirror));
    }
    return list;
}
Also used : MirrorList(com.emc.storageos.model.block.MirrorList) StringSet(com.emc.storageos.db.client.model.StringSet) 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 2 with MirrorList

use of com.emc.storageos.model.block.MirrorList in project coprhd-controller by CoprHD.

the class BlockService method getNativeContinuousCopies.

/**
 * List volume mirrors
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Volume to list mirrors
 *
 * @brief List volume mirrors
 * @return Volume mirror response containing a list of mirror identifiers
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public MirrorList getNativeContinuousCopies(@PathParam("id") URI id) {
    MirrorList list = new MirrorList();
    ArgValidator.checkFieldUriType(id, Volume.class, "id");
    Volume sourceVolume = queryVolumeResource(id);
    boolean vplexVolume = checkIfVolumeIsForVplex(id);
    StringSet sourceVolumeMirrors = sourceVolume.getMirrors();
    if (sourceVolumeMirrors == null || sourceVolumeMirrors.isEmpty()) {
        return list;
    }
    for (String uriStr : sourceVolumeMirrors) {
        if (vplexVolume) {
            VplexMirror vplexMirror = _dbClient.queryObject(VplexMirror.class, URI.create(uriStr));
            if (vplexMirror == null || vplexMirror.getInactive()) {
                _log.warn("Stale mirror {} found for volume {}", uriStr, sourceVolume.getId());
                continue;
            }
            list.getMirrorList().add(toNamedRelatedResource(vplexMirror));
        } else {
            BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, URI.create(uriStr));
            if (blockMirror == null || blockMirror.getInactive()) {
                _log.warn("Stale mirror {} found for volume {}", uriStr, sourceVolume.getId());
                continue;
            }
            list.getMirrorList().add(toNamedRelatedResource(blockMirror));
        }
    }
    return list;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) MirrorList(com.emc.storageos.model.block.MirrorList) MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)2 MirrorList (com.emc.storageos.model.block.MirrorList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)1 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)1 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 Volume (com.emc.storageos.db.client.model.Volume)1 VplexMirror (com.emc.storageos.db.client.model.VplexMirror)1 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)1