Yevgeny Zaspitsky has uploaded a new change for review.

Change subject: engine,webadmin: Plugging of an unlinked vnic with an ext net 
is blocked
......................................................................

engine,webadmin: Plugging of an unlinked vnic with an ext net is blocked

Plugged and unlinked VM network interface is not supported for an
external network, thus the action is blocked.

Change-Id: Ia944ca7e0430adc54a6cae6cb65b8a1df4e88d24
Bug-Url: https://bugzilla.redhat.com/1077796
Signed-off-by: Yevgeny Zaspitsky <yzasp...@redhat.com>
(cherry picked from commit 04531c26302628d07b5f15e88113c2ead8e852ab)
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/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, 21 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/32629/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
index 2edb943..043e8c9 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java
@@ -210,7 +210,8 @@
                 || !validate(nicValidator.isCompatibleWithOs())
                 || !validate(nicValidator.emptyNetworkValid())
                 || !validate(nicValidator.hotUpdatePossible())
-                || 
!validate(nicValidator.profileValid(getVm().getVdsGroupId()))) {
+                || 
!validate(nicValidator.profileValid(getVm().getVdsGroupId()))
+                || 
!validate(nicValidator.canVnicWithExternalNetworkBePlugged())) {
             return false;
         }
 
@@ -375,5 +376,17 @@
                     ? ValidationResult.VALID
                             : new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED);
         }
+
+        public ValidationResult canVnicWithExternalNetworkBePlugged() {
+            return 
ValidationResult.failWith(VdcBllMessages.PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED)
+                    .when(RequiredAction.PLUG == getRequiredAction()
+                          && !nic.isLinked()
+                          && isVnicAttachedToExternalNetwork());
+        }
+
+        private boolean isVnicAttachedToExternalNetwork() {
+            final Network network = 
NetworkHelper.getNetworkByVnicProfileId(nic.getVnicProfileId());
+            return (network != null && network.isExternal());
+        }
     }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index a1761eb..caa1276 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -769,6 +769,7 @@
     ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
+    
PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS(ErrorType.INCOMPATIBLE_VERSION),
     CANNOT_PERFORM_HOT_UPDATE(ErrorType.CONFLICT),
     CANNOT_PERFORM_HOT_UPDATE_WITH_PORT_MIRRORING(ErrorType.CONFLICT),
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 16ea37e..ecfbe32 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -611,6 +611,7 @@
 ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. 
External network cannot have MTU set.
 ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The 
management network '${NetworkName}' must be required, please change the network 
to be required and try again.
 ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. 
The address of the network 
'${ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED_LIST}' cannot be 
modified without reinstalling the host, since this address was used to create 
the host's certification.
+PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED=Cannot 
${action} ${type}. Plugged and unlinked VM network interface with external 
network is not supported.
 CANNOT_PREVIEW_ACTIVE_SNAPSHOT=Cannot preview Active VM snapshot.
 CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\
        -Please check configuration entry name.
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 4c52168..92432cd 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
@@ -3354,4 +3354,7 @@
 
     @DefaultStringValue("Cannot ${action} ${type}. Target cluster belongs to 
different Data Center.")
     String VDS_CLUSTER_ON_DIFFERENT_STORAGE_POOL();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Plugged and unlinked VM 
network interface with external network is not supported.")
+    String 
PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED();
 }
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 64d621a..c35c22b 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
@@ -578,6 +578,7 @@
 ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. 
External network cannot have MTU set.
 ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The 
management network '${NetworkName}' must be required, please change the network 
to be required and try again.
 ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. 
The address of the network 
'${ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED_LIST}' cannot be 
modified without reinstalling the host, since this address was used to create 
the host's certification.
+PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED=Cannot 
${action} ${type}. Plugged and unlinked VM network interface with external 
network is not supported.
 CANNOT_PREVIEW_ACTIVE_SNAPSHOT=Cannot preview Active VM snapshot.
 CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\
        -Please check configuration entry name.
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 1144f13..9d3ace5 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
@@ -614,6 +614,7 @@
 ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. 
External network cannot have MTU set.
 ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The 
management network '${NetworkName}' must be required, please change the network 
to be required and try again.
 ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. 
The address of the network 
'${ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED_LIST}' cannot be 
modified without reinstalling the host, since this address was used to create 
the host's certification.
+PLUGGED_UNLINKED_VM_INTERFACE_WITH_EXTERNAL_NETWORK_IS_NOT_SUPPORTED=Cannot 
${action} ${type}. Plugged and unlinked VM network interface with external 
network is not supported.
 CANNOT_PREVIEW_ACTIVE_SNAPSHOT=Cannot preview Active VM snapshot.
 CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\
        -Please check configuration entry name.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia944ca7e0430adc54a6cae6cb65b8a1df4e88d24
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Yevgeny Zaspitsky <yzasp...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to