use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCleanupMetaVolumeMembersJob in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doCleanupMetaMembers.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCleanupMetaMembers(com.emc.storageos.db.client.model.StorageSystem,
* com.emc.storageos.db.client.model.Volume,
* com.emc.storageos.volumecontroller.impl.block.taskcompleter.CleanupMetaVolumeMembersCompleter)
*/
@Override
public void doCleanupMetaMembers(StorageSystem storageSystem, Volume volume, CleanupMetaVolumeMembersCompleter cleanupCompleter) throws DeviceControllerException {
// Remove meta member volumes from storage device
try {
log.info(String.format("doCleanupMetaMembers Start - Array: %s, Volume: %s", storageSystem.getSerialNumber(), volume.getLabel()));
// Load meta volume members from WF data
String sourceStepId = cleanupCompleter.getSourceStepId();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getUsername(), storageSystem.getSmisPassword());
List<String> metaMembers = (ArrayList<String>) WorkflowService.getInstance().loadStepData(sourceStepId);
if (metaMembers != null && !metaMembers.isEmpty()) {
log.info(String.format("doCleanupMetaMembers: Members stored for meta volume: %n %s", metaMembers));
// Check if volumes still exist in array and if it is not composite member (already
// added to the meta volume)
Set<String> volumeIds = new HashSet<String>();
for (String logicalUnitObjectId : metaMembers) {
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(HDSUtils.getSystemObjectID(storageSystem), logicalUnitObjectId);
if (logicalUnit != null) {
log.debug("doCleanupMetaMembers: Volume: " + logicalUnitObjectId + ", Usage of volume: " + logicalUnit.getComposite());
if (logicalUnit.getComposite() != HDSConstants.COMPOSITE_ELEMENT_MEMBER) {
volumeIds.add(logicalUnitObjectId);
}
}
}
if (volumeIds.isEmpty()) {
log.info("doCleanupMetaMembers: No meta members to cleanup in array.");
cleanupCompleter.ready(dbClient);
} else {
log.info(String.format("doCleanupMetaMembers: Members to cleanup in array: %n %s", volumeIds));
// Prepare parameters and call method to delete meta members from array
HDSCleanupMetaVolumeMembersJob hdsJobCompleter = null;
// When "cleanup" is separate workflow step, call async (for example rollback
// step in volume expand)
// Otherwise, call synchronously (for example when cleanup is part of meta
// volume create rollback)
String asyncMessageId = hdsApiClient.deleteThickLogicalUnits(HDSUtils.getSystemObjectID(storageSystem), volumeIds, storageSystem.getModel());
if (asyncMessageId == null) {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
}
if (cleanupCompleter.isWFStep()) {
if (asyncMessageId != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSCleanupMetaVolumeMembersJob(asyncMessageId, storageSystem.getId(), volume.getId(), cleanupCompleter)));
}
} else {
// invoke synchronously
hdsJobCompleter = new HDSCleanupMetaVolumeMembersJob(asyncMessageId, storageSystem.getId(), volume.getId(), cleanupCompleter);
((HDSMetaVolumeOperations) metaVolumeOperations).invokeMethodSynchronously(hdsApiFactory, asyncMessageId, hdsJobCompleter);
}
}
} else {
log.info("doCleanupMetaMembers: No meta members stored for meta volume. Nothing to cleanup in array.");
cleanupCompleter.ready(dbClient);
}
} catch (Exception e) {
log.error("Problem in doCleanupMetaMembers: ", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("doCleanupMetaMembers", e.getMessage());
cleanupCompleter.error(dbClient, error);
}
log.info(String.format("doCleanupMetaMembers End - Array: %s, Volume: %s", storageSystem.getSerialNumber(), volume.getLabel()));
}
Aggregations