Search in sources :

Example 1 with VirtualArrayRelatedResourceRep

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

the class FileSystems method fileSystemMirrors.

public static void fileSystemMirrors(String fileSystemId) {
    URI id = uri(fileSystemId);
    ViPRCoreClient client = BourneUtil.getViprClient();
    FileProtectionRestRep targetFileSystems = client.fileSystems().get(id).getProtection();
    List<FileShareRestRep> fileMirrors = new ArrayList<FileShareRestRep>();
    for (VirtualArrayRelatedResourceRep virtualResource : targetFileSystems.getTargetFileSystems()) {
        fileMirrors.add(client.fileSystems().get(virtualResource.getId()));
    }
    String personality = targetFileSystems.getPersonality();
    // The code will be refactored once 1:n or cascaded FS replication is supported
    if (!fileMirrors.isEmpty()) {
        FileShareRestRep fsRestRep = fileMirrors.get(0);
        fsRestRep.getProtection().setMirrorStatus(targetFileSystems.getMirrorStatus());
    }
    // Verify the replication is at fs level or not
    boolean replicationAtFs = false;
    FileShareRestRep fs = client.fileSystems().get(id);
    if (fs != null) {
        FilePolicyRestRep replicationPolicy = getReplicationPolicy(client, fs);
        if (replicationPolicy != null) {
            if (FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(replicationPolicy.getAppliedAt())) {
                replicationAtFs = true;
            }
            renderArgs.put("replicationPolicy", replicationPolicy);
        }
        renderArgs.put("replicationAtFsLevel", replicationAtFs);
    }
    renderArgs.put("personality", personality);
    renderArgs.put("fileMirrors", fileMirrors);
    renderArgs.put("fileSystemId", fileSystemId);
    render();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep)

Example 2 with VirtualArrayRelatedResourceRep

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

the class FileProvider method getFailoverFileTarget.

@Asset("failoverFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailoverFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
    if (protectedFileSystem != null) {
        ViPRCoreClient client = api(ctx);
        List<AssetOption> options = Lists.newArrayList();
        debug("getting failoverFileTargets (protectedFileSystem=%s)", protectedFileSystem);
        FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
        FileProtectionRestRep protection = file.getProtection();
        if (protection != null) {
            List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
            for (VirtualArrayRelatedResourceRep target : targets) {
                FileShareRestRep fileshare = client.fileSystems().get(target.getId());
                options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
            }
        }
        AssetOptionsUtils.sortOptionsByLabel(options);
        return options;
    }
    return Lists.newArrayList();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with VirtualArrayRelatedResourceRep

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

the class FileProvider method getFailbackFileTarget.

@Asset("failbackFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailbackFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
    if (protectedFileSystem != null) {
        ViPRCoreClient client = api(ctx);
        List<AssetOption> options = Lists.newArrayList();
        debug("getting failbackFileTargets (protectedFileSystem=%s)", protectedFileSystem);
        FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
        FileProtectionRestRep protection = file.getProtection();
        if (protection != null) {
            List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
            for (VirtualArrayRelatedResourceRep target : targets) {
                FileShareRestRep fileshare = client.fileSystems().get(target.getId());
                options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
            }
        }
        AssetOptionsUtils.sortOptionsByLabel(options);
        return options;
    }
    return Lists.newArrayList();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with VirtualArrayRelatedResourceRep

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

the class BlockProvider method getSrdfFailoverTargets.

protected List<AssetOption> getSrdfFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
    List<VirtualArrayRelatedResourceRep> srdfTargets = volume.getProtection().getSrdfRep().getSRDFTargetVolumes();
    for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(srdfTargets, new SRDFTargetFilter())) {
        VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
        String label = getMessage("srdf.target", name(protectionSetVolume), 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) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) CachedResources(com.emc.vipr.client.core.util.CachedResources) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) SRDFTargetFilter(com.emc.vipr.client.core.filters.SRDFTargetFilter) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with VirtualArrayRelatedResourceRep

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

the class BlockProvider method getFailoverTarget.

@Asset("failoverTarget")
@AssetDependencies("protectedBlockVolume")
public List<AssetOption> getFailoverTarget(AssetOptionsContext ctx, URI protectedBlockVolume) {
    if (protectedBlockVolume != null) {
        ViPRCoreClient client = api(ctx);
        if (BlockProviderUtils.isType(protectedBlockVolume, VOLUME_TYPE)) {
            debug("getting failoverTargets (protectedBlockVolume=%s)", protectedBlockVolume);
            VolumeRestRep volume = client.blockVolumes().get(protectedBlockVolume);
            ProtectionRestRep protection = volume.getProtection();
            if (protection != null) {
                // RecoverPoint protection
                if (protection.getRpRep() != null && protection.getRpRep().getProtectionSet() != null) {
                    return getRpFailoverTargets(client, volume);
                }
                // VMAX SRDF protection
                if (protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
                    return getSrdfFailoverTargets(client, volume);
                }
            }
        } else if (BlockProviderUtils.isType(protectedBlockVolume, BLOCK_CONSISTENCY_GROUP_TYPE)) {
            debug("getting failoverTargets for consistency group %s", protectedBlockVolume);
            BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(protectedBlockVolume);
            List<VolumeRestRep> srcVolumes = null;
            // Get RP source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), RecoverPointPersonalityFilter.SOURCE);
            }
            // Get SRDF source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
            }
            if (srcVolumes != null && !srcVolumes.isEmpty()) {
                // Get the first source volume and obtain its target references
                VolumeRestRep srcVolume = srcVolumes.get(0);
                if (cg.getTypes() != null) {
                    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
                    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
                    List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
                    // Process the RP targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
                        targets = srcVolume.getProtection().getRpRep().getRpTargets();
                    }
                    // Process the SRDF targets
                    if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                        targets = srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes();
                    }
                    for (VolumeRestRep targetVolume : client.blockVolumes().getByRefs(targets)) {
                        VirtualArrayRestRep virtualArray = virtualArrays.get(targetVolume.getVirtualArray());
                        String label = getMessage(name(virtualArray));
                        targetVolumes.put(stringId(virtualArray), 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;
                }
            }
        }
    }
    return Lists.newArrayList();
}
Also used : SRDFSourceFilter(com.emc.vipr.client.core.filters.SRDFSourceFilter) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) Entry(java.util.Map.Entry) CachedResources(com.emc.vipr.client.core.util.CachedResources) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)12 ArrayList (java.util.ArrayList)7 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)6 FileProtectionRestRep (com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep)5 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 AssetOption (com.emc.vipr.model.catalog.AssetOption)5 Asset (com.emc.sa.asset.annotation.Asset)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 URI (java.net.URI)4 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 CachedResources (com.emc.vipr.client.core.util.CachedResources)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 Volume (com.emc.storageos.db.client.model.Volume)1