Search in sources :

Example 1 with QosSpecification

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

the class QosService method recordOperation.

public void recordOperation(OperationTypeEnum opType, String evDesc, Object... extParam) {
    String evType;
    evType = opType.getEvType(true);
    _log.info("opType: {} detail: {}", opType.toString(), evType + ':' + evDesc);
    QosSpecification qosSpecification = (QosSpecification) extParam[0];
    StringBuilder specs = new StringBuilder();
    if (qosSpecification.getSpecs() != null) {
        for (Map.Entry<String, String> entry : qosSpecification.getSpecs().entrySet()) {
            specs.append(" ");
            specs.append(entry.getKey()).append(":").append(entry.getValue());
        }
    }
    switch(opType) {
        case CREATE_QOS:
            auditOp(opType, true, null, qosSpecification.getId().toString(), qosSpecification.getLabel(), qosSpecification.getConsumer(), specs.toString());
            break;
        case UPDATE_QOS:
            auditOp(opType, true, null, qosSpecification.getId().toString(), qosSpecification.getLabel(), qosSpecification.getConsumer(), specs.toString());
            break;
        case DELETE_QOS:
            auditOp(opType, true, null, qosSpecification.getId().toString(), qosSpecification.getLabel());
            break;
        default:
            _log.error("unrecognized qos operation type");
    }
}
Also used : QosSpecification(com.emc.storageos.db.client.model.QosSpecification) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 2 with QosSpecification

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

the class QosService method getQosAssociations.

/**
 * Get the detailed list of all associations for a given qos
 *
 * @prereq none
 *
 * @param openstackTenantId the URN of the tenant
 *
 * @brief List volumes in detail
 * @return Volume detailed list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{qos_id}/associations")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public QosAssociationsRestResp getQosAssociations(@PathParam("tenant_id") String openstackTenantId, @PathParam("qos_id") String qosId) {
    _log.debug("START get qos associations");
    QosAssociationsRestResp objQosRestResp = new QosAssociationsRestResp();
    URI qosURI = URIUtil.createId(QosSpecification.class, qosId);
    QosSpecification qosSpecification = _dbClient.queryObject(QosSpecification.class, qosURI);
    if (qosSpecification != null && hasTenantUsageAclOnQos(qosSpecification)) {
        objQosRestResp.getAssociation().add(getQosAssociation(qosSpecification));
    }
    _log.debug("END get qos association");
    return objQosRestResp;
}
Also used : QosAssociationsRestResp(com.emc.storageos.cinder.model.QosAssociationsRestResp) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) 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 3 with QosSpecification

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

the class QosService method createQosSpecification.

/**
 * Retrieves information from given Virtual Pool, creates and persist Qos object to the DB
 *
 * @param virtualPool Virtual Pool
 * @return QosSpecification filled with information from Virtual Pool
 */
public static QosSpecification createQosSpecification(VirtualPool virtualPool, DbClient dbClient) {
    _log.debug("Fetching data from Virtual Pool, id: {}", virtualPool.getId());
    QosSpecification qosSpecification = new QosSpecification();
    StringMap specs = new StringMap();
    String protocols = null;
    if (virtualPool.getProtocols() != null) {
        protocols = virtualPool.getProtocols().toString();
    }
    qosSpecification.setName(QOS_NAME + virtualPool.getLabel());
    qosSpecification.setConsumer(QOS_CONSUMER);
    qosSpecification.setLabel(virtualPool.getLabel());
    qosSpecification.setId(URIUtil.createId(QosSpecification.class));
    qosSpecification.setVirtualPoolId(virtualPool.getId());
    if (virtualPool.getSupportedProvisioningType() != null) {
        specs.put(SPEC_PROVISIONING_TYPE, virtualPool.getSupportedProvisioningType());
    }
    if (protocols != null) {
        specs.put(SPEC_PROTOCOL, protocols.substring(1, protocols.length() - 1));
    }
    if (virtualPool.getDriveType() != null) {
        specs.put(SPEC_DRIVE_TYPE, virtualPool.getDriveType());
    }
    if (VirtualPoolService.getSystemType(virtualPool) != null) {
        specs.put(SPEC_SYSTEM_TYPE, VirtualPoolService.getSystemType(virtualPool));
    }
    if (virtualPool.getMultivolumeConsistency() != null) {
        specs.put(SPEC_MULTI_VOL_CONSISTENCY, Boolean.toString(virtualPool.getMultivolumeConsistency()));
    }
    if (virtualPool.getArrayInfo() != null && virtualPool.getArrayInfo().get(LABEL_RAID_LEVEL) != null) {
        specs.put(SPEC_RAID_LEVEL, virtualPool.getArrayInfo().get(LABEL_RAID_LEVEL).toString());
    }
    if (virtualPool.getExpandable() != null) {
        specs.put(SPEC_EXPENDABLE, Boolean.toString(virtualPool.getExpandable()));
    }
    if (virtualPool.getNumPaths() != null) {
        specs.put(SPEC_MAX_SAN_PATHS, Integer.toString(virtualPool.getNumPaths()));
    }
    if (virtualPool.getMinPaths() != null) {
        specs.put(SPEC_MIN_SAN_PATHS, Integer.toString(virtualPool.getMinPaths()));
    }
    if (virtualPool.getMaxNativeContinuousCopies() != null) {
        specs.put(SPEC_MAX_BLOCK_MIRRORS, Integer.toString(virtualPool.getMaxNativeContinuousCopies()));
    }
    if (virtualPool.getPathsPerInitiator() != null) {
        specs.put(SPEC_PATHS_PER_INITIATOR, Integer.toString(virtualPool.getPathsPerInitiator()));
    }
    if (virtualPool.getHighAvailability() != null) {
        specs.put(SPEC_HIGH_AVAILABILITY, virtualPool.getHighAvailability());
    }
    if (virtualPool.getMaxNativeSnapshots() != null) {
        if (virtualPool.getMaxNativeSnapshots().equals(UNLIMITED_SNAPSHOTS)) {
            specs.put(SPEC_MAX_SNAPSHOTS, LABEL_UNLIMITED_SNAPSHOTS);
        } else if (virtualPool.getMaxNativeSnapshots().equals(DISABLED_SNAPSHOTS)) {
            specs.put(SPEC_MAX_SNAPSHOTS, LABEL_DISABLED_SNAPSHOTS);
        } else {
            specs.put(SPEC_MAX_SNAPSHOTS, Integer.toString(virtualPool.getMaxNativeSnapshots()));
        }
    }
    qosSpecification.setSpecs(specs);
    // Create new QoS in the DB
    dbClient.createObject(qosSpecification);
    return qosSpecification;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) QosSpecification(com.emc.storageos.db.client.model.QosSpecification)

Example 4 with QosSpecification

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

the class QualityOfServiceMigration method getDataFromVirtualPool.

/**
 * Retrieves information from given Virtual Pool
 *
 * @param virtualPool Virtual Pool
 * @return QosSpecification filled with information from Virtual Pool
 */
private QosSpecification getDataFromVirtualPool(VirtualPool virtualPool) throws MigrationCallbackException {
    _log.debug("Fetching data from Virtual Pool, id: {}", virtualPool.getId());
    QosSpecification qos = null;
    try {
        qos = new QosSpecification();
        StringMap specs = new StringMap();
        qos.setName(QOS_NAME + virtualPool.getLabel());
        qos.setConsumer(QOS_CONSUMER);
        qos.setLabel(virtualPool.getLabel());
        qos.setId(URIUtil.createId(QosSpecification.class));
        qos.setVirtualPoolId(virtualPool.getId());
        String protocols = null;
        if (virtualPool.getProtocols() != null) {
            protocols = virtualPool.getProtocols().toString();
        }
        if (protocols != null) {
            specs.put(SPEC_PROTOCOL, protocols.substring(1, protocols.length() - 1));
        }
        if (virtualPool.getSupportedProvisioningType() != null) {
            specs.put(SPEC_PROVISIONING_TYPE, virtualPool.getSupportedProvisioningType());
        }
        if (virtualPool.getDriveType() != null) {
            specs.put(SPEC_DRIVE_TYPE, virtualPool.getDriveType());
        }
        String systemType = getSystemType(virtualPool);
        if (systemType != null) {
            specs.put(SPEC_SYSTEM_TYPE, systemType);
        }
        if (virtualPool.getMultivolumeConsistency() != null) {
            specs.put(SPEC_MULTI_VOL_CONSISTENCY, Boolean.toString(virtualPool.getMultivolumeConsistency()));
        }
        if (virtualPool.getArrayInfo() != null && virtualPool.getArrayInfo().get(RAID_LEVEL) != null) {
            specs.put(SPEC_RAID_LEVEL, virtualPool.getArrayInfo().get(RAID_LEVEL).toString());
        }
        if (virtualPool.getExpandable() != null) {
            specs.put(SPEC_EXPENDABLE, Boolean.toString(virtualPool.getExpandable()));
        }
        if (virtualPool.getNumPaths() != null) {
            specs.put(SPEC_MAX_SAN_PATHS, Integer.toString(virtualPool.getNumPaths()));
        }
        if (virtualPool.getMinPaths() != null) {
            specs.put(SPEC_MIN_SAN_PATHS, Integer.toString(virtualPool.getMinPaths()));
        }
        if (virtualPool.getMaxNativeContinuousCopies() != null) {
            specs.put(SPEC_MAX_BLOCK_MIRRORS, Integer.toString(virtualPool.getMaxNativeContinuousCopies()));
        }
        if (virtualPool.getPathsPerInitiator() != null) {
            specs.put(SPEC_PATHS_PER_INITIATOR, Integer.toString(virtualPool.getPathsPerInitiator()));
        }
        if (virtualPool.getHighAvailability() != null) {
            specs.put(SPEC_HIGH_AVAILABILITY, virtualPool.getHighAvailability());
        }
        if (virtualPool.getMaxNativeSnapshots() != null) {
            if (virtualPool.getMaxNativeSnapshots().equals(UNLIMITED_SNAPSHOTS)) {
                specs.put(SPEC_MAX_SNAPSHOTS, LABEL_UNLIMITED_SNAPSHOTS);
            } else if (virtualPool.getMaxNativeSnapshots().equals(DISABLED_SNAPSHOTS)) {
                specs.put(SPEC_MAX_SNAPSHOTS, LABEL_DISABLED_SNAPSHOTS);
            } else {
                specs.put(SPEC_MAX_SNAPSHOTS, Integer.toString(virtualPool.getMaxNativeSnapshots()));
            }
        }
        qos.setSpecs(specs);
    } catch (Exception e) {
        String errorMsg = String.format("%s encounter unexpected error %s", getName(), e.getMessage());
        _log.error(errorMsg);
        throw new MigrationCallbackException(errorMsg, e);
    }
    return qos;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 5 with QosSpecification

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

the class QualityOfServiceMigration method process.

@Override
public void process() throws MigrationCallbackException {
    _log.debug("START - QualityOfServiceMigration callback");
    DbClient _dbClient = getDbClient();
    List<QosSpecification> qosSpecifications = new ArrayList<>();
    List<URI> virtualPoolURIs = _dbClient.queryByType(VirtualPool.class, true);
    Iterator<VirtualPool> vpIter = _dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs);
    while (vpIter.hasNext()) {
        VirtualPool virtualPool = vpIter.next();
        if (virtualPool != null) {
            _log.info("Virtual Pool found, id: {}", virtualPool.getId());
            QosSpecification qosSpecification = getDataFromVirtualPool(virtualPool);
            qosSpecifications.add(qosSpecification);
        }
    }
    if (!qosSpecifications.isEmpty()) {
        _dbClient.createObject(qosSpecifications);
    }
    _log.debug("END - QualityOfServiceMigration callback");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

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