Moti Asayag has uploaded a new change for review.

Change subject: engine: Add audit log for network without interfaces
......................................................................

engine: Add audit log for network without interfaces

An audit log should be added to the use case in which
vdsm doesn't report any interface to a reported network.
This error was hidden by the event log of 'network is
attached to multiple interfaces'.

Change-Id: I3d2e9a3793ac1511debc25d69755ed0e99598cee
Bug-Url: https://bugzilla.redhat.com/881055
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.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/resources/bundles/AuditLogMessages.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
4 files changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/19291/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 68f2611..226c200 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
@@ -603,6 +603,7 @@
     UPDATE_VNIC_PROFILE_FAILED(1125),
     REMOVE_VNIC_PROFILE(1126),
     REMOVE_VNIC_PROFILE_FAILED(1127),
+    NETWORK_WITHOUT_INTERFACES(1128),
 
     // Import/Export
     IMPORTEXPORT_STARTING_EXPORT_VM(1162),
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 70cdd28..ffe8809 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
@@ -802,6 +802,7 @@
         severities.put(AuditLogType.UPDATE_VNIC_PROFILE_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.REMOVE_VNIC_PROFILE, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.REMOVE_VNIC_PROFILE_FAILED, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.NETWORK_WITHOUT_INTERFACES, 
AuditLogSeverity.WARNING);
     }
 
     private static void initExtrnalEvents() {
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 5a78c63..dd5c6e0 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -443,6 +443,7 @@
 VDS_NETWORKS_OUT_OF_SYNC=Host ${VdsName}'s following network(s) are not 
synchronized with their Logical Network configuration: ${Networks}.
 VDS_SET_NONOPERATIONAL_IFACE_DOWN=Host ${VdsName} moved to Non-Operational 
state because interfaces '${Interfaces}' are down but are needed by networks 
'${Networks}' in the current cluster
 BRIDGED_NETWORK_OVER_MULTIPLE_INTERFACES=Bridged network ${NetworkName} is 
attached to multiple interfaces: ${Interfaces} on Host ${VdsName}.
+NETWORK_WITHOUT_INTERFACES=Network ${NetworkName} is not attached to any 
interface on Host ${VdsName}.
 PROVIDER_ADDED=Provider ${ProviderName} was added. (User: ${UserName})
 PROVIDER_ADDITION_FAILED=Failed to add provider ${ProviderName}. (User: 
${UserName})
 PROVIDER_UPDATED=Provider ${ProviderName} was updated. (User: ${UserName})
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index d5c694e..6a8315f 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -981,14 +981,22 @@
      *            The host in which the network is defined
      */
     private static void 
reportInvalidInterfacesForNetwork(List<VdsNetworkInterface> interfaces, Network 
network, VDS vds) {
-        if (interfaces.size() != 1) {
-            AuditLogableBase logable = new AuditLogableBase(vds.getId());
-            logable.addCustomValue("NetworkName", network.getName());
+        if (interfaces.isEmpty()) {
+            AuditLogableBase logable = createHostNetworkAuditLog(network, vds);
+            AuditLogDirector.log(logable, 
AuditLogType.NETWORK_WITHOUT_INTERFACES);
+        } else if (interfaces.size() > 1) {
+            AuditLogableBase logable = createHostNetworkAuditLog(network, vds);
             logable.addCustomValue("Interfaces", 
StringUtils.join(Entities.objectNames(interfaces), ","));
             AuditLogDirector.log(logable, 
AuditLogType.BRIDGED_NETWORK_OVER_MULTIPLE_INTERFACES);
         }
     }
 
+    protected static AuditLogableBase createHostNetworkAuditLog(Network 
network, VDS vds) {
+        AuditLogableBase logable = new AuditLogableBase(vds.getId());
+        logable.addCustomValue("NetworkName", network.getName());
+        return logable;
+    }
+
     private static List<VdsNetworkInterface> findNetworkInterfaces(VDS vds,
             Map<String, Object> xmlRpcStruct,
             Map<String, Object> network) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d2e9a3793ac1511debc25d69755ed0e99598cee
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to