Search in sources :

Example 51 with DeviceControllerException

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

the class ExportMaskRemovePathsCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        if (status == Operation.Status.ready) {
            ExportMask exportMask = dbClient.queryObject(ExportMask.class, getMask());
            if (removedTargets != null && !removedTargets.isEmpty()) {
                for (URI target : removedTargets) {
                    exportMask.removeTarget(target);
                }
            }
            if (removedInitiators != null && !removedInitiators.isEmpty()) {
                exportMask.removeInitiatorURIs(removedInitiators);
                exportMask.removeFromUserAddedInitiatorsByURI(removedInitiators);
            }
            dbClient.updateObject(exportMask);
        }
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskRemovePaths - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 52 with DeviceControllerException

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

the class ExportRemoveVolumesOnAdoptedMaskCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        URI exportMaskUri = getMask();
        ExportMask exportMask = (exportMaskUri != null) ? dbClient.queryObject(ExportMask.class, getMask()) : null;
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        for (URI volumeURI : _volumes) {
            BlockObject volume = BlockObject.fetch(dbClient, volumeURI);
            if (exportMask != null && status == Operation.Status.ready) {
                exportMask.removeFromUserCreatedVolumes(volume);
                exportMask.removeVolume(volume.getId());
            }
        }
        if (exportMask != null) {
            URI pgURI = exportMask.getPortGroup();
            if (exportMask.getVolumes() == null || exportMask.getVolumes().isEmpty()) {
                exportGroup.removeExportMask(exportMask.getId());
                dbClient.markForDeletion(exportMask);
                dbClient.updateObject(exportGroup);
            } else {
                dbClient.updateObject(exportMask);
            }
            updatePortGroupVolumeCount(pgURI, dbClient);
        }
        _log.info(String.format("Done ExportMaskRemoveVolume - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskRemoveVolume - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) 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 53 with DeviceControllerException

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

the class RPCGExportCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        // Tell the workflow we're done.
        super.complete(dbClient, status, coded);
        _log.info("cg_export completer: done");
        _log.info(String.format("Done RPCGExport - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        // Tell the individual objects we're done.
        for (URI id : getIds()) {
            switch(status) {
                case error:
                    dbClient.error(ExportGroup.class, id, getOpId(), coded);
                    break;
                default:
                    dbClient.ready(ExportGroup.class, id, getOpId());
            }
        }
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for CG Export - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    }
}
Also used : URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 54 with DeviceControllerException

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

the class RPCGExportDeleteCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        // Tell the workflow we're done.
        super.complete(dbClient, status, coded);
        _log.info("cg_export_delete completer: done");
        _log.info(String.format("Done RPCGExportDelete - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        // Tell the individual objects we're done.
        for (URI id : getIds()) {
            switch(status) {
                case error:
                    dbClient.error(ExportGroup.class, id, getOpId(), coded);
                    break;
                default:
                    dbClient.ready(ExportGroup.class, id, getOpId());
            }
        }
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for CG Export Delete - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    }
}
Also used : URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 55 with DeviceControllerException

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

the class RollbackExportGroupCreateCompleter 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 ((status == Operation.Status.error) && (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) {
            URI pgURI = exportMask.getPortGroup();
            // clean up export group
            exportGroup.removeExportMask(exportMask.getId());
            dbClient.updateObject(exportGroup);
            List<URI> boURIs = new ArrayList<>();
            // part of export group then we should remove that volumes
            for (String emUri : exportGroup.getExportMasks()) {
                if (URIUtil.isValid(emUri) && !emUri.equals(exportMask.getId())) {
                    ExportMask em = dbClient.queryObject(ExportMask.class, URI.create(emUri));
                    if (em != null) {
                        for (String boURI : em.getUserAddedVolumes().values()) {
                            if (URIUtil.isValid(boURI)) {
                                boURIs.add(URI.create(boURI));
                            }
                        }
                    }
                }
            }
            exportMask.removeFromUserAddedVolumesByURI(boURIs);
            dbClient.updateObject(exportMask);
            // if its not used anywhere and is system created delete it
            if (ExportMaskUtils.getExportGroups(dbClient, exportMask.getId()).isEmpty() && exportMask.getCreatedBySystem() && !exportMask.hasAnyVolumes()) {
                dbClient.markForDeletion(exportMask);
            }
            updatePortGroupVolumeCount(pgURI, dbClient);
        }
        _log.info(String.format("Done RollbackExportGroupCreate - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for RollbackExportGroupCreate - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) 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