Search in sources :

Example 21 with RecordableBourneEvent

use of com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent in project coprhd-controller by CoprHD.

the class StorageSystemService method recordStoragePoolPortEvent.

/**
 * Record Bourne Event for the completed operations
 *
 * @param type
 * @param type
 * @param description
 * @param storagePort
 */
private void recordStoragePoolPortEvent(OperationTypeEnum opType, String description, URI resourcdId, String resType) {
    String evType;
    evType = opType.getEvType(true);
    String service = PORT_EVENT_SERVICE_TYPE;
    String eventSource = PORT_EVENT_SERVICE_SOURCE;
    if (resType.equalsIgnoreCase("StoragePool")) {
        service = POOL_EVENT_SERVICE_TYPE;
        eventSource = POOL_EVENT_SERVICE_SOURCE;
    } else if (resType.equalsIgnoreCase("StoragePortGroup")) {
        service = PORT_GROUP_EVENT_SERVICE_TYPE;
        eventSource = PORT_GROUP_EVENT_SERVICE_SOURCE;
    }
    RecordableBourneEvent event = new RecordableBourneEvent(/* String */
    evType, /* tenant id */
    null, /* user id ?? */
    URI.create("ViPR-User"), /* project ID */
    null, /* VirtualPool */
    null, /* service */
    service, /* resource id */
    resourcdId, /* description */
    description, /* timestamp */
    System.currentTimeMillis(), /* extensions */
    "", /* native guid */
    null, /* record type */
    RecordType.Event.name(), /* Event Source */
    eventSource, /* Operational Status codes */
    "", /* Operational Status Descriptions */
    "");
    try {
        _evtMgr.recordEvents(event);
    } catch (Exception ex) {
        _log.error("Failed to record event. Event description: {}. Error: ", description, ex);
    }
}
Also used : RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Example 22 with RecordableBourneEvent

use of com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent in project coprhd-controller by CoprHD.

the class TenantsService method recordTenantEvent.

/**
 * Record Bourne Event for the completed operations
 *
 * @param tenantId
 * @param targetId
 */
private void recordTenantEvent(OperationTypeEnum opType, URI tenantId, URI targetId) {
    String type = opType.getEvType(true);
    String description = opType.getDescription();
    RecordableBourneEvent event = new RecordableBourneEvent(/* String */
    type, /* tenant id */
    tenantId, /* user id ?? */
    URI.create("ViPR-User"), /* project ID */
    null, /* CoS */
    null, /* service */
    EVENT_SERVICE_TYPE, /* resource id */
    targetId, /* description */
    description, /* timestamp */
    System.currentTimeMillis(), /* extensions */
    "", /* native guid */
    null, /* record type */
    RecordType.Event.name(), /* Event Source */
    EVENT_SERVICE_SOURCE, /* Operational Status codes */
    "", /* Operational Status Descriptions */
    "");
    try {
        _evtMgr.recordEvents(event);
    } catch (Exception ex) {
        if (ex instanceof RuntimeException) {
            // CQ604367 --
            // print full stack trace of error. Problem is intermittent
            // and can not be reproduced easily. A NullPointerException
            // is getting thrown. This will code will help identify in
            // apisvc.log exactly where that occurs when it does.
            _log.error("Failed to record event. Event description: " + description + ". Error: .", ex);
        } else {
            _log.error("Failed to record event. Event description: {}. Error: {}.", description, ex);
        }
    }
    _log.info("opType: {} detail: {}", opType.toString(), type + ':' + description);
}
Also used : RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) ForbiddenException(com.emc.storageos.svcs.errorhandling.resources.ForbiddenException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 23 with RecordableBourneEvent

use of com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent in project coprhd-controller by CoprHD.

the class ControllerUtils method convertToRecordableBourneEvent.

/**
 * Create a new instance of RecordableBourneEvent with the given resource
 * and properties.
 *
 * @param resource
 *            - Type of Resource - File or Volume
 * @param type
 *            - Event Type Enum
 * @param description
 *            - Description of event if available
 * @param extensions
 *            - Extensions mapped with Event Model Extensions
 * @param eventServiceSource
 *            - URI of the Project
 * @param dbClient
 *            - DBClient reference
 * @param evtServiceType
 *            - Service Type
 * @param recordType
 *            - Type of Indication
 * @return RecordableBourneEvent
 */
public static RecordableBourneEvent convertToRecordableBourneEvent(DataObject resource, String type, String description, String extensions, DbClient dbClient, String evtServiceType, String recordType, String eventServiceSource) {
    URI cos = null;
    URI id = null;
    String nativeGuid = null;
    URI projectURI = null;
    URI tenantURI = null;
    RecordableBourneEvent event = null;
    if (resource != null) {
        if (resource instanceof Volume) {
            Volume volume = (Volume) resource;
            cos = volume.getVirtualPool();
            id = volume.getId();
            nativeGuid = volume.getNativeGuid();
            projectURI = volume.getProject().getURI();
            tenantURI = volume.getTenant().getURI();
        } else if (resource instanceof FileShare) {
            FileShare fs = (FileShare) resource;
            cos = fs.getVirtualPool();
            id = fs.getId();
            nativeGuid = fs.getNativeGuid();
            projectURI = (fs.getProject() != null) ? fs.getProject().getURI() : null;
            tenantURI = (fs.getTenant() != null) ? fs.getTenant().getURI() : null;
        } else if (resource instanceof VplexMirror) {
            VplexMirror vplexMirror = (VplexMirror) resource;
            cos = vplexMirror.getVirtualPool();
            id = vplexMirror.getId();
            projectURI = vplexMirror.getProject().getURI();
            tenantURI = vplexMirror.getTenant().getURI();
        } else if (resource instanceof BlockSnapshot) {
            BlockSnapshot snapshot = (BlockSnapshot) resource;
            try {
                if (!NullColumnValueGetter.isNullNamedURI(snapshot.getParent())) {
                    Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
                    cos = volume.getVirtualPool();
                    tenantURI = (volume.getTenant() != null) ? volume.getTenant().getURI() : null;
                }
                id = snapshot.getId();
                nativeGuid = snapshot.getNativeGuid();
                projectURI = snapshot.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof BlockSnapshotSession) {
            BlockSnapshotSession session = (BlockSnapshotSession) resource;
            try {
                id = session.getId();
                projectURI = session.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof ExportGroup) {
            ExportGroup exportGroup = (ExportGroup) resource;
            try {
                id = exportGroup.getId();
                projectURI = exportGroup.getProject().getURI();
                tenantURI = (exportGroup.getTenant() != null) ? exportGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof FCZoneReference) {
            FCZoneReference zone = (FCZoneReference) resource;
            try {
                id = zone.getId();
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof Network) {
            Network tz = (Network) resource;
            id = tz.getId();
            nativeGuid = tz.getNativeGuid();
        } else if (resource instanceof BlockConsistencyGroup) {
            BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) resource;
            try {
                id = consistencyGroup.getId();
                projectURI = consistencyGroup.getProject().getURI();
                tenantURI = (consistencyGroup.getTenant() != null) ? consistencyGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof StoragePool) {
            StoragePool sp = (StoragePool) resource;
            id = sp.getId();
            nativeGuid = sp.getNativeGuid();
        } else {
            s_logger.info("Error getting vpool,id,NativeGuid for event. Unexpected resource type {}.", resource.getClass().getName());
        }
        // TODO fix the bogus tenant, user ID once we have AuthZ working
        if (tenantURI == null && projectURI != null) {
            tenantURI = ControllerUtils.getProjectTenantOrgURI(dbClient, projectURI);
        }
        event = new RecordableBourneEvent(type, tenantURI, // user ID TODO when AAA
        URI.create("ViPR-User"), // fixed
        projectURI, cos, evtServiceType, id, description, System.currentTimeMillis(), extensions, nativeGuid, recordType, eventServiceSource, "", "");
    }
    return event;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Network(com.emc.storageos.db.client.model.Network) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 24 with RecordableBourneEvent

use of com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent in project coprhd-controller by CoprHD.

the class FileDeviceController method recordFsEvent.

/**
 * Create a nice event based on the File Share
 *
 * @param fs
 *            FileShare for which the event is about
 * @param type
 *            Type of event such as FileShareCreated or FileShareDeleted
 * @param description
 *            Description for the event if needed
 */
public static void recordFsEvent(DbClient dbClient, FileShare fs, String type, String description, String extensions) {
    if (fs == null) {
        _log.error("Invalid FileShare event");
        return;
    }
    RecordableEventManager eventManager = new RecordableEventManager();
    eventManager.setDbClient(dbClient);
    // fix the bogus user ID once we have AuthZ working
    RecordableBourneEvent event = ControllerUtils.convertToRecordableBourneEvent(fs, type, description, extensions, dbClient, EVENT_SERVICE_TYPE, RecordType.Event.name(), EVENT_SERVICE_SOURCE);
    try {
        eventManager.recordEvents(event);
    } catch (Exception th) {
        _log.error("Failed to record event. Event description: {}.", description, th);
    }
}
Also used : RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) RecordableEventManager(com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

RecordableBourneEvent (com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent)24 RecordableEventManager (com.emc.storageos.volumecontroller.impl.monitoring.RecordableEventManager)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 Volume (com.emc.storageos.db.client.model.Volume)5 ControllerException (com.emc.storageos.volumecontroller.ControllerException)5 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 IOException (java.io.IOException)4 URISyntaxException (java.net.URISyntaxException)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)2 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)2 VplexMirror (com.emc.storageos.db.client.model.VplexMirror)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)2 WBEMException (javax.wbem.WBEMException)2