Search in sources :

Example 1 with ProtectionSetRestRep

use of com.emc.storageos.model.protection.ProtectionSetRestRep in project coprhd-controller by CoprHD.

the class ProtectionMapper method map.

public static ProtectionSetRestRep map(ProtectionSet from) {
    if (from == null) {
        return null;
    }
    ProtectionSetRestRep to = new ProtectionSetRestRep();
    mapDataObjectFields(from, to);
    to.setProtectionSystem(toRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, from.getProtectionSystem()));
    to.setProtectionId(from.getProtectionId());
    if (from.getVolumes() != null) {
        for (String volume : from.getVolumes()) {
            to.getVolumes().add(toRelatedResource(ResourceTypeEnum.VOLUME, URI.create(volume)));
        }
    }
    to.setProtectionStatus(from.getProtectionStatus());
    to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject()));
    to.setNativeGuid(from.getNativeGuid());
    return to;
}
Also used : ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep)

Example 2 with ProtectionSetRestRep

use of com.emc.storageos.model.protection.ProtectionSetRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getBlockJournalSize.

@Asset("blockJournalSize")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getBlockJournalSize(AssetOptionsContext ctx, URI consistencyGroup) {
    String minimumSize = null;
    BlockConsistencyGroupRestRep cg = api(ctx).blockConsistencyGroups().get(consistencyGroup);
    // Get the first volume in the consistency group.  All volumes will be source volumes
    RelatedResourceRep vol = cg.getVolumes().get(0);
    VolumeRestRep volume = api(ctx).blockVolumes().get(vol);
    if (volume.getProtection() != null && volume.getProtection().getRpRep() != null && volume.getProtection().getRpRep().getProtectionSet() != null) {
        RelatedResourceRep protectionSetId = volume.getProtection().getRpRep().getProtectionSet();
        ProtectionSetRestRep protectionSet = api(ctx).blockVolumes().getProtectionSet(volume.getId(), protectionSetId.getId());
        List<URI> protectionSetVolumeIds = new ArrayList<URI>();
        for (RelatedResourceRep protectionVolume : protectionSet.getVolumes()) {
            protectionSetVolumeIds.add(protectionVolume.getId());
        }
        List<VolumeRestRep> protectionSetVolumes = api(ctx).blockVolumes().withInternal(true).getByIds(protectionSetVolumeIds, null);
        for (VolumeRestRep protectionVolume : protectionSetVolumes) {
            if (protectionVolume.getProtection().getRpRep().getPersonality().equalsIgnoreCase("METADATA")) {
                String capacity = protectionVolume.getCapacity();
                if (minimumSize == null || Float.parseFloat(capacity) < Float.parseFloat(minimumSize)) {
                    minimumSize = capacity;
                }
            }
        }
    }
    if (minimumSize == null) {
        return Lists.newArrayList();
    } else {
        return Lists.newArrayList(newAssetOption(minimumSize, minimumSize));
    }
}
Also used : BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep) ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with ProtectionSetRestRep

use of com.emc.storageos.model.protection.ProtectionSetRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getRpFailoverTargets.

protected List<AssetOption> getRpFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
    URI protectionSetId = volume.getProtection().getRpRep().getProtectionSet().getId();
    ProtectionSetRestRep localProtectionSet = client.blockVolumes().getProtectionSet(volume.getId(), protectionSetId);
    String sourceSiteName = volume.getProtection().getRpRep().getInternalSiteName();
    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
    List<RelatedResourceRep> rpTargets = localProtectionSet.getVolumes();
    for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(rpTargets, RecoverPointPersonalityFilter.TARGET)) {
        String targetSiteName = protectionSetVolume.getProtection().getRpRep().getInternalSiteName();
        boolean isLocal = StringUtils.equals(sourceSiteName, targetSiteName);
        String rpType = isLocal ? "local" : "remote";
        VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
        String label = getMessage("recoverpoint.target", name(protectionSetVolume), rpType, name(virtualArray));
        targetVolumes.put(stringId(protectionSetVolume), label);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
        options.add(new AssetOption(entry.getKey(), entry.getValue()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) CachedResources(com.emc.vipr.client.core.util.CachedResources) ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ProtectionSetRestRep (com.emc.storageos.model.protection.ProtectionSetRestRep)3 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)2 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 URI (java.net.URI)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 CachedResources (com.emc.vipr.client.core.util.CachedResources)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1