use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getProjectBlockVolumes.
protected List<VolumeRestRep> getProjectBlockVolumes(ViPRCoreClient client, URI hostOrClusterId, URI project, boolean onlyMounted) {
List<VolumeRestRep> volumes = Lists.newArrayList();
// the list of host ids that the volume could be mounted to
List<URI> hostIds = getHostIds(client, hostOrClusterId, onlyMounted);
// get a list of all volumes and snapshots in the project
List<VolumeRestRep> projectVolumes = client.blockVolumes().findByProject(project);
// cycle through every volume in the project and add those that match
for (VolumeRestRep volume : projectVolumes) {
boolean isMounted = isMounted(hostIds, volume);
if ((onlyMounted && isMounted) || (!onlyMounted && !isMounted)) {
volumes.add(volume);
}
}
return volumes;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumeDetails.
/**
* Gets the volume details for a collection of volumes.
*
* @param client the bourne client.
* @param volumes the collection of volumes.
* @return the volume details.
*/
protected static List<VolumeDetail> getVolumeDetails(ViPRCoreClient client, Collection<VolumeRestRep> volumes) {
Set<URI> blockVirtualPoolIds = getBlockVirtualPoolIdsForVolumes(volumes);
Map<URI, BlockVirtualPoolRestRep> virtualPoolMap = getBlockVirtualPools(client, blockVirtualPoolIds);
List<VolumeDetail> details = Lists.newArrayList();
for (VolumeRestRep volume : volumes) {
BlockVirtualPoolRestRep virtualPool = virtualPoolMap.get(volume.getVirtualPool().getId());
details.add(new VolumeDetail(volume, virtualPool));
}
return details;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getRpFailoverTargets.
protected List<AssetOption> getRpFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
URI protectionSetId = volume.getProtection().getRpRep().getProtectionSet().getId();
ProtectionSetRestRep localProtectionSet = client.blockVolumes().getProtectionSet(volume.getId(), protectionSetId);
String sourceSiteName = volume.getProtection().getRpRep().getInternalSiteName();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<RelatedResourceRep> rpTargets = localProtectionSet.getVolumes();
for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(rpTargets, RecoverPointPersonalityFilter.TARGET)) {
String targetSiteName = protectionSetVolume.getProtection().getRpRep().getInternalSiteName();
boolean isLocal = StringUtils.equals(sourceSiteName, targetSiteName);
String rpType = isLocal ? "local" : "remote";
VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
String label = getMessage("recoverpoint.target", name(protectionSetVolume), rpType, name(virtualArray));
targetVolumes.put(stringId(protectionSetVolume), label);
}
List<AssetOption> options = Lists.newArrayList();
for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
options.add(new AssetOption(entry.getKey(), entry.getValue()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class CreateBlockVolumeByName method executeTask.
@Override
public Task<VolumeRestRep> executeTask() throws Exception {
VolumeCreate create = new VolumeCreate();
create.setVpool(vpoolId);
create.setVarray(varrayId);
create.setProject(projectId);
create.setSize(size);
create.setConsistencyGroup(consistencyGroupId);
create.setCount(1);
create.setName(volumeName);
create.setPortGroup(portGroupId);
create.setComputeResource(computeResourceId);
Tasks<VolumeRestRep> tasksForVolume = getClient().blockVolumes().create(create);
if (tasksForVolume.getTasks().size() != 1) {
throw new IllegalStateException("Invalid number of tasks returned from API: " + tasksForVolume.getTasks().size());
}
addOrderIdTag(tasksForVolume.firstTask().getTaskResource().getId());
return tasksForVolume.firstTask();
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class CreateMultipleBlockVolumes method doExecute.
@Override
public Tasks<VolumeRestRep> doExecute() throws Exception {
Set<String> errorMessages = Sets.newHashSet();
Tasks<VolumeRestRep> tasks = null;
for (CreateBlockVolumeHelper param : helpers) {
String volumeSize = BlockStorageUtils.gbToVolumeSize(param.getSizeInGb());
VolumeCreate create = new VolumeCreate();
create.setVpool(param.getVirtualPool());
create.setVarray(param.getVirtualArray());
create.setProject(param.getProject());
create.setName(param.getName());
create.setSize(volumeSize);
create.setComputeResource(param.getComputeResource());
create.setPortGroup(param.getPortGroup());
int numberOfVolumes = 1;
if ((param.getCount() != null) && (param.getCount() > 1)) {
numberOfVolumes = param.getCount();
}
create.setCount(numberOfVolumes);
create.setConsistencyGroup(param.getConsistencyGroup());
try {
if (tasks == null) {
tasks = getClient().blockVolumes().create(create);
} else {
tasks.getTasks().addAll(getClient().blockVolumes().create(create).getTasks());
}
} catch (ServiceErrorException ex) {
errorMessages.add(ex.getDetailedMessage());
logError(getMessage("CreateMultipleBlockVolumes.getTask.error", create.getName(), ex.getDetailedMessage()));
}
}
if (tasks == null) {
throw stateException("CreateMultipleBlockVolumes.illegalState.invalid", Joiner.on('\n').join(errorMessages));
}
return tasks;
}
Aggregations