Search in sources :

Example 51 with NamedRelatedResourceRep

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

the class RemoveApplicationFullCopy method doExecute.

@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
    NamedVolumesList allFullCopies = getClient().application().getFullCopiesByApplication(applicationId);
    Set<URI> fullCopyIds = new HashSet<URI>();
    for (NamedRelatedResourceRep fullCopy : allFullCopies.getVolumes()) {
        fullCopyIds.add(fullCopy.getId());
    }
    List<URI> volList = Collections.singletonList(volumeId);
    VolumeGroupFullCopyDetachParam input = new VolumeGroupFullCopyDetachParam(true, volList);
    TaskList taskList = getClient().application().detachApplicationFullCopy(applicationId, input);
    BlockStorageUtils.removeBlockResources(fullCopyIds, VolumeDeleteTypeEnum.FULL);
    return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
Also used : WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) TaskList(com.emc.storageos.model.TaskList) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeGroupFullCopyDetachParam(com.emc.storageos.model.application.VolumeGroupFullCopyDetachParam) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) HashSet(java.util.HashSet)

Example 52 with NamedRelatedResourceRep

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

the class BlockStorageUtils method getVolumesBySite.

public static NamedVolumesList getVolumesBySite(ViPRCoreClient client, String virtualArrayId, URI applicationId) {
    boolean isTarget = false;
    URI virtualArray = null;
    if (virtualArrayId != null && StringUtils.split(virtualArrayId, ':')[0].equals("tgt")) {
        virtualArray = URI.create(StringUtils.substringAfter(virtualArrayId, ":"));
        isTarget = true;
    } else {
        isTarget = false;
    }
    NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
    NamedVolumesList volumesToUse = new NamedVolumesList();
    for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
        VolumeRestRep parentVolume = client.blockVolumes().get(volumeId);
        if (isTarget) {
            if (isRPTargetVolume(parentVolume) && parentVolume.getVirtualArray().getId().equals(virtualArray)) {
                volumesToUse.getVolumes().add(volumeId);
            }
        } else {
            if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
                volumesToUse.getVolumes().add(volumeId);
            }
        }
    }
    return volumesToUse;
}
Also used : NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 53 with NamedRelatedResourceRep

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

the class BlockStorageUtils method getReplicationGroupVolumes.

public static Table<URI, String, VolumeRestRep> getReplicationGroupVolumes(List<NamedRelatedResourceRep> volumeUris) {
    // Group volumes by storage system and replication group
    Table<URI, String, VolumeRestRep> storageRgToVolumes = HashBasedTable.create();
    for (NamedRelatedResourceRep volumeUri : volumeUris) {
        VolumeRestRep vplexVolume = null;
        VolumeRestRep volume = execute(new GetBlockVolume(volumeUri.getId()));
        boolean isVPlex = volume.getSystemType().equals("vplex");
        if (isVPlex) {
            vplexVolume = volume;
            volume = getSourceVolume(volume);
        }
        String rgName = BlockStorageUtils.stripRPTargetFromReplicationGroup(volume.getReplicationGroupInstance());
        URI storage = volume.getStorageController();
        if (!storageRgToVolumes.contains(storage, rgName)) {
            if (isVPlex) {
                storageRgToVolumes.put(storage, rgName, vplexVolume);
            } else {
                storageRgToVolumes.put(storage, rgName, volume);
            }
        }
    }
    return storageRgToVolumes;
}
Also used : GetBlockVolume(com.emc.sa.service.vipr.block.tasks.GetBlockVolume) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 54 with NamedRelatedResourceRep

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

the class BlockStorageUtils method getReplicationGroupSnapshots.

public static Table<URI, String, BlockSnapshotRestRep> getReplicationGroupSnapshots(List<NamedRelatedResourceRep> volumeUris) {
    Table<URI, String, BlockSnapshotRestRep> storageRgToVolumes = HashBasedTable.create();
    for (NamedRelatedResourceRep volumeUri : volumeUris) {
        BlockSnapshotRestRep snapshot = execute(new GetBlockSnapshot(volumeUri.getId()));
        VolumeRestRep volume = execute(new GetBlockVolume(snapshot.getParent().getId()));
        String rgName = volume.getReplicationGroupInstance();
        URI storage = volume.getStorageController();
        if (!storageRgToVolumes.contains(storage, rgName)) {
            storageRgToVolumes.put(storage, rgName, snapshot);
        }
    }
    return storageRgToVolumes;
}
Also used : GetBlockVolume(com.emc.sa.service.vipr.block.tasks.GetBlockVolume) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) GetBlockSnapshot(com.emc.sa.service.vipr.block.tasks.GetBlockSnapshot) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 55 with NamedRelatedResourceRep

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

the class BlockProvider method getExportsForExportedVolume.

@Asset("volumeExport")
@AssetDependencies("exportedBlockVolume")
public List<AssetOption> getExportsForExportedVolume(AssetOptionsContext ctx, URI volumeId) {
    final ViPRCoreClient client = api(ctx);
    Set<NamedRelatedResourceRep> exports = getUniqueExportsForVolume(ctx, volumeId);
    return createExportWithVarrayOptions(client, client.blockExports().getByRefs(exports));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) 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