Eli Mesika has uploaded a new change for review.

Change subject: core: Adding external events BE support and testing
......................................................................

core: Adding external events BE support and testing

This patch adds the External Event support in Event/Alert Director and in
DAOs and testing

Change-Id: I3562865255fe680b2906a10b517e70a37e6e09db
Signed-off-by: Eli Mesika <emes...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AlertDirector.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAOHibernateImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java
11 files changed, 363 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/10091/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index a1f8fc6..ae05206 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -666,7 +666,11 @@
     DWH_STARTED(9700),
     DWH_ERROR(9704),
 
-    ;
+    // External Events/Alerts
+    EXTERNAL_EVENT_NORMAL(9801),
+    EXTERNAL_EVENT_WARNING(9802),
+    EXTERNAL_EVENT_ERROR(9803),
+    EXTERNAL_ALERT(9804);
 
     private int intValue;
     // indicates time interval in seconds on which identical events from same 
instance are supressed.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java
index ba7a209..5ed87ab 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java
@@ -42,6 +42,12 @@
     private NGuid jobId;
     private NGuid glusterVolumeId;
     private String glusterVolumeName;
+    private String origin = "oVirt";
+    private int customEventId = -1;
+    private int eventFloodInSec = 30;
+    private String customData = "";
+    private boolean external = false;
+    private boolean deleted = false;
 
     public AuditLog() {
     }
@@ -63,6 +69,38 @@
         vmTemplateName = al_vmt_name;
     }
 
+    public AuditLog(AuditLogType al_type,
+            AuditLogSeverity al_severity,
+            String al_msg,
+            NGuid al_user_id,
+            String al_user_name,
+            NGuid al_vm_id,
+            String al_vm_name,
+            NGuid al_vds_id,
+            String al_vds_name,
+            NGuid al_vmt_id,
+            String al_vmt_name,
+            String origin,
+            int customEventId,
+            int eventFloogInSec,
+            String customData) {
+        logTime = new Date();
+        logType = al_type.getValue();
+        severity = al_severity.getValue();
+        message = al_msg;
+        userId = al_user_id;
+        userName = al_user_name;
+        vmId = al_vm_id;
+        vmName = al_vm_name;
+        vdsId = al_vds_id;
+        vdsName = al_vds_name;
+        vmTemplateId = al_vmt_id;
+        vmTemplateName = al_vmt_name;
+        this.origin = origin;
+        this.customEventId = customEventId;
+        this.eventFloodInSec = eventFloogInSec;
+        this.customData = customData;
+    }
     public long getaudit_log_id() {
         return this.auditLogId;
     }
@@ -309,6 +347,54 @@
         glusterVolumeName = value;
     }
 
+    public String getOrigin() {
+        return origin;
+    }
+
+    public void setOrigin(String origin) {
+        this.origin = origin;
+    }
+
+    public int getCustomEventId() {
+        return customEventId;
+    }
+
+    public void setCustomEventId(int customEventId) {
+        this.customEventId = customEventId;
+    }
+
+    public int getEventFloodInSec() {
+        return eventFloodInSec;
+    }
+
+    public void setEventFloodInSec(int eventFloodInSec) {
+        this.eventFloodInSec = eventFloodInSec;
+    }
+
+    public String getCustomData() {
+        return customData;
+    }
+
+    public void setCustomData(String customData) {
+        this.customData = customData;
+    }
+
+    public boolean isExternal() {
+        return external;
+    }
+
+    public void setExternal(boolean external) {
+        this.external = external;
+    }
+
+    public boolean isDeleted() {
+        return deleted;
+    }
+
+    public void setDeleted(boolean deleted) {
+        this.deleted = deleted;
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -328,6 +414,12 @@
         result = prime * result + (processed ? prime : 0);
         result = prime * result + ((correlationId == null) ? 0 : 
correlationId.hashCode());
         result = prime * result + ((jobId == null) ? 0 : jobId.hashCode());
+        result = prime * result + ((origin == null) ? 0 : origin.hashCode());
+        result = prime * result + (customEventId * prime);
+        result = prime * result + (eventFloodInSec * prime);
+        result = prime * result + ((customData == null) ? 0 : 
customData.hashCode());
+        result = prime * result + ((external) ? 1 : 0);
+        result = prime * result + ((deleted) ? 1 : 0);
         return result;
     }
 
@@ -403,6 +495,24 @@
                 return false;
         } else if (!jobId.equals(other.jobId))
             return false;
+        if (origin == null) {
+            if (other.origin != null)
+                return false;
+        } else if (!origin.equals(other.origin))
+            return false;
+        if (customEventId != other.customEventId)
+            return false;
+        if (eventFloodInSec != other.eventFloodInSec)
+            return false;
+        if (customData == null) {
+            if (other.customData != null)
+                return false;
+        } else if (!customData.equals(other.customData))
+            return false;
+        if (external != other.external)
+            return false;
+        if (deleted != other.deleted)
+            return false;
         return true;
     }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AlertDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AlertDirector.java
index 3ea11d0..bce7d8e 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AlertDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AlertDirector.java
@@ -1,7 +1,7 @@
 package org.ovirt.engine.core.dal.dbbroker.auditloghandling;
 
-import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 
 /**
@@ -20,6 +20,10 @@
         AuditLogDirector.log(auditLogable, logType);
     }
 
+    public static void Alert(AuditLogableBase auditLogable, AuditLogType 
logType, String message) {
+        AuditLogDirector.log(auditLogable, logType, message);
+    }
+
     /**
      * Removes the alert.
      *
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 8551cb1..1a98126 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -676,6 +676,11 @@
         mSeverities.put(AuditLogType.NETWORK_ACTIVATE_VM_INTERFACE_FAILURE, 
AuditLogSeverity.ERROR);
         mSeverities.put(AuditLogType.NETWORK_DEACTIVATE_VM_INTERFACE_SUCCESS, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.NETWORK_DEACTIVATE_VM_INTERFACE_FAILURE, 
AuditLogSeverity.ERROR);
+        // External Events/Alerts
+        mSeverities.put(AuditLogType.EXTERNAL_EVENT_NORMAL, 
AuditLogSeverity.NORMAL);
+        mSeverities.put(AuditLogType.EXTERNAL_EVENT_WARNING, 
AuditLogSeverity.WARNING);
+        mSeverities.put(AuditLogType.EXTERNAL_EVENT_ERROR, 
AuditLogSeverity.ERROR);
+        mSeverities.put(AuditLogType.EXTERNAL_ALERT, AuditLogSeverity.ALERT);
     }
 
     private static void initConfigSeverities() {
@@ -763,19 +768,43 @@
 
         if (auditLogable == null || auditLogable.getLegal()) {
             String message = null;
-            if ((message = mMessages.get(logType)) != null) {
-                String resolvedMessage = resolveMessage(message, auditLogable);
-                AuditLogSeverity severity = AuditLogSeverity.forValue(0);
-                if (!((severity = mSeverities.get(logType)) != null)) {
-                    severity = AuditLogSeverity.NORMAL;
-                    log.infoFormat("No severity for {0} type", logType);
+            String resolvedMessage = null;
+            AuditLogSeverity severity = AuditLogSeverity.forValue(0);
+            if (!((severity = mSeverities.get(logType)) != null)) {
+                severity = AuditLogSeverity.NORMAL;
+                log.infoFormat("No severity for {0} type", logType);
+            }
+            AuditLog auditLog = null;
+            if (auditLogable != null) {
+                AuditLog tempVar = null;
+                // handle external log messages invoked by plugins via the API
+                if (auditLogable.isExternal()) {
+                    resolvedMessage = message = loggerString; // message is 
sent as an argument, no need to resolve.
+                    tempVar =
+                            new AuditLog(logType,
+                                    severity,
+                                    resolvedMessage,
+                                    auditLogable.getUserId(),
+                                    auditLogable.getUserName(),
+                                    auditLogable.getVmIdRef(),
+                                    auditLogable.getVmName(),
+                                    auditLogable.getVdsIdRef(),
+                                    auditLogable.getVdsName(),
+                                    auditLogable.getVmTemplateIdRef(),
+                                    auditLogable.getVmTemplateName(),
+                                    auditLogable.getOrigin(),
+                                    auditLogable.getCustomEventId(),
+                                    auditLogable.getEventFloodInSec(),
+                                    auditLogable.getCustomData());
                 }
-                AuditLog auditLog;
-                if (auditLogable != null) {
-                    AuditLog tempVar = new AuditLog(logType, severity, 
resolvedMessage, auditLogable.getUserId(),
+                else if ((message = mMessages.get(logType)) != null) { // 
Application log message from AuditLogMessages
+                    resolvedMessage = resolveMessage(message, auditLogable);
+                    tempVar = new AuditLog(logType, severity, resolvedMessage, 
auditLogable.getUserId(),
                             auditLogable.getUserName(), 
auditLogable.getVmIdRef(), auditLogable.getVmName(),
                             auditLogable.getVdsIdRef(), 
auditLogable.getVdsName(), auditLogable.getVmTemplateIdRef(),
                             auditLogable.getVmTemplateName());
+                }
+                if (tempVar != null) {
                     
tempVar.setstorage_domain_id(auditLogable.getStorageDomainId());
                     
tempVar.setstorage_domain_name(auditLogable.getStorageDomainName());
                     
tempVar.setstorage_pool_id(auditLogable.getStoragePoolId());
@@ -786,19 +815,22 @@
                     tempVar.setJobId(auditLogable.getJobId());
                     
tempVar.setGlusterVolumeId(auditLogable.getGlusterVolumeId());
                     
tempVar.setGlusterVolumeName(auditLogable.getGlusterVolumeName());
+                    tempVar.setExternal(auditLogable.isExternal());
                     auditLog = tempVar;
-                } else {
-                    auditLog = new AuditLog(logType, severity, 
resolvedMessage, null, null, null, null, null, null,
-                            null, null);
                 }
+            } else {
+                auditLog = new AuditLog(logType, severity, resolvedMessage, 
null, null, null, null, null, null,
+                        null, null);
+            }
+            if (auditLog != null) {
                 getDbFacadeInstance().getAuditLogDao().save(auditLog);
                 if (!"".equals(loggerString)) {
                     log.infoFormat(loggerString, resolvedMessage);
                 }
-            } else if (auditLogable != null) {
-                log.infoFormat("No string for {0} type. Use default Log", 
auditLogable.getAuditLogTypeValue());
-                defaultLog(auditLogable);
             }
+        } else if (auditLogable != null) {
+            log.infoFormat("No string for {0} type. Use default Log", 
auditLogable.getAuditLogTypeValue());
+            defaultLog(auditLogable);
         }
     }
 
@@ -810,7 +842,12 @@
      *            the log type which determine if timeout is used for it
      */
     private static void updateTimeoutLogableObject(AuditLogableBase 
auditLogable, AuditLogType logType) {
-        if (logType.getDuplicateEventsIntervalValue() > 0) {
+        int duplicateEventsIntrvalValue = (auditLogable.isExternal())
+                ?
+                Math.max(auditLogable.getEventFloodInSec(), 30) // Min 
duration for External Events is 30 sec
+                :
+                logType.getDuplicateEventsIntervalValue();
+        if (duplicateEventsIntrvalValue > 0) {
             
auditLogable.setEndTime(DateTime.getNow().AddSeconds(logType.getDuplicateEventsIntervalValue()));
             auditLogable.setTimeoutObjectId(ComposeObjectId(auditLogable, 
logType));
         }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
index fbf63d2..860d124 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogableBase.java
@@ -8,6 +8,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
@@ -46,7 +47,7 @@
     private static final long serialVersionUID = -4764813076922800727L;
     private NGuid mVmId = Guid.Empty;
     private IVdcUser mVdcUser;
-    private Guid mUserId = Guid.Empty;
+    private NGuid mUserId = Guid.Empty;
     private String mUserName;
     private String mVmName;
     private final Map<String, String> customValues = new HashMap<String, 
String>();
@@ -68,6 +69,11 @@
     private String glusterVolumeName;
     private GlusterVolumeEntity glusterVolume;
     private Integer customId = null;
+    private String origin = "oVirt";
+    private int customEventId = -1;
+    private int eventFloodInSec = 30;
+    private String customData = "";
+    private boolean external = false;
 
     public AuditLogableBase() {
     }
@@ -81,8 +87,30 @@
         mVmId = vmId;
     }
 
+    public AuditLogableBase(final AuditLog auditLog) {
+        this._storageDomainId = auditLog.getstorage_domain_id();
+        this._storagePoolId = auditLog.getstorage_pool_id();
+        this.correlationId = auditLog.getCorrelationId();
+        this.customData = auditLog.getCustomData();
+        this.customEventId = auditLog.getCustomEventId();
+        this.eventFloodInSec = auditLog.getEventFloodInSec();
+        this.glusterVolumeId = auditLog.getGlusterVolumeId();
+        this.glusterVolumeName = auditLog.getGlusterVolumeName();
+        this.jobId = auditLog.getJobId();
+        this.mUserId = (NGuid) auditLog.getuser_id();
+        this.mUserName = auditLog.getuser_name();
+        this.mVdsGroupId = (Guid) auditLog.getvds_group_id();
+        this.mVdsId = auditLog.getvds_id();
+        this.mVdsName = auditLog.getvds_name();
+        this.mVmId = auditLog.getvm_id();
+        this.mVmName = auditLog.getvm_name();
+        this.mVmTemplateId = auditLog.getvm_template_id();
+        this.mVmTemplateName = auditLog.getvm_template_name();
+        this.origin = auditLog.getOrigin();
+        this.external = auditLog.isExternal();
+    }
     public NGuid getUserId() {
-        if (mUserId.equals(Guid.Empty) && getCurrentUser() != null) {
+        if (mUserId != null && mUserId.equals(Guid.Empty) && getCurrentUser() 
!= null) {
             mUserId = getCurrentUser().getUserId();
         }
         return mUserId;
@@ -566,6 +594,45 @@
         this.customId = customId;
     }
 
+    public String getOrigin() {
+        return origin;
+    }
+
+    public void setOrigin(String origin) {
+        this.origin = origin;
+    }
+
+    public int getCustomEventId() {
+        return customEventId;
+    }
+
+    public void setCustomEventId(int customEventId) {
+        this.customEventId = customEventId;
+    }
+
+    public int getEventFloodInSec() {
+        return eventFloodInSec;
+    }
+
+    public void setEventFloodInSec(int eventFloodInSec) {
+        this.eventFloodInSec = eventFloodInSec;
+    }
+
+    public String getCustomData() {
+        return customData;
+    }
+
+    public void setCustomData(String customData) {
+        this.customData = customData;
+    }
+
+    public boolean isExternal() {
+        return external;
+    }
+
+    public void setExternal(boolean external) {
+        this.external = external;
+    }
     private static final Log log = LogFactory.getLog(AuditLogableBase.class);
 
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
index 012bfbe..98073e9 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java
@@ -22,6 +22,16 @@
     AuditLog get(long id);
 
     /**
+     * Get External Event injected by a plug-in
+     * @param origin
+     *            the event origin
+     * @param customEventId
+     *            the unique ide per origin associated with the event instance
+     * @return
+     */
+    AuditLog getByOriginAndCustomEventId(String origin, int customEventId);
+
+    /**
      * Finds all entries created after the specified cutoff date
      *
      * @param cutoff
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
index 2e922e0..aacdbf1 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java
@@ -38,6 +38,15 @@
     }
 
     @Override
+    public AuditLog getByOriginAndCustomEventId(String origin, int 
customEventId) {
+        MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource()
+                .addValue("origin", origin)
+                .addValue("custom_event_id", customEventId);
+
+        return 
getCallsHandler().executeRead("GetAuditLogByOriginAndCustomEventId", 
auditLogRowMapper, parameterSource);
+    }
+
+    @Override
     public List<AuditLog> getAllAfterDate(Date cutoff) {
         MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource()
                 .addValue("date", cutoff);
@@ -88,7 +97,12 @@
 
     @Override
     public void save(AuditLog event) {
-        getCallsHandler().executeModification("InsertAuditLog", 
getSqlMapper(event));
+        if (event.isExternal()) {
+            getCallsHandler().executeModification("InsertExternalAuditLog", 
getExternalEventSqlMapper(event));
+        }
+        else {
+            getCallsHandler().executeModification("InsertAuditLog", 
getSqlMapper(event));
+        }
     }
 
     @Override
@@ -124,6 +138,14 @@
                 .addValue("quota_name", event.getQuotaName())
                 .addValue("gluster_volume_id", event.getGlusterVolumeId())
                 .addValue("gluster_volume_name", event.getGlusterVolumeName());
+    }
+
+    private MapSqlParameterSource getExternalEventSqlMapper(AuditLog event) {
+        return getSqlMapper(event)
+                .addValue("origin", event.getOrigin())
+                .addValue("custom_event_id", event.getCustomEventId())
+                .addValue("event_flood_in_sec", event.getEventFloodInSec())
+                .addValue("custom_data", event.getCustomData());
     }
 
     @Override
@@ -216,6 +238,11 @@
             entity.setQuotaName(rs.getString("quota_name"));
             
entity.setGlusterVolumeId(NGuid.createGuidFromString(rs.getString("gluster_volume_id")));
             entity.setGlusterVolumeName(rs.getString("gluster_volume_name"));
+            entity.setOrigin(rs.getString("origin"));
+            entity.setCustomEventId(rs.getInt("custom_event_id"));
+            entity.setEventFloodInSec(rs.getInt("event_flood_in_sec"));
+            entity.setCustomData(rs.getString("custom_data"));
+            entity.setDeleted(rs.getBoolean("deleted"));
             return entity;
         }
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAOHibernateImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAOHibernateImpl.java
index ae886ae..cfe4f7a 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAOHibernateImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAOHibernateImpl.java
@@ -108,4 +108,9 @@
     public int getTimeToWaitForNextPmOp(String vdsName, String event) {
         throw new NotImplementedException();
     }
+
+    @Override
+    public AuditLog getByOriginAndCustomEventId(String origin, int 
customEventId) {
+        throw new NotImplementedException();
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java
index 8822fd6..7a02658 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java
@@ -32,12 +32,14 @@
     private static final String VM_TEMPLATE_NAME = "1";
     private static final Guid VDS_ID = new 
Guid("afce7a39-8e8c-4819-ba9c-796d316592e6");
     private static final long EXISTING_ENTRY_ID = 44291;
+    private static final long EXTERNAL_ENTRY_ID = 44296;
     private static final SimpleDateFormat EXPECTED_DATE_FORMAT = new 
SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     private static final int EXISTING_COUNT = 5;
 
     private AuditLogDAO dao;
     private AuditLog newAuditLog;
     private AuditLog existingAuditLog;
+    private AuditLog externalAuditLog;
 
     @Override
     @Before
@@ -70,6 +72,7 @@
         newAuditLog.setGlusterVolumeName("gluster_volume_name-1");
 
         existingAuditLog = dao.get(EXISTING_ENTRY_ID);
+        externalAuditLog = dao.get(EXTERNAL_ENTRY_ID);
     }
 
     /**
@@ -94,6 +97,17 @@
     }
 
     /**
+     * Ensures that, for External Events, then retrieving a AuditLog works as 
expected.
+     */
+    @Test
+    public void testGetByOriginAndCustomEventId() {
+        AuditLog result = dao.getByOriginAndCustomEventId("EMS", 1);
+
+        assertNotNull(result);
+        assertEquals(externalAuditLog, result);
+    }
+
+    /**
      * Ensures that finding all AuditLog works as expected.
      */
     @Test
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 78a9406..652f6c6 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -3048,6 +3048,11 @@
         <column>storage_pool_name</column>
         <column>storage_domain_id</column>
         <column>storage_domain_name</column>
+        <column>origin</column>
+        <column>custom_event_id</column>
+        <column>event_flood_in_sec</column>
+        <column>custom_data</column>
+        <column>deleted</column>
         <row>
             <value>44291</value>
             <value>9bf7c640-b620-456f-a550-0348f366544a</value>
@@ -3068,6 +3073,11 @@
             <value>rhel6.iscsi</value>
             <value>72e3a666-89e1-4005-a7ca-f7548004a9ab</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
+            <value>oVirt</value>
+            <value>-1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>
         </row>
         <row>
             <value>44292</value>
@@ -3089,6 +3099,12 @@
             <value>rhel6.iscsi</value>
             <value>72e3a666-89e1-4005-a7ca-f7548004a9ab</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
+            <value>oVirt</value>
+            <value>-1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>
+            
         </row>
         <row>
             <value>44293</value>
@@ -3110,6 +3126,11 @@
             <value>rhel6.iscsi</value>
             <value>72e3a666-89e1-4005-a7ca-f7548004a9ab</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
+            <value>oVirt</value>
+            <value>-1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>            
         </row>
         <row>
             <value>44294</value>
@@ -3131,6 +3152,11 @@
             <value>rhel6.iscsi</value>
             <value>72e3a666-89e1-4005-a7ca-f7548004a9ab</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
+            <value>oVirt</value>
+            <value>-1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>            
         </row>
         <row>
             <value>44295</value>
@@ -3152,7 +3178,39 @@
             <value>rhel6.iscsi</value>
             <value>72e3a666-89e1-4005-a7ca-f7548004a9ab</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
+            <value>oVirt</value>
+            <value>-1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>            
         </row>
+        <row>
+            <value>44296</value>
+            <value>9bf7c640-b620-456f-a550-0348f366544a</value>
+            <value>userportal2</value>
+            <value></value>
+            <value></value>
+            <value></value>
+            <value>1</value>
+            <value></value>
+            <value></value>
+            <value>2010-12-20 13:11:29</value>
+            <value>EXTERNAL_EVENT_NORMAL</value>
+            <value>9801</value>
+            <value>1</value>
+            <value>External Event from EMC plug-in</value>
+            <value>true</value>
+            <value></value>
+            <value></value>
+            <value></value>
+            <value></value>
+            <value>EMC</value>
+            <value>1</value>
+            <value>30</value>
+            <value></value>
+            <value>false</value>            
+        </row>
+        
     </table>
 
     <table name="event_notification_hist">
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java
index c178874..22b4871 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java
@@ -98,4 +98,10 @@
         return 0;
     }
 
+    @Override
+    public AuditLog getByOriginAndCustomEventId(String origin, int 
customEventId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }


--
To view, visit http://gerrit.ovirt.org/10091
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3562865255fe680b2906a10b517e70a37e6e09db
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emes...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to