Search in sources :

Example 66 with NamedRelatedResourceRep

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

the class BlockProvider method getApplicationVolumes.

@Asset("applicationBlockVolume")
@AssetDependencies("application")
public List<AssetOption> getApplicationVolumes(AssetOptionsContext ctx, URI application) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(application);
    List<AssetOption> options = new ArrayList<AssetOption>();
    if (volList != null && !volList.isEmpty()) {
        List<VolumeRestRep> allVols = client.blockVolumes().getByRefs(volList);
        Map<String, List<VolumeRestRep>> repGrpVolMap = new HashMap<String, List<VolumeRestRep>>();
        for (VolumeRestRep vol : allVols) {
            if (!BlockProviderUtils.isRPTargetReplicationGroup(vol.getReplicationGroupInstance())) {
                if (repGrpVolMap.get(vol.getReplicationGroupInstance()) == null) {
                    repGrpVolMap.put(vol.getReplicationGroupInstance(), new ArrayList<VolumeRestRep>());
                }
                repGrpVolMap.get(vol.getReplicationGroupInstance()).add(vol);
            }
        }
        for (Entry<String, List<VolumeRestRep>> entry : repGrpVolMap.entrySet()) {
            for (VolumeRestRep vol : entry.getValue()) {
                options.add(new AssetOption(vol.getId(), getMessage("application.volumes.replication_group", vol.getName(), vol.getReplicationGroupInstance())));
            }
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) 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) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 67 with NamedRelatedResourceRep

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

the class BlockProvider method buildPathOptions.

/* helper for building the list of asset option for affected and removed paths */
private List<AssetOption> buildPathOptions(AssetOptionsContext ctx, List<InitiatorPortMapRestRep> list, String message) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (InitiatorPortMapRestRep ipm : list) {
        InitiatorRestRep initiator = ipm.getInitiator();
        List<NamedRelatedResourceRep> ports = ipm.getStoragePorts();
        String portList = new String(" ");
        List<URI> portURIs = new ArrayList<URI>();
        for (NamedRelatedResourceRep port : ports) {
            StoragePortRestRep p = client.storagePorts().get(port.getId());
            portList += p.getPortName() + " ";
            portURIs.add(port.getId());
        }
        Map<URI, List<URI>> key = new HashMap<URI, List<URI>>();
        key.put(initiator.getId(), portURIs);
        String label = getMessage(message, initiator.getHostName(), initiator.getName(), portList);
        String keyString = EMPTY_STRING;
        try {
            keyString = CatalogSerializationUtils.serializeToString(key);
        } catch (Exception ex) {
        }
        options.add(new AssetOption(keyString, label));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) URI(java.net.URI) InitiatorPortMapRestRep(com.emc.storageos.model.block.export.InitiatorPortMapRestRep) 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)

Example 68 with NamedRelatedResourceRep

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

the class BlockProvider method getApplicationSnapshotVirtualArrays.

@Asset("applicationSnapshotVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationSnapshotVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
    List<AssetOption> options = new ArrayList<AssetOption>();
    boolean isVplex = false;
    boolean isRP = false;
    URI sourceVarrayId = null;
    List<VolumeRestRep> allRPSourceVols = null;
    if (volList != null && !volList.isEmpty()) {
        VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
        StorageSystemRestRep sys = client.storageSystems().get(vol.getStorageController());
        if (sys.getSystemType().equals("vplex")) {
            isVplex = true;
            sourceVarrayId = vol.getVirtualArray().getId();
        }
        if (BlockProviderUtils.isVolumeRP(vol)) {
            isRP = true;
            allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
            if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
                VolumeRestRep rpvol = allRPSourceVols.get(0);
                sourceVarrayId = rpvol.getVirtualArray().getId();
            }
        }
    } else {
        return options;
    }
    // if it's neither RP nor vplex, it's just a simple block volume application; site is not needed
    if (!isVplex && !isRP) {
        options.add(newAssetOption(URI.create("none"), "None"));
    }
    // if the volumes are vplex or RP display source as an option
    if (isVplex || isRP) {
        options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
    }
    // if the volumes are RP (vplex or not) add the RP targets as options
    if (isRP) {
        Set<URI> targetVarrayIds = new HashSet<URI>();
        List<AssetOption> targetOptions = new ArrayList<AssetOption>();
        List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
        for (VolumeRestRep targetVol : allRPTargetVols) {
            targetVarrayIds.add(targetVol.getVirtualArray().getId());
        }
        List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
        for (VirtualArrayRestRep targetVarray : targetVarrays) {
            targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
        }
        // sort the targets
        AssetOptionsUtils.sortOptionsByLabel(targetOptions);
        options.addAll(targetOptions);
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 69 with NamedRelatedResourceRep

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

the class FileProvider method getFilesystemsWithPolicies.

@Asset("fileFilesystemWithPolicies")
@AssetDependencies("project")
public List<AssetOption> getFilesystemsWithPolicies(AssetOptionsContext ctx, URI project) {
    List<AssetOption> options = Lists.newArrayList();
    List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
    List<FileShareRestRep> fileSystems = api(ctx).fileSystems().findByProject(project);
    for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
        if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
            for (FileShareRestRep fileSystem : fileSystems) {
                for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
                    if (resource.getId().equals(fileSystem.getId())) {
                        options.add(new AssetOption(fileSystem.getId(), fileSystem.getName()));
                        break;
                    }
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 70 with NamedRelatedResourceRep

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

the class FileProvider method getFileContinuousCopies.

@Asset("fileContinuousCopies")
@AssetDependencies("fileWithContinuousCopies")
public List<AssetOption> getFileContinuousCopies(AssetOptionsContext ctx, URI fileId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    List<NamedRelatedResourceRep> mirrors = client.fileSystems().getFileContinuousCopies(fileId);
    for (NamedRelatedResourceRep mirror : mirrors) {
        FileShareRestRep fileShare = client.fileSystems().get(mirror.getId());
        options.add(new AssetOption(fileShare.getId(), fileShare.getName()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)111 URI (java.net.URI)47 ArrayList (java.util.ArrayList)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)22 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)18 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 HashMap (java.util.HashMap)8 GET (javax.ws.rs.GET)8 Produces (javax.ws.rs.Produces)8 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)7 Path (javax.ws.rs.Path)7 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 SnapshotList (com.emc.storageos.model.SnapshotList)5 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)5 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)5 HashSet (java.util.HashSet)5 List (java.util.List)5