Search in sources :

Example 6 with VolumeCreate

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

the class ApiSystemTestUtil method createVolume.

public List<URI> createVolume(String name, String size, Integer count, URI vpool, URI varray, URI project, URI cg) {
    List<URI> volumes = new ArrayList<URI>();
    VolumeCreate createParam = new VolumeCreate();
    createParam.setName(name);
    createParam.setSize(size);
    ;
    createParam.setCount(count);
    createParam.setVpool(vpool);
    createParam.setVarray(varray);
    createParam.setProject(project);
    createParam.setConsistencyGroup(cg);
    try {
        Tasks<VolumeRestRep> tasks = client.blockVolumes().create(createParam);
        for (VolumeRestRep volumeRestRep : tasks.get()) {
            log.info(String.format("Volume %s (%s) created", volumeRestRep.getName(), volumeRestRep.getNativeId()));
            volumes.add(volumeRestRep.getId());
        }
        return volumes;
    } catch (ServiceErrorException ex) {
        log.error("Exception creating virtual volumes " + ex.getMessage(), ex);
        throw ex;
    }
}
Also used : ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) URI(java.net.URI) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 7 with VolumeCreate

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

the class RPBlockServiceApiImpl method upgradeToProtectedVolume.

/**
 * Upgrade a local block volume to a protected RP volume
 *
 * @param changeVpoolVolume the existing volume being protected.
 * @param newVpool the requested virtual pool
 * @param vpoolChangeParam Param sent down by the API Service
 * @param taskId the task identifier
 * @throws InternalException
 */
private void upgradeToProtectedVolume(Volume changeVpoolVolume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    Project project = _dbClient.queryObject(Project.class, changeVpoolVolume.getProject());
    if (VirtualPool.vPoolSpecifiesProtection(newVpool)) {
        // the volume from the existing CG before they can proceed.
        if (!NullColumnValueGetter.isNullURI(changeVpoolVolume.getConsistencyGroup())) {
            BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, changeVpoolVolume.getConsistencyGroup());
            throw APIException.badRequests.cannotCreateRPVolumesInCG(changeVpoolVolume.getLabel(), cg.getLabel());
        }
        // The user needs to specify a CG for this operation.
        if (vpoolChangeParam.getConsistencyGroup() == null) {
            throw APIException.badRequests.addRecoverPointProtectionRequiresCG();
        }
        if (!CollectionUtils.isEmpty(getSnapshotsForVolume(changeVpoolVolume))) {
            throw APIException.badRequests.cannotAddProtectionWhenSnapshotsExist(changeVpoolVolume.getLabel());
        }
    }
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, changeVpoolVolume.getCapacity());
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, vpoolChangeParam.getConsistencyGroup());
    capabilities.put(VirtualPoolCapabilityValuesWrapper.CHANGE_VPOOL_VOLUME, changeVpoolVolume.getId().toString());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(changeVpoolVolume, newVpool, vpoolChangeParam, capabilities);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Get the volume's varray
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, changeVpoolVolume.getVirtualArray());
    // Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
    VolumeCreate param = new VolumeCreate(changeVpoolVolume.getLabel(), String.valueOf(changeVpoolVolume.getCapacity()), 1, newVpool.getId(), changeVpoolVolume.getVirtualArray(), changeVpoolVolume.getProject().getURI());
    TaskList taskList = new TaskList();
    createTaskForVolume(changeVpoolVolume, 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) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 8 with VolumeCreate

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

the class SRDFBlockServiceApiImpl method upgradeToSRDFTargetVolume.

/**
 * Upgrade a local block volume to a protected SRDF volume
 *
 * @param volume
 *            -- srdf source volume (existing).
 * @param vpool
 *            -- Requested vpool.
 * @param taskId
 * @throws InternalException
 */
private List<VolumeDescriptor> upgradeToSRDFTargetVolume(final Volume volume, final VirtualPool vpool, final VirtualPoolChangeParam cosChangeParam, final String taskId) throws InternalException {
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, vpool, cosChangeParam);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Call out to the respective block service implementation to prepare and create the
    // volumes based on the recommendations.
    Project project = _dbClient.queryObject(Project.class, volume.getProject());
    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, vpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
    if (volume.getIsComposite()) {
        // add meta volume properties to the capabilities instance
        capabilities.put(VirtualPoolCapabilityValuesWrapper.IS_META_VOLUME, volume.getIsComposite());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_TYPE, volume.getCompositionType());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_COUNT, volume.getMetaMemberCount());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_SIZE, volume.getMetaMemberSize());
        _log.debug(String.format("Capabilities : isMeta: %s, Meta Type: %s, Member size: %s, Count: %s", capabilities.getIsMetaVolume(), capabilities.getMetaVolumeType(), capabilities.getMetaVolumeMemberSize(), capabilities.getMetaVolumeMemberCount()));
    }
    TaskList taskList = new TaskList();
    // Prepare the Bourne Volumes to be created and associated
    // with the actual storage system volumes created. Also create
    // a BlockTaskList containing the list of task resources to be
    // returned for the purpose of monitoring the volume creation
    // operation for each volume to be created.
    String volumeLabel = param.getName();
    final BlockConsistencyGroup consistencyGroup = capabilities.getBlockConsistencyGroup() == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
    // prepare the volumes
    List<URI> volumeURIs = prepareRecommendedVolumes(taskId, taskList, project, varray, vpool, capabilities.getResourceCount(), recommendations, consistencyGroup, volumeLabel, param.getSize());
    List<VolumeDescriptor> resultListVolumeDescriptors = new ArrayList<>();
    // Execute the volume creations requests for each recommendation.
    Iterator<Recommendation> recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        Recommendation recommendation = recommendationsIter.next();
        try {
            List<VolumeDescriptor> volumeDescriptors = createVolumeDescriptors((SRDFRecommendation) recommendation, volumeURIs, capabilities);
            // Log volume descriptor information
            logVolumeDescriptorPrecreateInfo(volumeDescriptors, taskId);
            resultListVolumeDescriptors.addAll(volumeDescriptors);
        } catch (InternalException e) {
            if (_log.isErrorEnabled()) {
                _log.error("Controller error", e);
            }
            String errorMsg = String.format("Controller error: %s", e.getMessage());
            if (volumeURIs != null) {
                for (URI volumeURI : volumeURIs) {
                    Volume volume1 = _dbClient.queryObject(Volume.class, volumeURI);
                    if (volume1 != null) {
                        Operation op = new Operation();
                        ServiceCoded coded = ServiceError.buildServiceError(ServiceCode.API_RP_VOLUME_CREATE_ERROR, errorMsg.toString());
                        op.setMessage(errorMsg);
                        op.error(coded);
                        _dbClient.createTaskOpStatus(Volume.class, volumeURI, taskId, op);
                        TaskResourceRep volumeTask = toTask(volume1, taskId, op);
                        if (volume1.getPersonality() != null && volume1.getPersonality().equals(Volume.PersonalityTypes.SOURCE.toString())) {
                            taskList.getTaskList().add(volumeTask);
                        }
                    }
                }
            }
            // the user what succeeded and what failed.
            throw APIException.badRequests.cannotCreateSRDFVolumes(e);
        }
    }
    return resultListVolumeDescriptors;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeCreate(com.emc.storageos.model.block.VolumeCreate) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded)

Example 9 with VolumeCreate

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

the class SRDFBlockServiceApiImpl method upgradeToTargetVolume.

/**
 * Upgrade a local block volume to a protected SRDF volume
 *
 * @param volume
 *            -- VPlex volume (existing).
 * @param vpool
 *            -- Requested vpool.
 * @param taskId
 * @throws InternalException
 */
private void upgradeToTargetVolume(final Volume volume, final VirtualPool vpool, final VirtualPoolChangeParam cosChangeParam, final String taskId) throws InternalException {
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, vpool, cosChangeParam);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Call out to the respective block service implementation to prepare and create the
    // volumes based on the recommendations.
    Project project = _dbClient.queryObject(Project.class, volume.getProject());
    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, vpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
    if (volume.getIsComposite()) {
        // add meta volume properties to the capabilities instance
        capabilities.put(VirtualPoolCapabilityValuesWrapper.IS_META_VOLUME, volume.getIsComposite());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_TYPE, volume.getCompositionType());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_COUNT, volume.getMetaMemberCount());
        capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_SIZE, volume.getMetaMemberSize());
        _log.debug(String.format("Capabilities : isMeta: %s, Meta Type: %s, Member size: %s, Count: %s", capabilities.getIsMetaVolume(), capabilities.getMetaVolumeType(), capabilities.getMetaVolumeMemberSize(), capabilities.getMetaVolumeMemberCount()));
    }
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    createVolumes(param, project, varray, vpool, recommendationMap, null, 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) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 10 with VolumeCreate

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

the class ClusterAutoExportTest method createVolume.

public URI createVolume(VirtualArrayRestRep virtualArray, BlockVirtualPoolRestRep virtualPool, ProjectRestRep project) {
    VolumeCreate input = new VolumeCreate();
    input.setName("ClusterAutoExportTest" + 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