use of com.emc.sa.service.vipr.block.CreateBlockVolumeHelper in project coprhd-controller by CoprHD.
the class CreateMultipleBlockVolumes method getDetails.
private String getDetails(List<? extends CreateBlockVolumeHelper> helpers) {
String result = "";
for (CreateBlockVolumeHelper helper : helpers) {
result += String.format("[Name: %s, Size: %s, Count: %s] ", helper.getName(), helper.getSizeInGb(), helper.getCount());
}
result = result.trim();
return result;
}
use of com.emc.sa.service.vipr.block.CreateBlockVolumeHelper 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