use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class BlockVolumeIngestOrchestrator method ingestBlockObjects.
@Override
protected <T extends BlockObject> T ingestBlockObjects(IngestionRequestContext requestContext, Class<T> clazz) throws IngestionException {
UnManagedVolume unManagedVolume = requestContext.getCurrentUnmanagedVolume();
boolean unManagedVolumeExported = requestContext.getVolumeContext().isVolumeExported();
Volume volume = null;
List<BlockSnapshotSession> snapSessions = new ArrayList<BlockSnapshotSession>();
URI unManagedVolumeUri = unManagedVolume.getId();
String volumeNativeGuid = unManagedVolume.getNativeGuid().replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
volume = VolumeIngestionUtil.checkIfVolumeExistsInDB(volumeNativeGuid, _dbClient);
// Check if ingested volume has export masks pending for ingestion.
if (isExportIngestionPending(volume, unManagedVolumeUri, unManagedVolumeExported)) {
return clazz.cast(volume);
}
if (null == volume) {
validateUnManagedVolume(unManagedVolume, requestContext.getVpool(unManagedVolume));
// @TODO Need to revisit this. In 8.x Provider, ReplicationGroup is automatically created when a volume is associated to a
// StorageGroup.
// checkUnManagedVolumeAddedToCG(unManagedVolume, virtualArray, tenant, project, vPool);
checkVolumeExportState(unManagedVolume, unManagedVolumeExported);
checkVPoolValidForExportInitiatorProtocols(requestContext.getVpool(unManagedVolume), unManagedVolume);
checkHostIOLimits(requestContext.getVpool(unManagedVolume), unManagedVolume, unManagedVolumeExported);
StoragePool pool = validateAndReturnStoragePoolInVAarray(unManagedVolume, requestContext.getVarray(unManagedVolume));
// validate quota is exceeded for storage systems and pools
checkSystemResourceLimitsExceeded(requestContext.getStorageSystem(), unManagedVolume, requestContext.getExhaustedStorageSystems());
checkPoolResourceLimitsExceeded(requestContext.getStorageSystem(), pool, unManagedVolume, requestContext.getExhaustedPools());
String autoTierPolicyId = getAutoTierPolicy(unManagedVolume, requestContext.getStorageSystem(), requestContext.getVpool(unManagedVolume));
validateAutoTierPolicy(autoTierPolicyId, unManagedVolume, requestContext.getVpool(unManagedVolume));
volume = createVolume(requestContext, volumeNativeGuid, pool, unManagedVolume, autoTierPolicyId);
}
if (volume != null) {
String syncActive = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.IS_SYNC_ACTIVE.toString(), unManagedVolume.getVolumeInformation());
boolean isSyncActive = (null != syncActive) ? Boolean.parseBoolean(syncActive) : false;
volume.setSyncActive(isSyncActive);
if (VolumeIngestionUtil.isFullCopy(unManagedVolume)) {
_logger.info("Setting clone related properties {}", unManagedVolume.getId());
String replicaState = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REPLICA_STATE.toString(), unManagedVolume.getVolumeInformation());
volume.setReplicaState(replicaState);
String replicationGroupName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.FULL_COPY_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
if (replicationGroupName != null && !replicationGroupName.isEmpty()) {
volume.setReplicationGroupInstance(replicationGroupName);
}
}
// Create snapshot sessions for each synchronization aspect for the volume.
StringSet syncAspectInfoForVolume = PropertySetterUtil.extractValuesFromStringSet(SupportedVolumeInformation.SNAPSHOT_SESSIONS.toString(), unManagedVolume.getVolumeInformation());
if ((syncAspectInfoForVolume != null) && (!syncAspectInfoForVolume.isEmpty())) {
Project project = requestContext.getProject();
// If this is a vplex backend volume, then the front end project should be set as snapshot session's project
if (requestContext instanceof VplexVolumeIngestionContext && VolumeIngestionUtil.isVplexBackendVolume(unManagedVolume)) {
project = ((VplexVolumeIngestionContext) requestContext).getFrontendProject();
}
for (String syncAspectInfo : syncAspectInfoForVolume) {
String[] syncAspectInfoComponents = syncAspectInfo.split(":");
String syncAspectName = syncAspectInfoComponents[0];
String syncAspectObjPath = syncAspectInfoComponents[1];
// Make sure it is not already created.
URIQueryResultList queryResults = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotSessionBySessionInstance(syncAspectObjPath), queryResults);
Iterator<URI> queryResultsIter = queryResults.iterator();
if (!queryResultsIter.hasNext()) {
BlockSnapshotSession session = new BlockSnapshotSession();
session.setId(URIUtil.createId(BlockSnapshotSession.class));
session.setLabel(syncAspectName);
session.setSessionLabel(syncAspectName);
session.setParent(new NamedURI(volume.getId(), volume.getLabel()));
session.setProject(new NamedURI(project.getId(), project.getLabel()));
session.setStorageController(volume.getStorageController());
session.setSessionInstance(syncAspectObjPath);
StringSet linkedTargetURIs = new StringSet();
URIQueryResultList snapshotQueryResults = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotBySettingsInstance(syncAspectObjPath), snapshotQueryResults);
Iterator<URI> snapshotQueryResultsIter = snapshotQueryResults.iterator();
while (snapshotQueryResultsIter.hasNext()) {
linkedTargetURIs.add(snapshotQueryResultsIter.next().toString());
}
session.setLinkedTargets(linkedTargetURIs);
session.setOpStatus(new OpStatusMap());
snapSessions.add(session);
}
}
if (!snapSessions.isEmpty()) {
_dbClient.createObject(snapSessions);
}
}
}
// Note that a VPLEX backend volume can also be a snapshot target volume.
// When the VPLEX ingest orchestrator is executed, it gets the ingestion
// strategy for the backend volume and executes it. If the backend volume
// is both a snapshot and a VPLEX backend volume, this local volume ingest
// strategy is invoked and a Volume instance will result. That is fine because
// we need to represent that VPLEX backend volume. However, we also need a
// BlockSnapshot instance to represent the snapshot target volume. Therefore,
// if the unmanaged volume is also a snapshot target volume, we get and
// execute the local snapshot ingest strategy to create this BlockSnapshot
// instance and we add it to the created object list. Note that since the
// BlockSnapshot is added to the created objects list and the Volume and
// BlockSnapshot instance will have the same native GUID, we must be careful
// about adding the Volume to the created object list in the VPLEX ingestion
// strategy.
BlockObject snapshot = null;
if (VolumeIngestionUtil.isSnapshot(unManagedVolume)) {
String strategyKey = ReplicationStrategy.LOCAL.name() + "_" + VolumeType.SNAPSHOT.name();
IngestStrategy ingestStrategy = ingestStrategyFactory.getIngestStrategy(IngestStrategyEnum.getIngestStrategy(strategyKey));
snapshot = ingestStrategy.ingestBlockObjects(requestContext, BlockSnapshot.class);
requestContext.getBlockObjectsToBeCreatedMap().put(snapshot.getNativeGuid(), snapshot);
}
// Run this always when volume NO_PUBLIC_ACCESS
if (markUnManagedVolumeInactive(requestContext, volume)) {
_logger.info("All the related replicas and parent has been ingested ", unManagedVolume.getNativeGuid());
// RP masks.
if (!unManagedVolumeExported && !VolumeIngestionUtil.checkUnManagedResourceIsRecoverPointEnabled(unManagedVolume)) {
unManagedVolume.setInactive(true);
requestContext.getUnManagedVolumesToBeDeleted().add(unManagedVolume);
}
} else if (volume != null) {
_logger.info("Not all the parent/replicas of unManagedVolume {} have been ingested , hence marking as internal", unManagedVolume.getNativeGuid());
volume.addInternalFlags(INTERNAL_VOLUME_FLAGS);
for (BlockSnapshotSession snapSession : snapSessions) {
snapSession.addInternalFlags(INTERNAL_VOLUME_FLAGS);
}
_dbClient.updateObject(snapSessions);
}
return clazz.cast(volume);
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class BlockVplexVolumeIngestOrchestrator method ingestBackendVolumes.
/**
* Ingests the backend volumes and any related replicas.
*
* Calls ingestBlockObjects by getting a nested IngestStrategy
* for each backend volume or replica from the IngestStrategyFactory.
*
* @param backendRequestContext the VplexBackendIngestionContext for the parent virtual volume
*
* @throws IngestionException
*/
private void ingestBackendVolumes(IngestionRequestContext requestContext, VplexVolumeIngestionContext backendRequestContext) throws IngestionException {
while (backendRequestContext.hasNext()) {
UnManagedVolume associatedVolume = backendRequestContext.next();
String sourceClusterId = getClusterNameForVarray(backendRequestContext.getVarray(associatedVolume), requestContext.getStorageSystem());
String haClusterId = getClusterNameForVarray(backendRequestContext.getHaVarray(associatedVolume), requestContext.getStorageSystem());
_logger.info("the source cluster id is {} and the high availability cluster id is {}", sourceClusterId, haClusterId);
backendRequestContext.setHaClusterId(haClusterId);
_logger.info("Ingestion started for vplex backend volume {}", associatedVolume.getNativeGuid());
try {
validateBackendVolumeVpool(associatedVolume, backendRequestContext.getVpool(associatedVolume));
IngestStrategy ingestStrategy = ingestStrategyFactory.buildIngestStrategy(associatedVolume, IngestStrategyFactory.DISREGARD_PROTECTION);
@SuppressWarnings("unchecked") BlockObject blockObject = ingestStrategy.ingestBlockObjects(backendRequestContext, VolumeIngestionUtil.getBlockObjectClass(associatedVolume));
if (null == blockObject) {
// ingestion did not succeed, but in case it wasn't, throw one
throw IngestionException.exceptions.generalVolumeException(associatedVolume.getLabel(), "check the logs for more details");
}
// Note that a VPLEX backend volume could also be a snapshot target volume.
// When this is the case, the local volume ingest strategy is what will be
// retrieved and executed. As a result, the object returned will be a
// Volume instance not a BlockSnapshot instance. However, the local volume
// ingest strategy realizes that the volume may also be a snapshot target
// volume and creates the BlockSnapshot instance to represent the snapshot
// target volume and adds this BlockSnapshot instance to the created objects
// list. Because the BlockSnapshot and Volume instances will have the same
// native GUID, as they represent the same physical volume, we can't
// add the Volume to the created objects list as it would just replace
// the BlockSnapshot instance and only the Volume would get created. So,
// we first move the snapshot to the created snapshots list before adding
// the volume to the created objects list.
Map<String, BlockObject> createdObjectMap = backendRequestContext.getBlockObjectsToBeCreatedMap();
String blockObjectNativeGuid = blockObject.getNativeGuid();
if (createdObjectMap.containsKey(blockObjectNativeGuid)) {
BlockObject createdBlockObject = createdObjectMap.get(blockObjectNativeGuid);
if (createdBlockObject instanceof BlockSnapshot) {
_logger.info("Backend ingestion created block snapshot {}", blockObjectNativeGuid);
// The snapshot will be created with the backend volume project, so we
// need to update that to the frontend project.
((BlockSnapshot) createdBlockObject).setProject(new NamedURI(backendRequestContext.getFrontendProject().getId(), createdBlockObject.getLabel()));
backendRequestContext.getCreatedSnapshotMap().put(blockObjectNativeGuid, (BlockSnapshot) createdBlockObject);
createdObjectMap.put(blockObjectNativeGuid, blockObject);
} else {
// This should not happen. If there is an instance in the created
// objects list with the same guid as the ingested block object
// it must be that the backend volume is also a snapshot target
// volume and the strategy created the BlockSnapshot instance and
// added it to the created objects list.
_logger.warn("Unexpected object in created objects list during backend ingestion {}:{}", blockObjectNativeGuid, createdBlockObject.getLabel());
}
} else {
createdObjectMap.put(blockObjectNativeGuid, blockObject);
}
backendRequestContext.getProcessedUnManagedVolumeMap().put(associatedVolume.getNativeGuid(), backendRequestContext.getVolumeContext());
_logger.info("Ingestion ended for backend volume {}", associatedVolume.getNativeGuid());
} catch (Exception ex) {
_logger.error(ex.getLocalizedMessage());
backendRequestContext.rollback();
throw ex;
}
}
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class ConsistencyGroupSnapshotService method deleteConsistencyGroupSnapshot.
/**
* Delete a consistency group snapshot
*
* @param openstackTenantId
* openstack tenant id
* @param consistencyGroupSnapshot_id
* consistency group snapshot id
* @brief Delete a consistency group snapshot
* @param isV1Call
* Cinder V1 call
* @param header
* Http Header
* @return Response
*/
@DELETE
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{consistencyGroupSnapshot_id}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public Response deleteConsistencyGroupSnapshot(@PathParam("tenant_id") String openstackTenantId, @PathParam("consistencyGroupSnapshot_id") String consistencyGroupSnapshot_id, @HeaderParam("X-Cinder-V1-Call") String isV1Call, @Context HttpHeaders header) {
final BlockSnapshot snapshot = findSnapshot(consistencyGroupSnapshot_id, openstackTenantId);
final URI snapshotCgURI = snapshot.getConsistencyGroup();
URIQueryResultList uris = getCinderHelper().getConsistencyGroupsUris(openstackTenantId, getUserFromContext());
boolean isConsistencyGroupHasSnapshotId = false;
if (uris != null && snapshotCgURI != null) {
for (URI blockCGUri : uris) {
BlockConsistencyGroup blockCG = _dbClient.queryObject(BlockConsistencyGroup.class, blockCGUri);
if (blockCG != null && !blockCG.getInactive()) {
if (snapshotCgURI.equals(blockCG.getId())) {
isConsistencyGroupHasSnapshotId = true;
}
}
}
}
if (isConsistencyGroupHasSnapshotId) {
// Generate task id
final String task = UUID.randomUUID().toString();
TaskList response = new TaskList();
// Not an error if the snapshot we try to delete is already deleted
if (snapshot.getInactive()) {
Operation op = new Operation();
op.ready("The consistency group snapshot has already been deactivated");
op.setResourceType(ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP_SNAPSHOT);
_dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), task, op);
TaskResourceRep taskResponse = toTask(snapshot, task, op);
if (taskResponse.getState().equals("ready")) {
return Response.status(202).build();
}
}
Volume volume = _permissionsHelper.getObjectById(snapshot.getParent(), Volume.class);
BlockServiceApi blockServiceApiImpl = BlockService.getBlockServiceImpl(volume, _dbClient);
blockServiceApiImpl.deleteSnapshot(snapshot, Arrays.asList(snapshot), task, VolumeDeleteTypeEnum.FULL.name());
auditBlockConsistencyGroup(OperationTypeEnum.DELETE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), snapshot.getLabel());
return Response.status(202).build();
} else {
return CinderApiUtils.createErrorResponse(400, "Snapshot not attached to any active consistencygroup");
}
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class ConsistencyGroupSnapshotService method createConsistencyGroupSnapshot.
/**
* Create consistency group snapshot
*
* @param openstackTenantId
* openstack tenant Id
* @param param
* Pojo class to bind request
* @param isV1Call
* cinder V1 api
* @param header
* HTTP header
* @brief Create Consistency Group Snapshot
* @return Response
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createConsistencyGroupSnapshot(@PathParam("tenant_id") String openstackTenantId, final ConsistencyGroupSnapshotCreateRequest param, @HeaderParam("X-Cinder-V1-Call") String isV1Call, @Context HttpHeaders header) {
// Query Consistency Group
final String consistencyGroupId = param.cgsnapshot.consistencygroup_id;
final BlockConsistencyGroup consistencyGroup = findConsistencyGroup(consistencyGroupId, openstackTenantId);
if (consistencyGroup == null) {
_log.error("Not Found : No Such Consistency Group Found {}", consistencyGroupId);
return CinderApiUtils.createErrorResponse(404, "Not Found : No Such Consistency Group Found");
} else if (!consistencyGroupId.equals(CinderApiUtils.splitString(consistencyGroup.getId().toString(), ":", 3))) {
_log.error("Bad Request : Invalid Snapshot Id {} : Please enter valid or full Id", consistencyGroupId);
return CinderApiUtils.createErrorResponse(400, "Bad Request : No such consistency id exist, Please enter valid or full Id");
}
if (!isSnapshotCreationpermissible(consistencyGroup)) {
_log.error("Bad Request : vpool not being configured for the snapshots creation");
return CinderApiUtils.createErrorResponse(400, "Bad Request : vpool not being configured for the snapshots creation");
}
// system types.
if (!consistencyGroup.created()) {
CinderApiUtils.createErrorResponse(400, "No such consistency group created");
}
Project project = getCinderHelper().getProject(openstackTenantId, getUserFromContext());
URI cgStorageControllerURI = consistencyGroup.getStorageController();
if (!NullColumnValueGetter.isNullURI(cgStorageControllerURI)) {
// No snapshots for VPLEX consistency groups.
StorageSystem cgStorageController = _dbClient.queryObject(StorageSystem.class, cgStorageControllerURI);
if ((DiscoveredDataObject.Type.vplex.name().equals(cgStorageController.getSystemType())) && (!consistencyGroup.checkForType(Types.LOCAL))) {
CinderApiUtils.createErrorResponse(400, "can't create snapshot for VPLEX");
}
}
// Get the block service implementation
BlockServiceApi blockServiceApiImpl = getBlockServiceImpl(consistencyGroup);
// Get the volumes in the consistency group.
List<Volume> volumeList = blockServiceApiImpl.getActiveCGVolumes(consistencyGroup);
_log.info("Active CG volume list : " + volumeList);
// Generate task id
String taskId = UUID.randomUUID().toString();
// Set snapshot type.
String snapshotType = BlockSnapshot.TechnologyType.NATIVE.toString();
if (consistencyGroup.checkForType(BlockConsistencyGroup.Types.RP)) {
snapshotType = BlockSnapshot.TechnologyType.RP.toString();
} else if ((!volumeList.isEmpty()) && (volumeList.get(0).checkForSRDF())) {
snapshotType = BlockSnapshot.TechnologyType.SRDF.toString();
}
// Determine the snapshot volume for RP.
Volume snapVolume = null;
if (consistencyGroup.checkForType(BlockConsistencyGroup.Types.RP)) {
for (Volume volumeToSnap : volumeList) {
// Get the RP source volume.
if (volumeToSnap.getPersonality() != null && volumeToSnap.getPersonality().equals(Volume.PersonalityTypes.SOURCE.toString())) {
snapVolume = volumeToSnap;
break;
}
}
} else if (!volumeList.isEmpty()) {
// Any volume.
snapVolume = volumeList.get(0);
}
// Set the create inactive flag.
Boolean createInactive = Boolean.FALSE;
Boolean readOnly = Boolean.FALSE;
// Validate the snapshot request.
String snapshotName = param.cgsnapshot.name;
blockServiceApiImpl.validateCreateSnapshot(snapVolume, volumeList, snapshotType, snapshotName, readOnly, getFullCopyManager());
// Prepare and create the snapshots for the group.
List<URI> snapIdList = new ArrayList<URI>();
List<BlockSnapshot> snapshotList = new ArrayList<BlockSnapshot>();
TaskList response = new TaskList();
snapshotList.addAll(blockServiceApiImpl.prepareSnapshots(volumeList, snapshotType, snapshotName, snapIdList, taskId));
for (BlockSnapshot snapshot : snapshotList) {
response.getTaskList().add(toTask(snapshot, taskId));
}
blockServiceApiImpl.createSnapshot(snapVolume, snapIdList, snapshotType, createInactive, readOnly, taskId);
auditBlockConsistencyGroup(OperationTypeEnum.CREATE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, param.cgsnapshot.name, consistencyGroup.getId().toString());
ConsistencyGroupSnapshotCreateResponse cgSnapshotCreateRes = new ConsistencyGroupSnapshotCreateResponse();
for (TaskResourceRep rep : response.getTaskList()) {
URI snapshotUri = rep.getResource().getId();
BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshotUri);
snap.setId(snapshotUri);
snap.setConsistencyGroup(consistencyGroup.getId());
snap.setLabel(snapshotName);
if (snap != null) {
StringMap extensions = snap.getExtensions();
if (extensions == null) {
extensions = new StringMap();
}
extensions.put("status", CinderConstants.ComponentStatus.CREATING.getStatus().toLowerCase());
extensions.put("taskid", rep.getId().toString());
snap.setExtensions(extensions);
ScopedLabelSet tagSet = new ScopedLabelSet();
snap.setTag(tagSet);
tagSet.add(new ScopedLabel(project.getTenantOrg().getURI().toString(), CinderApiUtils.splitString(snapshotUri.toString(), ":", 3)));
}
_dbClient.updateObject(snap);
cgSnapshotCreateRes.id = CinderApiUtils.splitString(snapshotUri.toString(), ":", 3);
cgSnapshotCreateRes.name = param.cgsnapshot.name;
}
return CinderApiUtils.getCinderResponse(cgSnapshotCreateRes, header, true, CinderConstants.STATUS_OK);
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class QuotaHelper method getStorageStats.
/**
* Get usage statistics(like total number of volumes, snapshots and total size) for given vpool
*
* @prereq none
*
* @param vpool
*
* @brief get statistics
* @return UsageStats
*/
public UsageStats getStorageStats(URI vpool, URI projectId) {
UsageStats objStats = new UsageStats();
double totalSnapshotsUsed = 0;
double totalSizeUsed = 0;
long totalVolumesUsed = 0;
URIQueryResultList uris = new URIQueryResultList();
if (vpool != null) {
URIQueryResultList volUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolVolumeConstraint(vpool), volUris);
for (URI voluri : volUris) {
Volume volume = _dbClient.queryObject(Volume.class, voluri);
if (volume != null && !volume.getInactive() && (volume.getProject().getURI().toString().equals(projectId.toString()))) {
totalSizeUsed += ((double) volume.getCapacity() / GB);
totalVolumesUsed++;
}
URIQueryResultList snapList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(voluri), snapList);
for (URI snapUri : snapList) {
BlockSnapshot blockSnap = _dbClient.queryObject(BlockSnapshot.class, snapUri);
if (blockSnap != null && !blockSnap.getInactive()) {
_log.info("ProvisionedCapacity = {} ", blockSnap.getProvisionedCapacity());
totalSizeUsed += ((double) blockSnap.getProvisionedCapacity() / GB);
totalSnapshotsUsed++;
}
}
}
} else {
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getProjectVolumeConstraint(projectId), uris);
for (URI volUri : uris) {
Volume volume = _dbClient.queryObject(Volume.class, volUri);
if (volume != null && !volume.getInactive()) {
totalSizeUsed += ((double) volume.getCapacity() / GB);
totalVolumesUsed++;
}
URIQueryResultList snapList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volUri), snapList);
for (URI snapUri : snapList) {
BlockSnapshot blockSnap = _dbClient.queryObject(BlockSnapshot.class, snapUri);
if (blockSnap != null && !blockSnap.getInactive()) {
totalSizeUsed += ((double) blockSnap.getProvisionedCapacity() / GB);
totalSnapshotsUsed++;
}
}
}
}
objStats.snapshots = (long) totalSnapshotsUsed;
objStats.volumes = totalVolumesUsed;
objStats.spaceUsed = (long) (Math.round(totalSizeUsed));
return objStats;
}
Aggregations