Search in sources :

Example 1 with VolumeCreate

use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method upgradeToMetroPointVolume.

/**
 * Upgrade a local block volume to a protected RP volume
 *
 * @param volume the existing volume being protected.
 * @param newVpool the requested virtual pool
 * @param taskId the task identifier
 * @throws InternalException
 */
private void upgradeToMetroPointVolume(Volume volume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    _log.info(String.format("Upgrade [%s] to MetroPoint", volume.getLabel()));
    Project project = _dbClient.queryObject(Project.class, volume.getProject());
    // Now that we have a handle on the current vpool, let's set the new vpool on the volume.
    // The volume will not be persisted just yet but we need to have the new vpool to
    // properly make placement decisions and to add reference to the new vpool to the
    // recommendation objects that will be created.
    URI currentVpool = volume.getVirtualPool();
    volume.setVirtualPool(newVpool.getId());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, newVpool, vpoolChangeParam, null);
    volume.setVirtualPool(currentVpool);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Get the volume's varray
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
    // Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
    VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, newVpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
    TaskList taskList = new TaskList();
    createTaskForVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL, taskList, taskId);
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    createVolumes(param, project, varray, newVpool, recommendationMap, taskList, taskId, capabilities);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolUse(com.emc.storageos.api.service.impl.placement.VpoolUse) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 2 with VolumeCreate

use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method prepareVPlexVolume.

/**
 * Leverage the vplex block service api to properly prepare volumes in cassandra for later consumption by the controllers
 *
 * @param vplexRecommendations All the VPLEX recs
 * @param project Project for the volume
 * @param varray Varray for the volume
 * @param vpool Vpool for the volume
 * @param storagePoolUri URI of the Storage Pool for the volume
 * @param storageSystemId URI of the Storage System for the volume
 * @param capabilities Capabilities for the volume create
 * @param consistencyGroup CG for the volume
 * @param param Volume create param for the volume
 * @param volumeName Volume name
 * @param size Volume size
 * @param descriptors All volume descriptors, needed to be populated by the VPLEX Block
 * @param taskList Tasklist to add all VPLEX tasks
 * @param task Task Id
 * @param personality Personality of the volume
 * @param isChangeVpool Boolean set to true if it's a change vpool op
 * @param changeVpoolVolume The change vpool volume if needed
 * @return Prepared VPLEX volume
 */
private Volume prepareVPlexVolume(List<Recommendation> vplexRecommendations, Project project, VirtualArray varray, VirtualPool vpool, URI storagePoolUri, URI storageSystemId, VirtualPoolCapabilityValuesWrapper capabilities, BlockConsistencyGroup consistencyGroup, VolumeCreate param, String volumeName, String size, List<VolumeDescriptor> descriptors, TaskList taskList, String task, Volume.PersonalityTypes personality, boolean isChangeVpool, Volume changeVpoolVolume) {
    Volume vplexVirtualVolume = null;
    if (!isChangeVpool) {
        List<URI> volumes = new ArrayList<URI>();
        // VPLEX needs to be aware of the CG
        capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, consistencyGroup.getId());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.PERSONALITY, personality.name());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
        // Tweak the VolumeCreate slightly for VPLEX
        VolumeCreate volumeCreateParam = new VolumeCreate();
        volumeCreateParam.setConsistencyGroup(consistencyGroup.getId());
        volumeCreateParam.setCount(1);
        volumeCreateParam.setName(volumeName);
        volumeCreateParam.setProject(project.getId());
        volumeCreateParam.setSize(size);
        volumeCreateParam.setVarray(varray.getId());
        volumeCreateParam.setVpool(vpool.getId());
        boolean createTask = Volume.PersonalityTypes.SOURCE.equals(personality);
        List<VolumeDescriptor> vplexVolumeDescriptors = vplexBlockServiceApiImpl.createVPlexVolumeDescriptors(volumeCreateParam, project, varray, vpool, vplexRecommendations, task, capabilities, capabilities.getBlockConsistencyGroup(), taskList, volumes, createTask);
        // name if the custom volume naming is configured as such.
        if ((createTask) && (param.getComputeResource() != null)) {
            for (VolumeDescriptor vplexVolumeDescriptor : vplexVolumeDescriptors) {
                vplexVolumeDescriptor.setComputeResource(param.getComputeResource());
            }
        }
        descriptors.addAll(vplexVolumeDescriptors);
        vplexVirtualVolume = this.getVPlexVirtualVolume(volumes);
    } else {
        if (Volume.PersonalityTypes.SOURCE.equals(personality)) {
            VolumeDescriptor changeVpoolDescriptor = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, changeVpoolVolume.getStorageController(), changeVpoolVolume.getId(), null, consistencyGroup.getId(), capabilities, changeVpoolVolume.getCapacity());
            Map<String, Object> descParams = new HashMap<String, Object>();
            descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_EXISTING_VOLUME_ID, changeVpoolVolume.getId());
            descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_NEW_VPOOL_ID, vpool.getId());
            descParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_OLD_VPOOL_ID, changeVpoolVolume.getVirtualPool());
            changeVpoolDescriptor.setParameters(descParams);
            descriptors.add(changeVpoolDescriptor);
            vplexVirtualVolume = changeVpoolVolume;
        }
    }
    return vplexVirtualVolume;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 3 with VolumeCreate

use of com.emc.storageos.model.block.VolumeCreate 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();
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 4 with VolumeCreate

use of com.emc.storageos.model.block.VolumeCreate 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)

Example 5 with VolumeCreate

use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.

the class ViPRClientApp method createVolume.

public URI createVolume(VirtualArrayRestRep virtualArray, BlockVirtualPoolRestRep virtualPool, ProjectRestRep project) {
    VolumeCreate input = new VolumeCreate();
    input.setName("SDSClientApp_Volume_" + System.currentTimeMillis());
    input.setVarray(virtualArray.getId());
    input.setVpool(virtualPool.getId());
    input.setSize("2GB");
    input.setCount(1);
    input.setProject(project.getId());
    Task<VolumeRestRep> task = client.blockVolumes().create(input).firstTask();
    VolumeRestRep volume = task.get();
    System.out.println("Created Volume: " + volume.getId());
    return volume.getId();
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Aggregations

VolumeCreate (com.emc.storageos.model.block.VolumeCreate)14 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 TaskList (com.emc.storageos.model.TaskList)6 ArrayList (java.util.ArrayList)6 Project (com.emc.storageos.db.client.model.Project)5 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)5 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)5 URI (java.net.URI)5 Recommendation (com.emc.storageos.volumecontroller.Recommendation)4 HashMap (java.util.HashMap)4 VpoolUse (com.emc.storageos.api.service.impl.placement.VpoolUse)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 Volume (com.emc.storageos.db.client.model.Volume)3 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)3 StorageSystemConnectivityList (com.emc.storageos.model.systems.StorageSystemConnectivityList)3 List (java.util.List)3 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)2 VolumeGroupVolumeList (com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList)2