use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockObjectLabelWithVarray.
private static String getBlockObjectLabelWithVarray(BlockObjectRestRep blockObject, Map<URI, VirtualArrayRestRep> varrayNames) {
if (blockObject instanceof VolumeRestRep) {
VolumeRestRep volume = (VolumeRestRep) blockObject;
String varrayName = varrayNames.get(volume.getVirtualArray().getId()).getName();
return getMessage("block.unexport.volume", volume.getName(), volume.getProvisionedCapacity(), varrayName, volume.getWwn());
}
return blockObject.getName();
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVirtualArrayChangeCandidateVolumes.
@Asset("virtualArrayChangeVolume")
@AssetDependencies({ "project", "targetVirtualArray" })
public List<AssetOption> getVirtualArrayChangeCandidateVolumes(AssetOptionsContext ctx, URI projectId, URI varrayId) {
ViPRCoreClient client = api(ctx);
NamedVolumesList volumeList = client.blockVolumes().listVirtualArrayChangeCandidates(projectId, varrayId);
List<VolumeRestRep> volumes = client.blockVolumes().getByRefs(volumeList.getVolumes());
return createVolumeOptions(client, volumes);
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationVirtualArrays.
@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
final ViPRCoreClient client = api(ctx);
List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
List<AssetOption> options = new ArrayList<AssetOption>();
boolean isRP = false;
URI sourceVarrayId = null;
List<VolumeRestRep> allRPSourceVols = null;
if (volList != null && !volList.isEmpty()) {
VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
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 {
options.add(newAssetOption(URI.create("none"), "None"));
return options;
}
// if the volumes are RP (vplex or not) add the RP targets as options
if (isRP) {
options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
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);
}
if (options.isEmpty()) {
options.add(newAssetOption(URI.create("none"), "None"));
}
return options;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumesWithoutConsistencyGroup.
@Asset("volumeWithoutConsistencyGroup")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithoutConsistencyGroup(AssetOptionsContext ctx, URI project) {
debug("getting volumes that don't belong to a consistency group (project=%s)", project);
ViPRCoreClient client = api(ctx);
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project);
Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
List<AssetOption> options = Lists.newArrayList();
for (VolumeRestRep volume : volumes) {
if (volume.getConsistencyGroup() == null) {
options.add(createVolumeOption(client, null, volume, volumeNames));
}
}
return options;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockVolumes.
@Asset("unassignedBlockVolume")
@AssetDependencies({ "host", "project", "blockStorageType" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId, String blockStorageType) {
ViPRCoreClient client = api(ctx);
Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, null);
UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
// get varray IDs for host/cluster
List<VirtualArrayRestRep> varrays = new ArrayList<>();
if (EXCLUSIVE_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Host.class)) {
varrays = client.varrays().findByConnectedHost(hostOrClusterId);
} else if (SHARED_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Cluster.class)) {
varrays = client.varrays().findByConnectedCluster(hostOrClusterId);
}
List<URI> varrayIds = new ArrayList<>();
for (VirtualArrayRestRep varray : varrays) {
varrayIds.add(varray.getId());
}
// remove volumes not in hosts/cluster's varray
Iterator<VolumeRestRep> itr = volumes.iterator();
while (itr.hasNext()) {
if (!varrayIds.contains(itr.next().getVirtualArray().getId())) {
itr.remove();
}
}
return createVolumeOptions(client, volumes);
}
Aggregations