Search in sources :

Example 21 with StoragePool

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

the class StorageSystemService method deregisterStorageSystem.

/**
 * Allows the user register the storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief Deregister storage system
 * @return A StorageSystemRestRep reference specifying the data for the
 *         updated storage system.
 * @throws ControllerException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deregister")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public StorageSystemRestRep deregisterStorageSystem(@PathParam("id") URI id) throws ControllerException {
    // Validate the storage system.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, id);
    ArgValidator.checkEntity(storageSystem, id, isIdEmbeddedInURL(id));
    if (!RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(storageSystem.getRegistrationStatus())) {
        storageSystem.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        _dbClient.updateObject(storageSystem);
        stopStorageSystem(storageSystem);
    }
    // Deregister all Pools.
    URIQueryResultList storagePoolURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(id), storagePoolURIs);
    Iterator<URI> storagePoolIter = storagePoolURIs.iterator();
    List<StoragePool> modifiedPools = new ArrayList<StoragePool>();
    while (storagePoolIter.hasNext()) {
        StoragePool pool = _dbClient.queryObject(StoragePool.class, storagePoolIter.next());
        modifiedPools.add(pool);
        if (pool.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(pool.getRegistrationStatus())) {
            continue;
        }
        // Setting status to UNREGISTERED.
        pool.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        _dbClient.updateObject(pool);
        auditOp(OperationTypeEnum.DEREGISTER_STORAGE_POOL, true, null, id.toString());
    }
    // Deregister all Ports.
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(id), storagePortURIs);
    Iterator<URI> storagePortIter = storagePortURIs.iterator();
    while (storagePortIter.hasNext()) {
        StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortIter.next());
        if (port.getInactive() || DiscoveredDataObject.RegistrationStatus.UNREGISTERED.toString().equals(port.getRegistrationStatus())) {
            continue;
        }
        // Setting status to UNREGISTERED.
        port.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        _dbClient.updateObject(port);
        auditOp(OperationTypeEnum.DEREGISTER_STORAGE_PORT, true, null, port.getLabel(), port.getId().toString());
    }
    StringBuffer errorMessage = new StringBuffer();
    ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(modifiedPools, _dbClient, _coordinator, errorMessage);
    auditOp(OperationTypeEnum.DEREGISTER_STORAGE_SYSTEM, true, null, storageSystem.getId().toString(), id.toString());
    return map(storageSystem);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 22 with StoragePool

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

the class StorageSystemService method registerStoragePool.

/**
 * Manually register the discovered storage pool with the passed id on the
 * registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 * @param poolId The id of the storage pool.
 *
 * @brief Register storage system storage pool
 * @return A reference to a StoragePoolRestRep specifying the data for the
 *         registered storage pool.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{id}/storage-pools/{poolId}/register")
public StoragePoolRestRep registerStoragePool(@PathParam("id") URI id, @PathParam("poolId") URI poolId) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    queryRegisteredSystem(id);
    ArgValidator.checkFieldUriType(poolId, StoragePool.class, "poolId");
    StoragePool pool = _dbClient.queryObject(StoragePool.class, poolId);
    ArgValidator.checkEntity(pool, poolId, isIdEmbeddedInURL(poolId));
    if (!id.equals(pool.getStorageDevice())) {
        throw APIException.badRequests.poolNotBelongingToSystem(poolId, id);
    }
    // if not register, registered it. Otherwise, dont do anything
    if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(pool.getRegistrationStatus())) {
        registerStoragePool(pool);
        StringBuffer errorMessage = new StringBuffer();
        // Pool registration also update its varray relationship, so, we should also update vpool to pool relation.
        ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVirtualPool(Arrays.asList(pool), _dbClient, _coordinator, errorMessage);
    }
    return StoragePoolService.toStoragePoolRep(pool, _dbClient, _coordinator);
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) 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 23 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 24 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);
    volume.setCapacity(SizeUtil.translateSize(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(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 25 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)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 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 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30