Muli Salem has uploaded a new change for review.

Change subject: core: Erase Network Name and Change Audit Log (#844396)
......................................................................

core: Erase Network Name and Change Audit Log (#844396)

https://bugzilla.redhat.com/844396

This patch makes sure the Network name is removed from Nic
in case the Network name was found to be invalid. Also, it
separates the audit log into two - one for ImportVm and
the other for ImportVmTemplate.

The patch also changes the wording of the audit log to
be more accurate.

Signed-off-by: Muli Salem <[email protected]>
Change-Id: I1c0e2258d1523c99ef095a3e07947835ff0c5da2
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
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
6 files changed, 23 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/7326/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
index e563d8c..185844d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmCommand.java
@@ -823,6 +823,7 @@
             if (!VmInterfaceManager.isValidVmNetwork(iface, 
networksInVdsByName)) {
                 invalidNetworkNames.add(iface.getNetworkName());
                 invalidIfaceNames.add(iface.getName());
+                iface.setNetworkName(StringUtils.EMPTY);
             }
 
             macAdded = vmInterfaceManager.add(iface, getCompensationContext(), 
getParameters().isImportAsNewEntity());
@@ -1035,4 +1036,8 @@
         }
     }
 
+    @Override
+    protected AuditLogType getAuditLogTypeForInvalidInterfaces() {
+        return AuditLogType.IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES;
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java
index 07c1dac..8bcacb1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportVmTemplateCommand.java
@@ -532,4 +532,9 @@
             }
         }
     }
+
+    @Override
+    protected AuditLogType getAuditLogTypeForInvalidInterfaces() {
+        return AuditLogType.IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES;
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
index 1bfc0f0..666bc4a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java
@@ -11,6 +11,7 @@
 import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
+import org.jboss.util.NotImplementedException;
 import org.ovirt.engine.core.bll.command.utils.StorageDomainSpaceChecker;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.storage.StorageDomainCommandBase;
@@ -369,7 +370,12 @@
             AuditLogableBase logable = new AuditLogableBase();
             logable.AddCustomValue("Networks", 
StringUtils.join(invalidNetworkNames, ','));
             logable.AddCustomValue("Interfaces", 
StringUtils.join(invalidIfaceNames, ','));
-            AuditLogDirector.log(logable, 
AuditLogType.IMPORTEXPORT_IMPORT_VM_INTERFACES_ON_NON_VM_NETWORKS);
+            AuditLogDirector.log(logable, 
getAuditLogTypeForInvalidInterfaces());
         }
     }
+
+    protected AuditLogType getAuditLogTypeForInvalidInterfaces() {
+        // Functionality must be implemented in subclasses
+        throw new NotImplementedException();
+    }
 }
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 7995afc..47ac8cf 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
@@ -507,6 +507,7 @@
     IMPORTEXPORT_REMOVE_VM_FAILED(1161),
     IMPORTEXPORT_FAILED_TO_IMPORT_VM(1168),
     IMPORTEXPORT_FAILED_TO_IMPORT_TEMPLATE(1169),
+    IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES(1170, 
AuditLogTimeInterval.MINUTE.getValue()),
 
     USER_ADD_PERMISSION(850),
     USER_ADD_PERMISSION_FAILED(851),
@@ -610,7 +611,7 @@
     USER_ACTIVATED_STORAGE_DOMAIN_ASYNC(9505, 
AuditLogTimeInterval.HOUR.getValue() * 3),
     USER_ACTIVATE_STORAGE_DOMAIN_FAILED_ASYNC(9506, 
AuditLogTimeInterval.HOUR.getValue() * 3),
 
-    IMPORTEXPORT_IMPORT_VM_INTERFACES_ON_NON_VM_NETWORKS(9600, 
AuditLogTimeInterval.MINUTE.getValue()),
+    IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES(9600, 
AuditLogTimeInterval.MINUTE.getValue()),
     VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS(9601, 
AuditLogTimeInterval.MINUTE.getValue()),
 
 
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 f7f942e..fc20760 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
@@ -597,7 +597,8 @@
         mSeverities.put(AuditLogType.IMPORTEXPORT_STARTING_REMOVE_VM, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.IMPORTEXPORT_FAILED_TO_IMPORT_VM, 
AuditLogSeverity.WARNING);
         mSeverities.put(AuditLogType.IMPORTEXPORT_FAILED_TO_IMPORT_TEMPLATE, 
AuditLogSeverity.WARNING);
-        
mSeverities.put(AuditLogType.IMPORTEXPORT_IMPORT_VM_INTERFACES_ON_NON_VM_NETWORKS,
 AuditLogSeverity.NORMAL);
+        
mSeverities.put(AuditLogType.IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES, 
AuditLogSeverity.NORMAL);
+        
mSeverities.put(AuditLogType.IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES, 
AuditLogSeverity.NORMAL);
     }
 
     private static void initNetworkSeverities() {
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 9bc196b..49ed79b 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -515,7 +515,8 @@
 RELOAD_CONFIGURATIONS_FAILURE=System Configurations failed to reload.
 USER_ACCOUNT_DISABLED_OR_LOCKED=User ${UserName} cannot login, as it got 
disabled or locked. Please contact the system administrator.
 USER_ACCOUNT_PASSWORD_EXPIRED=User ${UserName} cannot login, as the user 
account password has expired. Please contact the system administrator.
-IMPORTEXPORT_IMPORT_VM_INTERFACES_ON_NON_VM_NETWORKS=Trying to import VM 
${VmName} with the interface/s ${Interfaces} attached to non VM or non-existent 
cluster network/s ${Networks}.
+IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES=While importing VM ${VmName}, the 
Network/s ${Networks} were found to be Non-VM Networks or do not exist in 
Cluster. Network Name was set to empty in the Interface/s ${Interfaces}.
+IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES=While importing Template 
${VmTemplateName}, the Network/s ${Networks} were found to be Non-VM Networks 
or do not exist in Cluster. Network Name was set to empty in the Interface/s 
${Interfaces}.
 VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS=Host ${VdsName} does not 
comply with the cluster ${VdsGroupName} networks, the following VM networks are 
bridgeless: '${Networks}'
 # Gluster Messages
 GLUSTER_VOLUME_CREATE=Gluster Volume ${glusterVolumeName} created.


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

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

Reply via email to