Shireesh Anjal has uploaded a new change for review. Change subject: gluster: Audit Log Director for gluster ......................................................................
gluster: Audit Log Director for gluster Log Director for gluster related audit logs. Provides convenience methods to create audit logs related to a gluster cluster, volume, or server. While the AuditLogDirectory is sufficient for logging from regular BLL commands, this class can be used for creating audit logs from other places, e.g. GlusterManager Change-Id: If36dcf305cd6b0ee57cff3bea126f4f6acef740f Signed-off-by: Shireesh Anjal <san...@redhat.com> --- A backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/gluster/GlusterAuditLogDirector.java 1 file changed, 84 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/11300/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/gluster/GlusterAuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/gluster/GlusterAuditLogDirector.java new file mode 100644 index 0000000..37da156 --- /dev/null +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/gluster/GlusterAuditLogDirector.java @@ -0,0 +1,84 @@ +package org.ovirt.engine.core.dal.dbbroker.auditloghandling.gluster; + +import java.util.HashMap; +import java.util.Map; + +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; + +/** + * Log Director for gluster related audit logs. Provides convenience methods to create audit logs related to a gluster + * cluster, volume, or server. While the AuditLogDirectory is sufficient for logging from regular BLL commands, this + * class can be used for creating audit logs from other places, e.g. GlusterManager + */ +public class GlusterAuditLogDirector { + private static GlusterAuditLogDirector instance = new GlusterAuditLogDirector(); + + private GlusterAuditLogDirector() { + } + + public static GlusterAuditLogDirector getInstance() { + return instance; + } + + public void logVolumeMessage(final GlusterVolumeEntity volume, final AuditLogType logType) { + logAuditMessage(volume.getClusterId(), volume, null, logType, null, null); + } + + public void logServerMessage(final VDS server, final AuditLogType logType) { + logAuditMessage(null, null, server, logType, null, null); + } + + @SuppressWarnings("serial") + public void logAuditMessage(final Guid clusterId, + final GlusterVolumeEntity volume, + final VDS server, + final AuditLogType logType, + final String[]... customValues) { + AuditLogDirector.log(new AuditLogableBase() { + @Override + protected VDS getVds() { + return server; + } + + @Override + public Guid getVdsGroupId() { + return clusterId; + } + + @Override + public VDSGroup getVdsGroup() { + setVdsGroupId(clusterId); + return super.getVdsGroup(); + } + + @Override + protected GlusterVolumeEntity getGlusterVolume() { + return volume; + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return logType; + } + + @Override + public Map<String, String> getCustomValues() { + Map<String, String> customValuesMap = new HashMap<String, String>(); + if (customValues != null) { + for (String entry[] : customValues) { + if (entry != null && entry.length == 2) { + customValuesMap.put(entry[0], entry[1]); + } + } + } + return customValuesMap; + } + }); + } +} -- To view, visit http://gerrit.ovirt.org/11300 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If36dcf305cd6b0ee57cff3bea126f4f6acef740f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shireesh Anjal <san...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches