Moti Asayag has uploaded a new change for review.

Change subject: engine: Update vnic profile id when adding vm from snapshot
......................................................................

engine: Update vnic profile id when adding vm from snapshot

Adding vm from snapshot loads the vm configuration from the
OVF which requires resolving the vnic profile id by the
network name and the vnic profile name.

Change-Id: Ie3057590b59fc7281b1c49fb9b94144999bcb471
Bug-Url: https://bugzilla.redhat.com/1003523
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromSnapshotCommand.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
4 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/18798/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromSnapshotCommand.java
index eba6f10..82f65d3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmFromSnapshotCommand.java
@@ -6,11 +6,13 @@
 import java.util.List;
 import java.util.Map;
 
+import org.ovirt.engine.core.bll.network.vm.VnicProfileHelper;
 import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.bll.utils.VmDeviceUtils;
 import org.ovirt.engine.core.bll.validator.DiskImagesValidator;
 import org.ovirt.engine.core.bll.validator.VmValidator;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.AddVmFromSnapshotParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
@@ -125,6 +127,21 @@
     }
 
     @Override
+    protected void addVmNetwork() {
+        VnicProfileHelper vnicProfileHelper =
+                new VnicProfileHelper(getVm().getVdsGroupId(),
+                        getStoragePoolId(),
+                        getVdsGroup().getcompatibility_version());
+
+        for (VmNetworkInterface iface : vmFromConfiguration.getInterfaces()) {
+            vnicProfileHelper.updateNicWithVnicProfileForUser(iface, 
getCurrentUser().getUserId());
+        }
+
+        vnicProfileHelper.auditInvalidInterfaces(getVmName(), 
AuditLogType.ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES);
+        super.addVmNetwork();
+    }
+
+    @Override
     protected boolean addVmImages() {
         int numberOfStartedCopyTasks = 0;
         try {
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 e22f1bc..3dcaed1 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
@@ -757,6 +757,7 @@
     HA_VM_RESTART_FAILED(9603),
 
     IMPORTEXPORT_SNAPSHOT_VM_INVALID_INTERFACES(9606, 
AuditLogTimeInterval.MINUTE.getValue()),
+    ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES(9607, 
AuditLogTimeInterval.MINUTE.getValue()),
 
     // DWH
     DWH_STOPPED(9701),
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 7678ada..851650d 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
@@ -652,6 +652,7 @@
         severities.put(AuditLogType.USER_UPDATE_VM_FROM_UNTRUSTED_TO_TRUSTED, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VM_SET_TICKET, AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.VM_SET_TICKET_FAILED, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES, 
AuditLogSeverity.WARNING);
     }
 
     private static void initClusterSeverities() {
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 42dc162..64de49e 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -593,6 +593,7 @@
 IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES=While importing VM ${EntityName}, 
the Network/s ${Networks} were found to be Non-VM Networks or do not exist in 
Cluster. Network Name was not set in the Interface/s ${Interfaces}.
 IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES=While importing Template 
${EntityName}, the Network/s ${Networks} were found to be Non-VM Networks or do 
not exist in Cluster. Network Name was not set in the Interface/s ${Interfaces}.
 IMPORTEXPORT_SNAPSHOT_VM_INVALID_INTERFACES=While previewing a snapshot of VM 
${EntityName}, the Network/s ${Networks} were found to be Non-VM Networks or do 
not exist in Cluster. Network Name was not set in the Interface/s ${Interfaces}.
+ADD_VM_FROM_SNAPSHOT_INVALID_INTERFACES=While adding vm ${EntityName} from 
snapshot, the Network/s ${Networks} were found to be Non-VM Networks or do not 
exist in Cluster. Network Name was not set 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 
non-VM networks: '${Networks}'
 EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER=Host ${VdsName} does not comply 
with the cluster ${VdsGroupName} emulated machines. The Hosts emulated machines 
are ${hostSupportedEmulatedMachines} and the cluster is 
${clusterEmulatedMachines}}
 # Gluster Messages


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

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

Reply via email to