Search in sources :

Example 1 with BlockMirrorRestRep

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

the class BlockMapper method map.

public static BlockMirrorRestRep map(DbClient dbClient, BlockMirror from) {
    if (from == null) {
        return null;
    }
    BlockMirrorRestRep to = new BlockMirrorRestRep();
    mapBlockObjectFields(from, to);
    if (from.getSource() != null) {
        to.setSource(toNamedRelatedResource(ResourceTypeEnum.VOLUME, from.getSource().getURI(), from.getSource().getName()));
    }
    to.setSyncState(from.getSyncState());
    to.setSyncType(from.getSyncType());
    to.setReplicaState(SynchronizationState.fromState(from.getSyncState()).name());
    to.setVirtualPool(toRelatedResource(ResourceTypeEnum.BLOCK_VPOOL, from.getVirtualPool()));
    if (from.getPool() != null) {
        to.setPool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getPool()));
    }
    return to;
}
Also used : BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep)

Example 2 with BlockMirrorRestRep

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

the class BlockService method getMirror.

/**
 * Show details for a specific continuous copy
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source volume
 * @param mid
 *            Continuous copy URI
 *
 * @brief Show continuous copy
 * @return BlockMirrorRestRep
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/{mid}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockMirrorRestRep getMirror(@PathParam("id") URI id, @PathParam("mid") URI mid) {
    ArgValidator.checkFieldUriType(id, Volume.class, "id");
    boolean vplexVolume = checkIfVolumeIsForVplex(id);
    BlockMirrorRestRep mirrorRestRep = null;
    if (vplexVolume) {
        ArgValidator.checkFieldUriType(mid, VplexMirror.class, "mid");
        VplexMirror mirror = queryVplexMirror(mid);
        if (!mirror.getSource().getURI().equals(id)) {
            throw APIException.badRequests.invalidParameterVolumeMirrorMismatch(mid, id);
        }
        mirrorRestRep = map(mirror);
    } else {
        queryResource(id);
        ArgValidator.checkFieldUriType(mid, BlockMirror.class, "mid");
        BlockMirror mirror = queryMirror(mid);
        if (!mirror.getSource().getURI().equals(id)) {
            throw APIException.badRequests.invalidParameterVolumeMirrorMismatch(mid, id);
        }
        mirrorRestRep = map(_dbClient, mirror);
    }
    return mirrorRestRep;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) 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)

Example 3 with BlockMirrorRestRep

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

the class BlockProvider method getExportedBlockContinuousCopyByVolume.

@Asset("exportedBlockContinuousCopy")
@AssetDependencies({ "project", "volumeWithContinuousCopies" })
public List<AssetOption> getExportedBlockContinuousCopyByVolume(AssetOptionsContext ctx, URI project, URI volume) {
    debug("getting exported blockContinuousCopy (project=%s) (parent=%s)", project, volume);
    final ViPRCoreClient client = api(ctx);
    Set<URI> exportedMirrors = new HashSet<URI>();
    for (ExportGroupRestRep export : client.blockExports().findByProject(project)) {
        for (ExportBlockParam resource : export.getVolumes()) {
            if (ResourceType.isType(ResourceType.BLOCK_CONTINUOUS_COPY, resource.getId())) {
                exportedMirrors.add(resource.getId());
            }
        }
    }
    ExportedBlockResourceFilter<BlockMirrorRestRep> exportedMirrorFilter = new ExportedBlockResourceFilter<BlockMirrorRestRep>(exportedMirrors);
    List<BlockMirrorRestRep> mirrors = client.blockVolumes().getContinuousCopies(volume, exportedMirrorFilter);
    return createVolumeOptions(client, mirrors);
}
Also used : ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) URI(java.net.URI) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with BlockMirrorRestRep

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

the class BlockProvider method constructCopiesOptions.

protected List<AssetOption> constructCopiesOptions(ViPRCoreClient client, URI project, List<BlockMirrorRestRep> copies) {
    List<AssetOption> options = Lists.newArrayList();
    for (BlockMirrorRestRep copy : copies) {
        options.add(new AssetOption(copy.getId(), getBlockObjectLabel(client, copy, null)));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep)

Example 5 with BlockMirrorRestRep

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

the class BlockStorageUtils method isVMAXUsePortGroupEnabled.

public static boolean isVMAXUsePortGroupEnabled(URI resourceId) {
    SimpleValueRep value = execute(new GetVMAXUsePortGroupEnabledConfig());
    if (value.getValue().equalsIgnoreCase("true")) {
        if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
            BlockObjectRestRep obj = getVolume(resourceId);
            if (obj instanceof VolumeRestRep) {
                VolumeRestRep volume = (VolumeRestRep) obj;
                boolean isVMAX = StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
                boolean isRPOrVPlex = isVplexOrRPVolume(volume);
                if (isVMAX && !isRPOrVPlex) {
                    return true;
                }
            }
            if (obj instanceof BlockSnapshotRestRep) {
                BlockSnapshotRestRep snapshot = (BlockSnapshotRestRep) obj;
                BlockObjectRestRep parent = getVolume(snapshot.getParent().getId());
                if (parent instanceof VolumeRestRep) {
                    VolumeRestRep volume = (VolumeRestRep) obj;
                    if (StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                        return true;
                    }
                }
                if (parent instanceof BlockMirrorRestRep) {
                    BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
                    if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                        return true;
                    }
                }
            }
            if (obj instanceof BlockMirrorRestRep) {
                BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
                if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
                    return true;
                }
            }
        }
        if (ResourceType.isType(ResourceType.VIRTUAL_POOL, resourceId)) {
            BlockVirtualPoolRestRep virtualPool = execute(new GetBlockVirtualPool(resourceId));
            boolean isVMAX = StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
            boolean isVPLEX = virtualPool.getHighAvailability() != null;
            if (isVMAX && !isVPLEX) {
                return true;
            }
        }
    }
    return false;
}
Also used : SimpleValueRep(com.emc.storageos.model.customconfig.SimpleValueRep) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) GetBlockVirtualPool(com.emc.sa.service.vipr.block.tasks.GetBlockVirtualPool) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) GetVMAXUsePortGroupEnabledConfig(com.emc.sa.service.vipr.block.tasks.GetVMAXUsePortGroupEnabledConfig) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Aggregations

BlockMirrorRestRep (com.emc.storageos.model.block.BlockMirrorRestRep)9 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)4 URI (java.net.URI)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)2 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 HashSet (java.util.HashSet)2 GetActiveContinuousCopiesForVolume (com.emc.sa.service.vipr.block.tasks.GetActiveContinuousCopiesForVolume)1 GetBlockVirtualPool (com.emc.sa.service.vipr.block.tasks.GetBlockVirtualPool)1 GetVMAXUsePortGroupEnabledConfig (com.emc.sa.service.vipr.block.tasks.GetVMAXUsePortGroupEnabledConfig)1 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 VplexMirror (com.emc.storageos.db.client.model.VplexMirror)1 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)1 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)1 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)1 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)1