Search in sources :

Example 1 with CreateBlockVolumeHelper

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;
}
Also used : CreateBlockVolumeHelper(com.emc.sa.service.vipr.block.CreateBlockVolumeHelper)

Example 2 with CreateBlockVolumeHelper

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;
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) CreateBlockVolumeHelper(com.emc.sa.service.vipr.block.CreateBlockVolumeHelper) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Aggregations

CreateBlockVolumeHelper (com.emc.sa.service.vipr.block.CreateBlockVolumeHelper)2 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1