Search in sources :

Example 1 with SmisCleanupMetaVolumeMembersJob

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()));
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) SmisCleanupMetaVolumeMembersJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCleanupMetaVolumeMembersJob) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) StringSet(com.emc.storageos.db.client.model.StringSet) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) HashSet(java.util.HashSet) CIMArgument(javax.cim.CIMArgument)

Aggregations

AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 SmisCleanupMetaVolumeMembersJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisCleanupMetaVolumeMembersJob)1 HashSet (java.util.HashSet)1 CIMArgument (javax.cim.CIMArgument)1 CIMInstance (javax.cim.CIMInstance)1 CIMObjectPath (javax.cim.CIMObjectPath)1 WBEMException (javax.wbem.WBEMException)1