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");
}
}
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;
}
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;
}
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;
}
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");
}
Aggregations