use of com.emc.storageos.volumecontroller.impl.smis.job.SmisCleanupMetaVolumeMembersJob in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doCleanupMetaMembers.
@Override
public void doCleanupMetaMembers(final StorageSystem storageSystem, final 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()));
// Get meta volume members from the volume data
StringSet metaMembers = volume.getMetaVolumeMembers();
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 nativeId : metaMembers) {
CIMInstance volumeInstance = _helper.checkExists(storageSystem, _cimPath.getVolumePath(storageSystem, nativeId), false, false);
if (volumeInstance != null) {
// Check that volume is not "Composite Volume Member", "Usage" property
// equals 15
String usage = CIMPropertyFactory.getPropertyValue(volumeInstance, SmisConstants.CP_VOLUME_USAGE);
int usageInt = Integer.valueOf(usage);
_log.debug("doCleanupMetaMembers: Volume: " + nativeId + ", Usage of volume: " + usageInt);
if (usageInt != SmisConstants.COMPOSITE_ELEMENT_MEMBER) {
volumeIds.add(nativeId);
}
}
}
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));
String[] nativeIds = volumeIds.toArray(new String[0]);
// Prepare parameters and call method to delete meta members from array
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = _helper.getDeleteVolumesInputArguments(storageSystem, nativeIds);
CIMArgument[] outArgs = new CIMArgument[5];
SmisCleanupMetaVolumeMembersJob smisJobCompleter = null;
String returnElementsMethod;
if (storageSystem.getUsingSmis80()) {
returnElementsMethod = SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL;
} else {
returnElementsMethod = SmisConstants.EMC_RETURN_TO_STORAGE_POOL;
}
// volume create rollback)
if (cleanupCompleter.isWFStep()) {
// invoke async
_helper.invokeMethod(storageSystem, configSvcPath, returnElementsMethod, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCleanupMetaVolumeMembersJob(job, storageSystem.getId(), volume.getId(), cleanupCompleter)));
}
} else {
// invoke synchronously
smisJobCompleter = new SmisCleanupMetaVolumeMembersJob(null, storageSystem.getId(), volume.getId(), cleanupCompleter);
_helper.invokeMethodSynchronously(storageSystem, configSvcPath, returnElementsMethod, inArgs, outArgs, smisJobCompleter);
}
}
} else {
_log.info("doCleanupMetaMembers: No meta members stored for meta volume. Nothing to cleanup in array.");
cleanupCompleter.ready(_dbClient);
}
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
cleanupCompleter.error(_dbClient, error);
} 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