Search in sources :

Example 46 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class ExportCreateCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        super.complete(dbClient, status, coded);
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        Operation operation = new Operation();
        switch(status) {
            case error:
                operation.error(coded);
                break;
            case ready:
                operation.ready();
                break;
            case suspended_no_error:
                operation.suspendedNoError();
                break;
            case suspended_error:
                operation.suspendedError(coded);
                break;
            default:
                break;
        }
        exportGroup.getOpStatus().updateTaskStatus(getOpId(), operation);
        // then make sure that the inactive flag is set to true
        if (!hasActiveMasks(dbClient, exportGroup)) {
            exportGroup.setInactive(status != Operation.Status.ready && status != Operation.Status.suspended_no_error);
        }
        // In the case of RecoverPoint bookmark exports, the volumes map could contain additional objects
        // that are being exported. Adding the object references to the ExportGroup here, ensures it aligns
        // with the ExportMask objects.
        _log.info(String.format("Adding block objects %s to export group %s.", volumeMap, exportGroup.getId()));
        exportGroup.addVolumes(volumeMap);
        dbClient.updateObject(exportGroup);
        _log.info("export_create completer: done");
        _log.info(String.format("Done ExportMaskCreate - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        recordBlockExportOperation(dbClient, OperationTypeEnum.CREATE_EXPORT_GROUP, status, eventMessage(status, exportGroup), exportGroup);
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskCreate - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Operation(com.emc.storageos.db.client.model.Operation) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 47 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class ExportMaskAddVolumeCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
        if (exportMask == null) {
            _log.warn("Export mask was null for task {}", getOpId());
            return;
        }
        if (shouldUpdateDatabase(status)) {
            for (URI volumeURI : _volumes) {
                BlockObject volume = BlockObject.fetch(dbClient, volumeURI);
                _log.info(String.format("Done ExportMaskAddVolume - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
                exportMask.removeFromExistingVolumes(volume);
                exportMask.addToUserCreatedVolumes(volume);
            }
            exportMask.setCreatedBySystem(true);
            ExportMaskUtils.setExportMaskResource(dbClient, exportGroup, exportMask);
            exportMask.addVolumes(_volumeMap);
            if (getExportGroups() != null && !getExportGroups().isEmpty()) {
                List<ExportGroup> egs = dbClient.queryObject(ExportGroup.class, getExportGroups());
                for (ExportGroup eg : egs) {
                    eg.addExportMask(exportMask.getId());
                    ExportUtils.reconcileHLUs(dbClient, eg, exportMask, _volumeMap);
                }
                dbClient.updateObject(egs);
            } else {
                exportGroup.addExportMask(exportMask.getId());
                ExportUtils.reconcileHLUs(dbClient, exportGroup, exportMask, _volumeMap);
                dbClient.updateObject(exportGroup);
            }
            dbClient.updateObject(exportMask);
            updatePortGroupVolumeCount(exportMask.getPortGroup(), dbClient);
            // on rollback if subsequent steps in the workflow fail.
            if (_forgetStepId != null) {
                @SuppressWarnings("unchecked") Set<URI> maskedVolumeURIs = (Set<URI>) WorkflowService.getInstance().loadWorkflowData(_forgetStepId, "forget");
                if (maskedVolumeURIs == null) {
                    maskedVolumeURIs = new HashSet<>();
                    maskedVolumeURIs.addAll(_volumes);
                } else {
                    maskedVolumeURIs.addAll(_volumes);
                }
                WorkflowService.getInstance().storeWorkflowData(_forgetStepId, "forget", maskedVolumeURIs);
            }
        }
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskAddVolume - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Set(java.util.Set) HashSet(java.util.HashSet) ExportMask(com.emc.storageos.db.client.model.ExportMask) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 48 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class ExportMaskCreateCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
        if (exportMask != null && status == Operation.Status.ready) {
            List<Initiator> initiators = dbClient.queryObject(Initiator.class, _initiatorURIs);
            exportMask.addInitiators(initiators);
            StorageSystem system = dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice());
            exportMask.addToUserCreatedInitiators(initiators);
            exportMask.addVolumes(_volumeMap);
            if (Type.xtremio.toString().equalsIgnoreCase(system.getSystemType())) {
                // XtremIO case, wwn's are updated only during export.
                // Clean up the existing volumes in export Mask which will have dummy wwns after provisioning.
                // The code below this method addToUserCreatedVolumes adds back the volumes with right wwns.
                _log.info("Cleaning existing xtremio volumes with dummy wwns");
                exportMask.getUserAddedVolumes().clear();
            }
            for (URI boURI : _volumeMap.keySet()) {
                BlockObject blockObject = BlockObject.fetch(dbClient, boURI);
                exportMask.addToUserCreatedVolumes(blockObject);
                // CTRL-11544: Set the hlu in the export group too
                if (exportMask.getCreatedBySystem() && exportMask.getVolumes() != null) {
                    String hlu = exportMask.getVolumes().get(boURI.toString());
                    exportGroup.addVolume(boURI, Integer.parseInt(hlu));
                }
            }
            ExportUtils.reconcileHLUs(dbClient, exportGroup, exportMask, _volumeMap);
            dbClient.updateObject(exportMask);
            exportGroup.addExportMask(exportMask.getId());
            dbClient.updateObject(exportGroup);
            updatePortGroupVolumeCount(exportMask.getPortGroup(), dbClient);
        }
        _log.info(String.format("Done ExportMaskCreate - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskCreate - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 49 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class ExportMaskDeleteCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
        if ((status == Operation.Status.error) && (isRollingBack()) && (coded instanceof ServiceError)) {
            ServiceError error = (ServiceError) coded;
            String originalMessage = error.getMessage();
            StorageSystem storageSystem = exportMask != null ? dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice()) : null;
            String additionMessage = String.format("Rollback encountered problems cleaning up export mask %s on storage system %s and may require manual clean up", exportMask.getMaskName(), storageSystem != null ? storageSystem.forDisplay() : "Unknown");
            String updatedMessage = String.format("%s\n%s", originalMessage, additionMessage);
            error.setMessage(updatedMessage);
        }
        if (exportMask != null && (status == Operation.Status.ready || (Operation.isTerminalState(status) && isRollingBack()))) {
            URI pgURI = exportMask.getPortGroup();
            ExportUtils.cleanupAssociatedMaskResources(dbClient, exportMask);
            dbClient.markForDeletion(exportMask);
            updatePortGroupVolumeCount(pgURI, dbClient);
        }
        _log.info(String.format("Done ExportMaskDelete - EG: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskDelete - EG: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 50 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class ExportMaskRemoveInitiatorCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        ExportMask exportMask = (getMask() != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
        boolean isRollback = WorkflowService.getInstance().isStepInRollbackState(getOpId());
        if ((status == Operation.Status.error) && (isRollback) && (coded instanceof ServiceError)) {
            ServiceError error = (ServiceError) coded;
            String originalMessage = error.getMessage();
            StorageSystem storageSystem = exportMask != null ? dbClient.queryObject(StorageSystem.class, exportMask.getStorageDevice()) : null;
            List<Initiator> initiators = dbClient.queryObject(Initiator.class, _initiatorURIs);
            StringBuffer initiatorsJoined = new StringBuffer();
            if (initiators != null && !initiators.isEmpty()) {
                Iterator<Initiator> initIter = initiators.iterator();
                while (initIter.hasNext()) {
                    Initiator initiator = initIter.next();
                    initiatorsJoined.append(initiator.forDisplay());
                    if (initIter.hasNext()) {
                        initiatorsJoined.append(",");
                    }
                }
            }
            String additionMessage = String.format("Rollback encountered problems removing initiator(s) %s from export mask %s on storage system %s and may require manual clean up", initiatorsJoined.toString(), exportMask.getMaskName(), storageSystem != null ? storageSystem.forDisplay() : "Unknown");
            String updatedMessage = String.format("%s\n%s", originalMessage, additionMessage);
            error.setMessage(updatedMessage);
        }
        if (exportMask != null && (status == Operation.Status.ready || isRollback)) {
            List<Initiator> initiators = dbClient.queryObject(Initiator.class, _initiatorURIs);
            List<URI> targetPorts = ExportUtils.getRemoveInitiatorStoragePorts(exportMask, initiators, dbClient);
            exportMask.removeInitiators(initiators);
            exportMask.removeFromUserCreatedInitiators(initiators);
            if (exportMask.getExistingInitiators() != null && exportMask.getExistingInitiators().isEmpty()) {
                exportMask.setExistingInitiators(null);
            }
            if (exportMask.getInitiators() == null || exportMask.getInitiators().isEmpty()) {
                exportGroup.removeExportMask(exportMask.getId());
                dbClient.removeObject(exportMask);
                dbClient.updateObject(exportGroup);
            } else {
                if (targetPorts != null && !targetPorts.isEmpty()) {
                    for (URI targetPort : targetPorts) {
                        exportMask.removeTarget(targetPort);
                    }
                }
                removeUnusedTargets(exportMask);
                dbClient.updateObject(exportMask);
            }
            _log.info(String.format("Done ExportMaskRemoveInitiator - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        }
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskRemoveInitiator - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)393 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 URI (java.net.URI)157 Volume (com.emc.storageos.db.client.model.Volume)115 ArrayList (java.util.ArrayList)115 WBEMException (javax.wbem.WBEMException)113 CIMObjectPath (javax.cim.CIMObjectPath)104 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)85 ExportMask (com.emc.storageos.db.client.model.ExportMask)83 CIMArgument (javax.cim.CIMArgument)81 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)75 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)63 BlockObject (com.emc.storageos.db.client.model.BlockObject)55 HashMap (java.util.HashMap)54 Initiator (com.emc.storageos.db.client.model.Initiator)52 HashSet (java.util.HashSet)52 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)48 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)46 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)43