Search in sources :

Example 6 with QosSpecification

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

the class QualityOfServiceMigrationTest method verifyResults.

@Override
protected void verifyResults() throws Exception {
    List<URI> qosSpecsURI = _dbClient.queryByType(QosSpecification.class, true);
    Assert.assertNotNull("List of vPool URIs should not be null", qosSpecsURI);
    List<QosSpecification> qosSpecificationList = _dbClient.queryObject(QosSpecification.class, qosSpecsURI);
    Assert.assertEquals("QosSpecification list should contain one object", new Integer(qosSpecificationList.size()), QOS_LIST_SIZE);
    QosSpecification qosSpecification = qosSpecificationList.get(QOS_LIST_HEAD);
    Assert.assertNotNull("QosSpecification should not be null", qosSpecification);
    Assert.assertEquals(vPoolId, qosSpecification.getVirtualPoolId());
    Assert.assertEquals(QOS_NAME, qosSpecification.getName());
    Assert.assertEquals(QOS_CONSUMER, qosSpecification.getConsumer());
    Assert.assertEquals(V_POOL_LABEL, qosSpecification.getLabel());
    Assert.assertEquals(V_POOL_PROVISIONING_TYPE, qosSpecification.getSpecs().get("Provisioning Type"));
    Assert.assertEquals(V_POOL_PROTOCOL, qosSpecification.getSpecs().get("Protocol"));
    Assert.assertEquals(V_POOL_DRIVE_TYPE, qosSpecification.getSpecs().get("Drive Type"));
    Assert.assertEquals(V_POOL_SYSTEM_TYPE, qosSpecification.getSpecs().get("System Type"));
    Assert.assertFalse(Boolean.valueOf(qosSpecification.getSpecs().get("Multi-Volume Consistency")));
    Assert.assertTrue(Boolean.valueOf(qosSpecification.getSpecs().get("Expendable")));
    Assert.assertEquals(V_POOL_MAX_SAN_PATHS, Integer.valueOf(qosSpecification.getSpecs().get("Maximum SAN paths")));
    Assert.assertEquals(V_POOL_MIN_SAN_PATHS, Integer.valueOf(qosSpecification.getSpecs().get("Minimum SAN paths")));
    Assert.assertEquals(V_POOL_MAX_BLOCK_MIRRORS, Integer.valueOf(qosSpecification.getSpecs().get("Maximum block mirrors")));
    Assert.assertEquals(V_POOL_PATHS_PER_INITIATOR, Integer.valueOf(qosSpecification.getSpecs().get("Paths per Initiator")));
    Assert.assertEquals(V_POOL_MAX_SNAPSHOTS, Integer.valueOf(qosSpecification.getSpecs().get("Maximum Snapshots")));
}
Also used : QosSpecification(com.emc.storageos.db.client.model.QosSpecification) URI(java.net.URI)

Example 7 with QosSpecification

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

the class VirtualPoolService method deleteVirtualPool.

protected Response deleteVirtualPool(VirtualPool.Type type, URI id) {
    ArgValidator.checkUri(id);
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, id);
    ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
    // we need to remove before the virtual pool removal
    if (vpool.getType().equalsIgnoreCase(Type.block.name())) {
        List<URI> quotas = _dbClient.queryByType(QuotaOfCinder.class, true);
        for (URI quota : quotas) {
            QuotaOfCinder quotaObj = _dbClient.queryObject(QuotaOfCinder.class, quota);
            if ((quotaObj.getVpool() != null) && (quotaObj.getVpool().toString().equalsIgnoreCase(vpool.getId().toString()))) {
                _log.debug("Deleting related Vpool for quota object {}.", vpool.getId().toString());
                _dbClient.removeObject(quotaObj);
            }
        }
    }
    if (vpool.getType().equalsIgnoreCase(Type.file.name())) {
        // check if any file policies are assigned to the vpool
        if ((vpool.getFilePolicies() != null) && !(vpool.getFilePolicies().isEmpty())) {
            _log.error("Failed to update the name of virtual pool as a policy is assigned");
            throw APIException.badRequests.cannotDeleteVpoolAssignedFilePolicy(vpool.getLabel());
        }
        // if file policy is assigned to project level then also it has file vpool associated with it.
        // In this scenario association is only way.so need to iterate through all the policy to get vpool reference.
        List<URI> filePolicyList = _dbClient.queryByType(FilePolicy.class, true);
        for (URI filePolicy : filePolicyList) {
            FilePolicy policyObj = _dbClient.queryObject(FilePolicy.class, filePolicy);
            if ((policyObj.getAssignedResources() != null) && (policyObj.getFilePolicyVpool() != null) && (policyObj.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString()))) {
                _log.error("Failed to update the name of virtual pool as a policy is assigned at higher level");
                throw APIException.badRequests.cannotDeleteVpoolAssignedFilePolicy(vpool.getLabel());
            }
        }
    }
    if (!vpool.getType().equals(type.name())) {
        throw APIException.badRequests.providedVirtualPoolNotCorrectType();
    }
    QosSpecification qosSpecification = null;
    // Check if Virtual Pool type equals block type
    if (vpool.getType().equalsIgnoreCase(Type.block.name())) {
        // Get the QoS for the VirtualPool, otherwise throw exception
        qosSpecification = QosService.getQos(vpool.getId(), _dbClient);
    }
    // make sure vpool is unused by volumes/fileshares
    ArgValidator.checkReference(VirtualPool.class, id, checkForDelete(vpool));
    // Check if vpool is set as a continuous copies vpool
    checkIfVpoolIsSetAsContinuousCopiesVpool(vpool);
    // Additional check for VirtualPool that may be hidden in another VirtualPool via the
    // protection settings
    URIQueryResultList settingsResultList = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVpoolProtectionVarraySettingsConstraint(id.toString()), settingsResultList);
    Iterator<URI> settingsListItr = settingsResultList.iterator();
    while (settingsListItr.hasNext()) {
        final URI settingId = settingsListItr.next();
        VpoolProtectionVarraySettings setting = _dbClient.queryObject(VpoolProtectionVarraySettings.class, settingId);
        ArgValidator.checkEntity(setting, settingId, isIdEmbeddedInURL(settingId));
    }
    if (vpool.getProtectionVarraySettings() != null) {
        // Delete all settings associated with the protection settings
        deleteVPoolProtectionVArraySettings(vpool);
    }
    if (vpool.getFileRemoteCopySettings() != null) {
        // Delete all settings associated with the protection settings
        deleteFileVPoolRemoteCopyProtectionSettings(vpool);
    }
    // We also check to see if this virtual pool is specified as the HA virtual pool
    // for some other virtual pool that specifies VPLEX distributed high availability.
    // If this is the case, we disallow the deletion.
    List<URI> vpoolURIs = _dbClient.queryByType(VirtualPool.class, true);
    Iterator<VirtualPool> vpoolsIter = _dbClient.queryIterativeObjects(VirtualPool.class, vpoolURIs);
    while (vpoolsIter.hasNext()) {
        VirtualPool activeVPool = vpoolsIter.next();
        if (!activeVPool.getId().equals(id)) {
            StringMap haMap = activeVPool.getHaVarrayVpoolMap();
            if ((haMap != null) && (!haMap.isEmpty()) && (haMap.values().contains(id.toString()))) {
                // is not allowed.
                throw APIException.badRequests.cantDeleteVPlexHaVPool(activeVPool.getLabel());
            }
        }
    }
    if (vpool.getType().equalsIgnoreCase(Type.block.name()) && qosSpecification != null) {
        // Remove Qos associated to this Virtual Pool
        _dbClient.removeObject(qosSpecification);
    }
    _dbClient.markForDeletion(vpool);
    recordOperation(OperationTypeEnum.DELETE_VPOOL, VPOOL_DELETED_DESCRIPTION, vpool);
    return Response.ok().build();
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) QuotaOfCinder(com.emc.storageos.db.client.model.QuotaOfCinder) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 8 with QosSpecification

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

the class QosService method getQos.

/**
 * Get QoS specification associated with provided VirtualPool.
 *
 * @param vpoolId the VirtualPool for which QoS specification is required.
 */
public static QosSpecification getQos(URI vpoolId, DbClient dbClient) throws APIException {
    List<URI> qosSpecsURI = dbClient.queryByType(QosSpecification.class, true);
    Iterator<QosSpecification> qosIter = dbClient.queryIterativeObjects(QosSpecification.class, qosSpecsURI);
    while (qosIter.hasNext()) {
        QosSpecification activeQos = qosIter.next();
        if (activeQos != null && activeQos.getVirtualPoolId().equals(vpoolId)) {
            _log.debug("Qos Specification {} assigned to Virtual Pool {} found", activeQos.getId(), vpoolId);
            return activeQos;
        }
    }
    throw APIException.internalServerErrors.noAssociatedQosForVirtualPool(vpoolId);
}
Also used : QosSpecification(com.emc.storageos.db.client.model.QosSpecification) URI(java.net.URI)

Example 9 with QosSpecification

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

the class QosService method getQosDetails.

/**
 * Get the details of given Qos for the given tenant
 *
 * @prereq none
 *
 * @param openstackTenantId the URN of the tenant
 * @param qosId the URN of the QoS
 *
 * @brief List Qos in detail
 * @return Qos detailed list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{qos_id}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public CinderQosDetail getQosDetails(@PathParam("tenant_id") String openstackTenantId, @PathParam("qos_id") String qosId) {
    CinderQosDetail qosDetailed = new CinderQosDetail();
    _log.debug("START get QoS specs detailed");
    URI qosURI = URIUtil.createId(QosSpecification.class, qosId);
    QosSpecification qosSpecification = _dbClient.queryObject(QosSpecification.class, qosURI);
    if (qosSpecification != null && hasTenantUsageAclOnQos(qosSpecification)) {
        _log.debug("Fetched Qos Specification, id: {}", qosSpecification.getId());
        qosDetailed.qos_spec = getDataFromQosSpecification(qosSpecification);
        // Self link points on a Virtual Pool assigned to Qos
        VirtualPool virtualPool = _dbClient.queryObject(VirtualPool.class, qosSpecification.getVirtualPoolId());
        if (virtualPool != null) {
            qosDetailed.setLink(DbObjectMapper.toLink(virtualPool));
        }
    }
    _log.debug("END get QoS specs detailed");
    return qosDetailed;
}
Also used : CinderQosDetail(com.emc.storageos.cinder.model.CinderQosDetail) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 10 with QosSpecification

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

the class QosService method getQosList.

/**
 * Get the summary list of all Qos for the given tenant
 *
 * @prereq none
 *
 * @param openstackTenantId the URN of the tenant
 *
 * @brief List Qos
 * @return Qos list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public CinderQosListRestResp getQosList(@PathParam("tenant_id") String openstackTenantId) {
    CinderQosListRestResp qosListResp = new CinderQosListRestResp();
    _log.debug("START get QoS list");
    List<URI> qosSpecsURI = _dbClient.queryByType(QosSpecification.class, true);
    Iterator<QosSpecification> qosIter = _dbClient.queryIterativeObjects(QosSpecification.class, qosSpecsURI);
    while (qosIter.hasNext()) {
        QosSpecification activeQos = qosIter.next();
        if (activeQos != null && hasTenantUsageAclOnQos(activeQos)) {
            _log.debug("Qos Specification found, id: {}", activeQos.getId());
            qosListResp.getQos_specs().add(getDataFromQosSpecification(activeQos));
        }
    }
    _log.debug("END get QoS list");
    return qosListResp;
}
Also used : CinderQosListRestResp(com.emc.storageos.cinder.model.CinderQosListRestResp) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

QosSpecification (com.emc.storageos.db.client.model.QosSpecification)11 URI (java.net.URI)8 StringMap (com.emc.storageos.db.client.model.StringMap)4 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Produces (javax.ws.rs.Produces)4 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)1 CinderQosDetail (com.emc.storageos.cinder.model.CinderQosDetail)1 CinderQosListRestResp (com.emc.storageos.cinder.model.CinderQosListRestResp)1 QosAssociationsRestResp (com.emc.storageos.cinder.model.QosAssociationsRestResp)1 DbClient (com.emc.storageos.db.client.DbClient)1 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 QuotaOfCinder (com.emc.storageos.db.client.model.QuotaOfCinder)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 Volume (com.emc.storageos.db.client.model.Volume)1 VpoolProtectionVarraySettings (com.emc.storageos.db.client.model.VpoolProtectionVarraySettings)1