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