Search in sources :

Example 6 with NamedVolumesList

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

the class BlockProvider method getApplicationReplicationGroups.

@Asset("replicationGroup")
@AssetDependencies({ "application", "applicationSnapshotVirtualArray" })
public List<AssetOption> getApplicationReplicationGroups(AssetOptionsContext ctx, URI applicationId, String virtualArrayParameter) {
    ViPRCoreClient client = api(ctx);
    boolean isTarget = false;
    URI virtualArray = null;
    if (virtualArrayParameter != null && StringUtils.split(virtualArrayParameter, ':')[0].equals("tgt")) {
        virtualArray = URI.create(StringUtils.substringAfter(virtualArrayParameter, ":"));
        isTarget = true;
    } else {
        isTarget = false;
    }
    Set<String> subGroups = Sets.newHashSet();
    NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
    for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
        VolumeRestRep volume = client.blockVolumes().get(volumeId);
        VolumeRestRep parentVolume = volume;
        if (volume.getHaVolumes() != null && !volume.getHaVolumes().isEmpty()) {
            volume = BlockStorageUtils.getVPlexSourceVolume(client, volume);
        }
        if (volume != null && volume.getReplicationGroupInstance() != null) {
            if (isTarget) {
                if (volume.getVirtualArray().getId().equals(virtualArray)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            } else {
                if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            }
        }
    }
    return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(subGroups));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) 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 7 with NamedVolumesList

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

the class CreateCloneOfApplicationService method execute.

@Override
public void execute() throws Exception {
    NamedVolumesList volumesToUse = BlockStorageUtils.getVolumesBySite(getClient(), virtualArrayId, applicationId);
    List<URI> volumeIds = BlockStorageUtils.getSingleVolumePerSubGroupAndStorageSystem(volumesToUse, subGroups);
    checkAndPurgeObsoleteClones(applicationId);
    String cloneName = TimeUtils.formatDateForCurrent(name);
    Tasks<? extends DataObjectRestRep> tasks = execute(new CreateCloneOfApplication(applicationId, cloneName, volumeIds));
    addAffectedResources(tasks);
    addRetainedReplicas(applicationId, cloneName);
}
Also used : NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) URI(java.net.URI) CreateCloneOfApplication(com.emc.sa.service.vipr.application.tasks.CreateCloneOfApplication)

Example 8 with NamedVolumesList

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

the class CreateSnapshotOfApplicationService method execute.

@Override
public void execute() throws Exception {
    NamedVolumesList volumesToUse = BlockStorageUtils.getVolumesBySite(getClient(), virtualArrayParameter, applicationId);
    List<URI> volumeIds = BlockStorageUtils.getSingleVolumePerSubGroupAndStorageSystem(volumesToUse, subGroups);
    checkAndPurgeObsoleteSnapshots(applicationId);
    String snapshotName = TimeUtils.formatDateForCurrent(name);
    Tasks<? extends DataObjectRestRep> tasks = execute(new CreateSnapshotForApplication(applicationId, volumeIds, snapshotName, readOnly));
    addAffectedResources(tasks);
    addRetainedReplicas(applicationId, snapshotName);
}
Also used : CreateSnapshotForApplication(com.emc.sa.service.vipr.application.tasks.CreateSnapshotForApplication) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) URI(java.net.URI)

Example 9 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList 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 10 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList 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)

Aggregations

NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)17 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 Volume (com.emc.storageos.db.client.model.Volume)6 URI (java.net.URI)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 GET (javax.ws.rs.GET)4 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)3 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 HashSet (java.util.HashSet)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)2 CreateCloneOfApplication (com.emc.sa.service.vipr.application.tasks.CreateCloneOfApplication)1 CreateSnapshotForApplication (com.emc.sa.service.vipr.application.tasks.CreateSnapshotForApplication)1 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)1 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)1