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));
}
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);
}
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);
}
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);
}
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;
}
Aggregations