Search in sources :

Example 6 with AuditLogManager

use of com.emc.storageos.security.audit.AuditLogManager in project coprhd-controller by CoprHD.

the class AuditBlockUtil method auditBlock.

/**
 * Record audit log for block devices
 *
 * @param auditType Type of AuditLog
 * @param operationalStatus success or failure
 * @param operation stage
 *            For sync operation, it should be null;
 *            For async operation, it should be "BEGIN" or "END";
 * @param descparams Description paramters
 */
public static void auditBlock(DbClient dbClient, OperationTypeEnum auditType, boolean operationalStatus, String operationStage, Object... descparams) {
    AuditLogManager auditMgr = AuditLogManagerFactory.getAuditLogManager();
    auditMgr.recordAuditLog(null, null, ControllerUtils.BLOCK_EVENT_SERVICE, auditType, System.currentTimeMillis(), operationalStatus ? AuditLogManager.AUDITLOG_SUCCESS : AuditLogManager.AUDITLOG_FAILURE, operationStage, descparams);
}
Also used : AuditLogManager(com.emc.storageos.security.audit.AuditLogManager)

Example 7 with AuditLogManager

use of com.emc.storageos.security.audit.AuditLogManager in project coprhd-controller by CoprHD.

the class ComputeHostCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    Host host = dbClient.queryObject(Host.class, getId());
    ComputeElement ce = null;
    if (host != null) {
        ce = dbClient.queryObject(ComputeElement.class, host.getComputeElement());
    }
    AuditLogManager auditMgr = AuditLogManagerFactory.getAuditLogManager();
    switch(status) {
        case ready:
            if (host != null) {
                if (ce != null) {
                    host.setUuid(ce.getUuid());
                    host.setBios(ce.getBios());
                }
                host.setProvisioningStatus(ProvisioningJobStatus.COMPLETE.toString());
                dbClient.updateObject(host);
                dbClient.ready(Host.class, getId(), getOpId());
                if (ce != null) {
                    auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, host.getId().toString(), ce.getAvailable(), ce.getUuid(), ce.getDn());
                } else {
                    auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, host.getId().toString());
                }
            }
            break;
        case error:
            if (host != null) {
                host.setProvisioningStatus(ProvisioningJobStatus.ERROR.toString());
                dbClient.updateObject(host);
                dbClient.error(Host.class, getId(), getOpId(), coded);
                /**
                 * Looks like the provisioning of the Host was unsuccessful...
                 * Set the ComputeElement to available (assuming that the
                 * rollback method executed properly)
                 */
                if (ce != null) {
                    ce.setAvailable(true);
                    dbClient.updateObject(ce);
                    auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_FAILURE, AuditLogManager.AUDITOP_END, host.getId().toString(), ce.getAvailable(), ce.getUuid(), ce.getDn());
                } else {
                    auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_FAILURE, AuditLogManager.AUDITOP_END, host.getId().toString());
                }
            }
            break;
        default:
            throw new DeviceControllerException(new IllegalStateException("Terminal state processing called, when operation was in fact not in a terminal state!"));
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) AuditLogManager(com.emc.storageos.security.audit.AuditLogManager) Host(com.emc.storageos.db.client.model.Host) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 8 with AuditLogManager

use of com.emc.storageos.security.audit.AuditLogManager in project coprhd-controller by CoprHD.

the class ComputeImageCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    log.info("ComputeImageCompleter.complete {}", status.name());
    ComputeImage ci = dbClient.queryObject(ComputeImage.class, getId());
    AuditLogManager auditMgr = AuditLogManagerFactory.getAuditLogManager();
    if (status == Status.error) {
        if (opType == OperationTypeEnum.CREATE_COMPUTE_IMAGE) {
            boolean available = false;
            List<URI> ids = dbClient.queryByType(ComputeImageServer.class, true);
            for (URI imageServerId : ids) {
                ComputeImageServer imageServer = dbClient.queryObject(ComputeImageServer.class, imageServerId);
                if (imageServer.getComputeImages() != null && imageServer.getComputeImages().contains(ci.getId().toString())) {
                    available = true;
                    break;
                }
            }
            if (available) {
                ci.setComputeImageStatus(ComputeImageStatus.AVAILABLE.name());
            } else {
                ci.setComputeImageStatus(ComputeImageStatus.NOT_AVAILABLE.name());
            }
            ci.setLastImportStatusMessage(coded.getMessage());
            dbClient.persistObject(ci);
        }
        dbClient.error(ComputeImage.class, getId(), getOpId(), coded);
        auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_FAILURE, AuditLogManager.AUDITOP_END, ci.getId().toString(), ci.getImageUrl(), ci.getComputeImageStatus());
    } else {
        if (opType == OperationTypeEnum.DELETE_COMPUTE_IMAGE) {
            dbClient.markForDeletion(ci);
        } else if (opType == OperationTypeEnum.CREATE_COMPUTE_IMAGE) {
            ci.setComputeImageStatus(ComputeImageStatus.AVAILABLE.name());
            ci.setLastImportStatusMessage("Success");
            dbClient.persistObject(ci);
        }
        dbClient.ready(ComputeImage.class, getId(), getOpId());
        auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, ci.getId().toString(), ci.getImageUrl(), ci.getComputeImageStatus());
    }
}
Also used : ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) AuditLogManager(com.emc.storageos.security.audit.AuditLogManager) URI(java.net.URI) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Example 9 with AuditLogManager

use of com.emc.storageos.security.audit.AuditLogManager in project coprhd-controller by CoprHD.

the class ComputeImageServerCompleter method complete.

/**
 * Method to be invoked on job execution completion
 * @param dbClient {@link DBClient} instance
 * @param Status {@link Status} of job
 * @param coded {@link ServiceCoded} instance
 */
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    log.info("ComputeImageServerCompleter.complete {}", status.name());
    ComputeImageServer imageServer = dbClient.queryObject(ComputeImageServer.class, getId());
    AuditLogManager auditMgr = AuditLogManagerFactory.getAuditLogManager();
    if (status == Status.error) {
        dbClient.error(ComputeImageServer.class, getId(), getOpId(), coded);
        auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_FAILURE, AuditLogManager.AUDITOP_END, imageServer.getId().toString(), imageServer.getComputeImageServerStatus());
    } else {
        if (opType == OperationTypeEnum.DELETE_COMPUTE_IMAGESERVER) {
            dbClient.markForDeletion(imageServer);
        } else if (opType == OperationTypeEnum.IMAGESERVER_VERIFY_IMPORT_IMAGES) {
            imageServer.setComputeImageServerStatus(ComputeImageServerStatus.AVAILABLE.name());
            dbClient.persistObject(imageServer);
        }
        dbClient.ready(ComputeImageServer.class, getId(), getOpId());
        auditMgr.recordAuditLog(null, null, serviceType, opType, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, imageServer.getId().toString(), imageServer.getComputeImageServerStatus());
    }
}
Also used : ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) AuditLogManager(com.emc.storageos.security.audit.AuditLogManager)

Aggregations

AuditLogManager (com.emc.storageos.security.audit.AuditLogManager)9 ComputeImage (com.emc.storageos.db.client.model.ComputeImage)2 ComputeImageServer (com.emc.storageos.db.client.model.ComputeImageServer)2 Host (com.emc.storageos.db.client.model.Host)2 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)1 ComputeImageJob (com.emc.storageos.db.client.model.ComputeImageJob)1 IpInterface (com.emc.storageos.db.client.model.IpInterface)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 URI (java.net.URI)1