use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class ExportPathsAdjustmentPreviewRestRep method logResponse.
public void logResponse(Logger log) {
log.info("Path Adjustment Preview : adjustedPaths");
for (InitiatorPortMapRestRep entry : adjustedPaths) {
log.info(String.format("Host %s initiator %s (%s): ", entry.getInitiator().getHostName(), entry.getInitiator().getInitiatorPort(), entry.getInitiator().getId()));
StringBuilder buffer = new StringBuilder();
for (NamedRelatedResourceRep aPort : entry.getStoragePorts()) {
buffer.append(String.format("%s (%s) ", aPort.getName(), aPort.getId()));
}
log.info("Ports: " + buffer.toString());
}
log.info("Path Adjustment Preview : removedPaths");
if (removedPaths != null) {
for (InitiatorPortMapRestRep entry : removedPaths) {
log.info(String.format("Host %s initiator %s (%s): ", entry.getInitiator().getHostName(), entry.getInitiator().getInitiatorPort(), entry.getInitiator().getId()));
StringBuilder buffer = new StringBuilder();
for (NamedRelatedResourceRep aPort : entry.getStoragePorts()) {
buffer.append(String.format("%s (%s) ", aPort.getName(), aPort.getId()));
}
log.info("Ports: " + buffer.toString());
}
}
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getFullCopiesForApplication.
private List<VolumeRestRep> getFullCopiesForApplication(AssetOptionsContext ctx, URI applicationId) {
List<VolumeRestRep> fullCopies = new ArrayList<VolumeRestRep>();
final ViPRCoreClient client = api(ctx);
NamedVolumesList volList = client.application().getFullCopiesByApplication(applicationId);
if (volList != null && volList.getVolumes() != null && !volList.getVolumes().isEmpty()) {
List<URI> ids = new ArrayList<URI>();
for (NamedRelatedResourceRep volId : volList.getVolumes()) {
ids.add(volId.getId());
}
fullCopies.addAll(client.blockVolumes().getByIds(ids));
}
return fullCopies;
}
use of com.emc.storageos.model.NamedRelatedResourceRep 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.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getReplicationGroupsForApplicationSnapshot.
protected Set<String> getReplicationGroupsForApplicationSnapshot(ViPRCoreClient client, URI applicationId, String copySet) {
Set<String> options = Sets.newHashSet();
VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
input.setCopySetName(copySet);
SnapshotList sessions = client.application().getVolumeGroupSnapshotsForSet(applicationId, input);
for (NamedRelatedResourceRep snap : sessions.getSnapList()) {
BlockSnapshotRestRep snapRep = client.blockSnapshots().get(snap);
// TODO get replication group from parent. should the snapshot already contain this?
VolumeRestRep parentVolume = client.blockVolumes().get(snapRep.getParent());
if (parentVolume != null && parentVolume.getReplicationGroupInstance() != null) {
options.add(parentVolume.getReplicationGroupInstance());
}
}
return BlockStorageUtils.stripRPTargetFromReplicationGroup(options);
}
use of com.emc.storageos.model.NamedRelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationSourceVolumes.
@Asset("sourceBlockVolumeForAddToApplication")
@AssetDependencies({ "consistencyGroupAll" })
public List<AssetOption> getApplicationSourceVolumes(AssetOptionsContext ctx, URI cg) {
final ViPRCoreClient client = api(ctx);
VolumeGroupList applications = client.application().getApplications();
List<URI> applicationIds = new ArrayList<URI>();
for (NamedRelatedResourceRep volumeGroup : applications.getVolumeGroups()) {
VolumeGroupRestRep vg = client.application().getApplication(volumeGroup.getId());
if (vg.getRoles().contains("COPY")) {
applicationIds.add(volumeGroup.getId());
}
}
ResourceFilter<VolumeRestRep> cgFilter = new BlockVolumeConsistencyGroupFilter(cg, false);
List<ProjectRestRep> projects = api(ctx).projects().getByTenant(ctx.getTenant());
List<VolumeRestRep> volumes = new ArrayList<VolumeRestRep>();
for (ProjectRestRep project : projects) {
volumes.addAll(listSourceVolumes(api(ctx), project.getId(), cgFilter));
}
List<VolumeRestRep> volumesNotInApplication = new ArrayList<VolumeRestRep>();
for (VolumeRestRep volume : volumes) {
if (volume.getVolumeGroups() != null && !volume.getVolumeGroups().isEmpty()) {
boolean volumeIsInApplication = false;
for (RelatedResourceRep rep : volume.getVolumeGroups()) {
if (applicationIds.contains(rep.getId())) {
volumeIsInApplication = true;
break;
}
}
if (!volumeIsInApplication) {
volumesNotInApplication.add(volume);
}
} else {
volumesNotInApplication.add(volume);
}
}
return createVolumeOptions(null, volumesNotInApplication);
}
Aggregations