Maor Lipchuk has uploaded a new change for review.

Change subject: core: Add audit log when removing networks from iSCSI bond.
......................................................................

core: Add audit log when removing networks from iSCSI bond.

Adding an audit log to indicate the user that the removed networks
from the iSCSI bond, will only take affect, after the Hosts will be moved
to maintenance and activated again.

Change-Id: I087818bb48cc9243e76b2cb850e6262104537f3c
Bug-Url: https://bugzilla.redhat.com/1094144
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
3 files changed, 22 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/31012/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
index a1089b1..ded5740 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
@@ -11,9 +11,11 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.EditIscsiBondParameters;
 import org.ovirt.engine.core.common.businessentities.IscsiBond;
+import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.validation.group.UpdateEntity;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 import org.ovirt.engine.core.utils.transaction.TransactionSupport;
 
@@ -24,6 +26,7 @@
 
     private List<String> addedConnections = new ArrayList<>();
     private List<Guid> addedNetworks = new ArrayList<>();
+    private Set<Guid> removedNetworks = new HashSet<>();
 
     public EditIscsiBondCommand(T parameters) {
         super(parameters);
@@ -60,7 +63,7 @@
                     getDbFacade().getIscsiBondDao().update(getIscsiBond());
                 }
 
-                updateNetworksIds();
+                removedNetworks = updateNetworksIds();
                 updateConnectionsIds();
 
                 return null;
@@ -71,10 +74,24 @@
             connectAllHostsToStorage(getIscsiBond().getStorageConnectionIds());
         }
 
+        if (!removedNetworks.isEmpty()) {
+            addAuditLogForRemovedNetowrks(removedNetworks);
+        }
         setSucceeded(true);
     }
 
-    private void updateNetworksIds() {
+    private void addAuditLogForRemovedNetowrks(Set<Guid> removedNetworks) {
+        List<String> networkNames = new ArrayList<>();
+        for (Guid networkId : removedNetworks) {
+            Network network = getDbFacade().getNetworkDao().get(networkId);
+            networkNames.add(network.getName());
+        }
+        addCustomValue("NetworkNames", StringUtils.join(networkNames, ","));
+        addCustomValue("IscsiBondName", getIscsiBond().getName());
+        AuditLogDirector.log(this, 
AuditLogType.USER_ISCSI_BOND_HOST_RESTART_WARNING);
+    }
+
+    private Set<Guid> updateNetworksIds() {
         Set<Guid> beforeChangeNetworkIds = new 
HashSet<>(getExistingIscsiBond().getNetworkIds());
 
         for (Guid networkId : getIscsiBond().getNetworkIds()) {
@@ -87,6 +104,7 @@
         for (Guid networkId : beforeChangeNetworkIds) {
             
getDbFacade().getIscsiBondDao().removeNetworkFromIscsiBond(getExistingIscsiBond().getId(),
 networkId);
         }
+        return beforeChangeNetworkIds;
     }
 
     private void updateConnectionsIds() {
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 ccaebd4..2b6c0b4 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
@@ -253,6 +253,7 @@
     USER_EXPORT_IMAGE_FINISHED_FAILURE(2032, AuditLogSeverity.ERROR),
     HOT_SET_NUMBER_OF_CPUS(2033),
     FAILED_HOT_SET_NUMBER_OF_CPUS(2034, AuditLogSeverity.ERROR),
+    USER_ISCSI_BOND_HOST_RESTART_WARNING(2035, AuditLogSeverity.WARNING),
 
     // Used only from SQL script, therefor should not have severity & message
     USER_RUN_UNLOCK_ENTITY_SCRIPT(2024),
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 33d1307..5769814 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -99,6 +99,7 @@
 USER_EXPORT_IMAGE_FINISHED_FAILURE=User ${UserName} failed to export image 
${RepoImageName} to domain ${DestinationStorageDomainName}.
 HOT_SET_NUMBER_OF_CPUS=VM ${vmName} number of CPUs is hot set to 
${numberOfCpus}
 FAILED_HOT_SET_NUMBER_OF_CPUS= Failed to hot set number of CPUS to VM 
${vmName}. Underlying error message: ${ErrorMessage}
+USER_ISCSI_BOND_HOST_RESTART_WARNING=The following Networks has been removed 
from the iSCSI bond ${IscsiBondName}: ${NetworkNames}. for those changes to 
take affect, the hosts must be moved to maintenance and activated again.
 USER_MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE=Possible failure while 
deleting ${DiskAlias} from the source Storage Domain ${StorageDomainName} 
during the move operation. The Storage Domain may be manually cleaned-up from 
possible leftovers (User:${UserName}).
 USER_MOVE_IMAGE_GROUP_FAILED_TO_DELETE_DST_IMAGE=Possible failure while 
clearing possible leftovers of ${DiskAlias} from the target Storage Domain 
${StorageDomainName} after the move operation failed to copy the image to it 
properly. The Storage Domain may be manually cleaned-up from possible leftovers 
(User:${UserName}).
 USER_REMOVE_DISK_FROM_VM=Disk was removed from VM ${VmName} by ${UserName}.


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

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

Reply via email to