Search in sources :

Example 1 with HDSBlockMirrorDeleteJob

use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob in project coprhd-controller by CoprHD.

the class HDSMirrorOperations method deleteSingleVolumeMirror.

/**
 * Deletes mirror instance from StorageSystem
 */
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
        Set<String> thickLogicalUnitIdList = new HashSet<String>();
        Set<String> thinLogicalUnitIdList = new HashSet<String>();
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
        String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
        LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
        if (logicalUnit == null) {
            // related volume state (if any) has been deleted. skip
            // processing, if already deleted from array.
            log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
            // HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
            dbClient.markForDeletion(mirrorObj);
        } else {
            if (mirrorObj.getThinlyProvisioned()) {
                thinLogicalUnitIdList.add(logicalUnitObjectId);
            } else {
                thickLogicalUnitIdList.add(logicalUnitObjectId);
            }
            log.info(logMsgBuilder.toString());
            if (!thickLogicalUnitIdList.isEmpty()) {
                String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThickLUsJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
            if (!thinLogicalUnitIdList.isEmpty()) {
                String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
                if (null != asyncThinHDSJobId) {
                    ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
                } else {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
                }
            }
        }
        log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
    } catch (Exception e) {
        log.error("Problem in deleteSingleVolumeMirror: ", e);
        ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : HDSBlockMirrorDeleteJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException) HashSet(java.util.HashSet)

Aggregations

BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 HDSException (com.emc.storageos.hds.HDSException)1 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)1 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 HDSBlockMirrorDeleteJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockMirrorDeleteJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 HashSet (java.util.HashSet)1