Muli Salem has uploaded a new change for review.

Change subject: enging: Block Hot Adding a Nic in 3.0
......................................................................

enging: Block Hot Adding a Nic in 3.0

This patch adds a validation in AddVmInterfaceCommand
that makes sure the cluster version supports Hot
Adding a vm network interface, if this is the case.

Change-Id: Ic0ee6563b55a84421b3a9a068e6d69ff228d46ae
Bug-Url: https://bugzilla.redhat.com/923332
Signed-off-by: Muli Salem <msa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
6 files changed, 32 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/44/13244/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java
index 0dca4cf..0926396 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/AddVmInterfaceCommand.java
@@ -5,11 +5,13 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
+import org.ovirt.engine.core.bll.ValidationResult;
 import org.ovirt.engine.core.bll.network.MacPoolManager;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.bll.utils.VmDeviceUtils;
 import org.ovirt.engine.core.bll.validator.VmNicValidator;
 import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.AddVmInterfaceParameters;
 import org.ovirt.engine.core.common.action.PlugAction;
@@ -103,8 +105,14 @@
             return false;
         }
 
+        Version compatibilityVersion = 
getVm().getVdsGroupCompatibilityVersion();
+        AddVmNicValidator nicValidator = new AddVmNicValidator(getInterface(), 
compatibilityVersion);
+
         switch (getVmDynamicDao().get(getParameters().getVmId()).getstatus()) {
         case Up:
+            if (!validate(nicValidator.hotAddSupported())) {
+                return false;
+            }
         case Down:
         case ImageLocked:
             break;
@@ -130,9 +138,6 @@
         if (!pciAndIdeWithinLimit(vm, allInterfaces)) {
             return false;
         }
-
-        Version compatibilityVersion = 
getVm().getVdsGroupCompatibilityVersion();
-        VmNicValidator nicValidator = new VmNicValidator(getInterface(), 
compatibilityVersion);
 
         if (!validate(nicValidator.linkedCorrectly()) || 
!validate(nicValidator.networkNameValid())
                 || !validate(nicValidator.networkProvidedForPortMirroring())) {
@@ -218,4 +223,21 @@
         }
         return permissionList;
     }
+
+    /**
+     * Internal validator that adds checks specific to this class, but uses 
info from the {@link VmNicValidator}.
+     */
+    private class AddVmNicValidator extends VmNicValidator {
+
+        public AddVmNicValidator(VmNetworkInterface nic, Version version) {
+            super(nic, version);
+        }
+
+        private ValidationResult hotAddSupported() {
+            return FeatureSupported.hotPlug(version)
+            ? new 
ValidationResult(VdcBllMessages.HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED,
+                            clusterVersion())
+            : ValidationResult.VALID;
+        }
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
index bd53bd8..cd7b63a 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java
@@ -618,6 +618,7 @@
     UNLINKING_IS_NOT_SUPPORTED,
     NULL_NETWORK_IS_NOT_SUPPORTED,
     HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED,
+    HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED,
     CANNOT_PERFOM_HOT_UPDATE,
     CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING,
     PORT_MIRRORING_REQUIRES_NETWORK,
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 11c0477..b947bb1 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -726,6 +726,7 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
+HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Adding the 
virtual machine interface while the virtual machine is running is not supported 
for clusters of version ${clusterVersion}.
 CANNOT_PERFOM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
 CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING=Cannot ${action} ${type}. Update 
is not possible when 'Port Mirroring' is set on the interface of a running 
virtual machine.
 PORT_MIRRORING_REQUIRES_NETWORK=Cannot ${action} ${type}. 'Port Mirroring' 
setting requires a network.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 17f25cf..058c9d2 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1960,6 +1960,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Updating the virtual 
machine interface while the virtual machine is running is not supported for 
clusters of version ${clusterVersion}.")
     String HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Adding the virtual machine 
interface while the virtual machine is running is not supported for clusters of 
version ${clusterVersion}.")
+    String HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.")
     String CANNOT_PERFOM_HOT_UPDATE();
 
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index e2bb661..d837adc 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -719,6 +719,7 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
+HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Adding the 
virtual machine interface while the virtual machine is running is not supported 
for clusters of version ${clusterVersion}.
 CANNOT_PERFOM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
 CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING=Cannot ${action} ${type}. Update 
is not possible when 'Port Mirroring' is set on the interface of a running 
virtual machine.
 PORT_MIRRORING_REQUIRES_NETWORK=Cannot ${action} ${type}. 'Port Mirroring' 
setting requires a network.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 8721a49..e37ea7d 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -718,6 +718,7 @@
 UNLINKING_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Link state is set to 
'Down' on the virtual machine's interface, this is not supported for clusters 
of version ${clusterVersion}.
 NULL_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. There is no network on 
the virtual machine's interface, this is not supported for clusters of version 
${clusterVersion}.
 HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Updating 
the virtual machine interface while the virtual machine is running is not 
supported for clusters of version ${clusterVersion}.
+HOT_VM_INTERFACE_ADD_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Adding the 
virtual machine interface while the virtual machine is running is not supported 
for clusters of version ${clusterVersion}.
 CANNOT_PERFOM_HOT_UPDATE=Cannot ${action} ${type}. Updating some of the 
properties is not supported while the interface is plugged into a running 
virtual machine. Please un-plug the interface, update the properties, and then 
plug it back.
 CANNOT_PERFOM_HOT_UPDATE_WITH_PORT_MIRRORING=Cannot ${action} ${type}. Update 
is not possible when 'Port Mirroring' is set on the interface of a running 
virtual machine.
 PORT_MIRRORING_REQUIRES_NETWORK=Cannot ${action} ${type}. 'Port Mirroring' 
setting requires a network.


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

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

Reply via email to