Search in sources :

Example 1 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method prepareVolume.

/**
 * Prepare Volume for an SRDF protected volume
 *
 * @param volume
 *            pre-created volume from the api service
 * @param param
 *            volume request
 * @param project
 *            project requested
 * @param varray
 *            varray requested
 * @param vpool
 *            vpool requested
 * @param size
 *            size of the volume
 * @param placement
 *            recommendation for placement
 * @param label
 *            volume label
 * @param consistencyGroup
 *            consistency group
 * @param token
 *            task id
 * @param remote
 *            is this a target volume
 * @param personality
 *            normal volume or metadata
 * @param srcVolumeId
 *            source volume ID; only for target volumes
 * @param raGroupURI
 *            RDF Group of the source array to use
 * @param copyMode
 *            copy policy, like async or sync
 *
 * @return a persisted volume
 */
private Volume prepareVolume(Volume volume, final Project project, final VirtualArray varray, final VirtualPool vpool, final String size, final Recommendation placement, final String label, final BlockConsistencyGroup consistencyGroup, final String token, final boolean remote, final Volume.PersonalityTypes personality, final URI srcVolumeId, final URI raGroupURI, final String copyMode) {
    boolean newVolume = false;
    if (volume == null) {
        // check for duplicate label
        validateVolumeLabel(label, project);
        newVolume = true;
        volume = new Volume();
        volume.setId(URIUtil.createId(Volume.class));
        volume.setOpStatus(new OpStatusMap());
    } else {
        volume = _dbClient.queryObject(Volume.class, volume.getId());
    }
    volume.setLabel(label);
    long sizeLong = SizeUtil.translateSize(size);
    volume.setCapacity(sizeLong);
    Long thinVolumePreAllocationSize = 0L;
    if (null != vpool.getThinVolumePreAllocationPercentage()) {
        thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vpool.getThinVolumePreAllocationPercentage(), sizeLong);
    }
    if (0 != thinVolumePreAllocationSize) {
        volume.setThinVolumePreAllocationSize(thinVolumePreAllocationSize);
    }
    volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
    volume.setVirtualPool(vpool.getId());
    volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
    volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
    volume.setVirtualArray(varray.getId());
    volume.setSrdfGroup(raGroupURI);
    volume.setSrdfCopyMode(copyMode);
    if (null != placement.getSourceStoragePool()) {
        StoragePool pool = _dbClient.queryObject(StoragePool.class, placement.getSourceStoragePool());
        if (null != pool) {
            volume.setProtocol(new StringSet());
            volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
        }
    }
    volume.setPersonality(personality.toString());
    if (personality.equals(Volume.PersonalityTypes.SOURCE)) {
        volume.setAccessState(VolumeAccessState.READWRITE.name());
    } else if (personality.equals(Volume.PersonalityTypes.TARGET)) {
        volume.setAccessState(VolumeAccessState.NOT_READY.name());
    }
    URI storageSystemUri = null;
    if (!remote) {
        storageSystemUri = placement.getSourceStorageSystem();
        volume.setStorageController(storageSystemUri);
        volume.setPool(placement.getSourceStoragePool());
    } else {
        storageSystemUri = ((SRDFRecommendation) placement).getVirtualArrayTargetMap().get(varray.getId()).getTargetStorageDevice();
        volume.setStorageController(storageSystemUri);
        volume.setPool(((SRDFRecommendation) placement).getVirtualArrayTargetMap().get(varray.getId()).getTargetStoragePool());
    }
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemUri);
    String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
    volume.setSystemType(systemType);
    volume.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
    op.setStartTime(Calendar.getInstance());
    volume.getOpStatus().put(token, op);
    if (consistencyGroup != null) {
        volume.setConsistencyGroup(consistencyGroup.getId());
        volume.setReplicationGroupInstance(consistencyGroup.getLabel());
    }
    if (null != vpool.getAutoTierPolicyName()) {
        URI autoTierPolicyUri = StorageScheduler.getAutoTierPolicy(volume.getPool(), vpool.getAutoTierPolicyName(), _dbClient);
        if (null != autoTierPolicyUri) {
            volume.setAutoTieringPolicyUri(autoTierPolicyUri);
        }
    }
    // Keep track of target volumes associated with the source volume
    if (srcVolumeId != null) {
        Volume srcVolume = _dbClient.queryObject(Volume.class, srcVolumeId);
        if (srcVolume.getSrdfTargets() == null) {
            srcVolume.setSrdfTargets(new StringSet());
        }
        // This is done in prepare, but the source volume may be a cos change volume that didn't
        // go through that process.
        srcVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
        srcVolume.getSrdfTargets().add(volume.getId().toString());
        _dbClient.updateObject(srcVolume);
        volume.setSrdfParent(new NamedURI(srcVolume.getId(), srcVolume.getLabel()));
        computeCapacityforSRDFV3ToV2(volume, vpool);
    }
    if (newVolume) {
        _dbClient.createObject(volume);
    } else {
        _dbClient.updateObject(volume);
    }
    return volume;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) StringSet(com.emc.storageos.db.client.model.StringSet) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method computeCapacityforSRDFV3ToV2.

/**
 * SRDF between VMAX3 to VMAX2 is failing due to configuration mismatch (OPT#475186).
 * As a workaround, calculate the VMAX2 volume size based on the VMAX3 cylinder size.
 *
 * @param targetVolume
 * @param vpool
 */
private void computeCapacityforSRDFV3ToV2(Volume targetVolume, final VirtualPool vpool) {
    if (targetVolume == null) {
        return;
    }
    StorageSystem targetSystem = _dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
    StoragePool targetPool = _dbClient.queryObject(StoragePool.class, targetVolume.getPool());
    Volume sourceVolume = _dbClient.queryObject(Volume.class, targetVolume.getSrdfParent());
    StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
    StoragePool sourcePool = _dbClient.queryObject(StoragePool.class, sourceVolume.getPool());
    if (sourceSystem != null && targetSystem != null) {
        boolean isCapacityReset = false;
        if (sourcePool != null && targetPool != null) {
            // Meta Versus Non Meta
            MetaVolumeRecommendation sourceVolumeRecommendation = MetaVolumeUtils.getCreateRecommendation(sourceSystem, sourcePool, sourceVolume.getCapacity(), sourceVolume.getThinlyProvisioned(), vpool.getFastExpansion(), null);
            MetaVolumeRecommendation targetVolumeRecommendation = MetaVolumeUtils.getCreateRecommendation(targetSystem, targetPool, targetVolume.getCapacity(), targetVolume.getThinlyProvisioned(), vpool.getFastExpansion(), null);
            isCapacityReset = computeCapacityforSRDFV3ToV2Meta(sourcePool, targetPool, sourceVolume, targetVolume, sourceVolumeRecommendation, targetVolumeRecommendation);
        }
        // Source : VMAX3 & Target : VMAX2 case
        if (sourceSystem.checkIfVmax3() && !targetSystem.checkIfVmax3() && !isCapacityReset) {
            Long cylinderCount = (long) Math.ceil((double) targetVolume.getCapacity() / V3CYLINDERSIZE);
            targetVolume.setCapacity(cylinderCount * V3CYLINDERSIZE);
            _log.info("Cylinder Count : {}, VMAX2 volume Capacity : {}", cylinderCount, targetVolume.getCapacity());
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class ObjectVirtualPoolService method getMatchingPoolsForVirtualPoolAttributes.

/**
 * Return the matching pools for a given set of VirtualPool attributes.
 * This API is useful for user to find the matching pools before creating a VirtualPool.
 *
 * @param param : VirtualPoolAttributeParam
 * @brief List pools matching specified properties in Object store VirtualPool
 * @return : matching pools.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/matching-pools")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StoragePoolList getMatchingPoolsForVirtualPoolAttributes(ObjectVirtualPoolParam param) {
    StoragePoolList poolList = new StoragePoolList();
    VirtualPool vpool = prepareVirtualPool(param);
    List<URI> poolURIs = _dbClient.queryByType(StoragePool.class, true);
    List<StoragePool> allPools = _dbClient.queryObject(StoragePool.class, poolURIs);
    StringBuffer errorMessage = new StringBuffer();
    List<StoragePool> matchedPools = ImplicitPoolMatcher.getMatchedPoolWithStoragePools(vpool, allPools, null, null, null, _dbClient, _coordinator, AttributeMatcher.VPOOL_MATCHERS, errorMessage);
    for (StoragePool pool : matchedPools) {
        poolList.getPools().add(toNamedRelatedResource(pool, pool.getNativeGuid()));
    }
    return poolList;
}
Also used : StoragePoolList(com.emc.storageos.model.pools.StoragePoolList) StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPoolMapper.toObjectVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toObjectVirtualPool) MapObjectVirtualPool(com.emc.storageos.api.mapper.functions.MapObjectVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method prepareVolumeForRequest.

/**
 * Prepare a new Bourne volume.
 *
 * TODO: Use existing function (prepareVolume) when VirtualPool capabilities change
 * completed by Stalin. Just pass size instead of getting from VolumeCreate
 * parameter.
 *
 * @param size The volume size.
 * @param project A reference to the volume's Project.
 * @param neighborhood A reference to the volume's varray.
 * @param vpool A reference to the volume's VirtualPool.
 * @param storageSystemURI The URI of the volume's storage system.
 * @param storagePoolURI The URI of the volume's storage pool.
 * @param label The volume label.
 * @param token The task id for volume creation.
 * @param dbClient A reference to a database client.
 *
 * @return A reference to the new volume.
 */
public static Volume prepareVolumeForRequest(Long size, Project project, VirtualArray neighborhood, VirtualPool vpool, URI storageSystemURI, URI storagePoolURI, String label, ResourceOperationTypeEnum opType, String token, DbClient dbClient) {
    Volume volume = new Volume();
    volume.setId(URIUtil.createId(Volume.class));
    volume.setLabel(label);
    volume.setCapacity(size);
    volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
    volume.setVirtualPool(vpool.getId());
    volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
    volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
    volume.setVirtualArray(neighborhood.getId());
    StoragePool storagePool = null;
    if (!NullColumnValueGetter.getNullURI().toString().equals(storagePoolURI.toString())) {
        storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
        if (null != storagePool) {
            volume.setProtocol(new StringSet());
            volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), storagePool.getProtocols()));
        }
    } else {
        // Must be preparing a VPLEX volume which does not
        // have a storage pool so a null URI is passed. Set
        // the volume protocols to FC.
        StringSet protocols = new StringSet();
        protocols.add(StorageProtocol.Block.FC.name());
        volume.setProtocol(protocols);
    }
    volume.setStorageController(storageSystemURI);
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
    String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
    volume.setSystemType(systemType);
    volume.setPool(storagePoolURI);
    volume.setOpStatus(new OpStatusMap());
    // Set the auto tiering policy.
    if (null != vpool.getAutoTierPolicyName()) {
        URI autoTierPolicyUri = StorageScheduler.getAutoTierPolicy(storagePoolURI, vpool.getAutoTierPolicyName(), dbClient);
        if (null != autoTierPolicyUri) {
            volume.setAutoTieringPolicyUri(autoTierPolicyUri);
        }
    }
    if (opType != null) {
        Operation op = new Operation();
        op.setResourceType(opType);
        volume.getOpStatus().createTaskStatus(token, op);
    }
    dbClient.createObject(volume);
    return volume;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method printMigrationInfo.

/**
 * Method for logging for migrations.
 *
 * @param migration The migration that has been created
 * @param sourceVolume The source/original volume to be migrated from (potential to be null for ingested volumes)
 * @param targetVolume The target volume to be migrated to
 */
private void printMigrationInfo(Migration migration, Volume sourceVolume, Volume targetVolume) {
    StringBuffer migrationInfo = new StringBuffer();
    migrationInfo.append("\n+++++++++++++++++++++++++++++++++++++++++++");
    migrationInfo.append(String.format("\nPrepared Migration: (%s)", migration.getId()));
    if (sourceVolume != null) {
        VirtualArray migrationSourceVarray = _dbClient.queryObject(VirtualArray.class, sourceVolume.getVirtualArray());
        VirtualPool migrationSourceVpool = _dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
        StoragePool migrationSourcePool = _dbClient.queryObject(StoragePool.class, sourceVolume.getPool());
        StorageSystem migrationSourceStorageSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
        migrationInfo.append("\nMigration from... ");
        migrationInfo.append(String.format("\n\tMigration Source Volume: [%s](%s)", sourceVolume.getLabel(), sourceVolume.getId()));
        migrationInfo.append(String.format("\n\tMigration Source Varray: [%s](%s)", migrationSourceVarray.getLabel(), migrationSourceVarray.getId()));
        migrationInfo.append(String.format("\n\tMigration Source Vpool: [%s](%s)", migrationSourceVpool.getLabel(), migrationSourceVpool.getId()));
        migrationInfo.append(String.format("\n\tMigration Source Pool: [%s](%s)", migrationSourcePool.getLabel(), migrationSourcePool.getId()));
        migrationInfo.append(String.format("\n\tMigration Source Storage: [%s](%s)", migrationSourceStorageSystem.getLabel(), migrationSourceStorageSystem.getId()));
    }
    VirtualArray migrationTargetVarray = _dbClient.queryObject(VirtualArray.class, targetVolume.getVirtualArray());
    VirtualPool migrationTargetVpool = _dbClient.queryObject(VirtualPool.class, targetVolume.getVirtualPool());
    StoragePool migrationTargetPool = _dbClient.queryObject(StoragePool.class, targetVolume.getPool());
    StorageSystem migrationTargetStorageSystem = _dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
    migrationInfo.append("\nMigration to... ");
    migrationInfo.append(String.format("\n\tMigration Target Volume: [%s](%s)", targetVolume.getLabel(), targetVolume.getId()));
    migrationInfo.append(String.format("\n\tMigration Target Varray: [%s](%s)", migrationTargetVarray.getLabel(), migrationTargetVarray.getId()));
    migrationInfo.append(String.format("\n\tMigration Target Vpool: [%s](%s)", migrationTargetVpool.getLabel(), migrationTargetVpool.getId()));
    migrationInfo.append(String.format("\n\tMigration Target Pool: [%s](%s)", migrationTargetPool.getLabel(), migrationTargetPool.getId()));
    migrationInfo.append(String.format("\n\tnMigration Target Storage: [%s](%s)", migrationTargetStorageSystem.getLabel(), migrationTargetStorageSystem.getId()));
    migrationInfo.append("\n+++++++++++++++++++++++++++++++++++++++++++");
    s_logger.info(migrationInfo.toString());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)388 URI (java.net.URI)198 ArrayList (java.util.ArrayList)190 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)162 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)81 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)78 HashSet (java.util.HashSet)76 Volume (com.emc.storageos.db.client.model.Volume)73 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 StringMap (com.emc.storageos.db.client.model.StringMap)47 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)44 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)40 IOException (java.io.IOException)35 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)30