Moti Asayag has uploaded a new change for review.

Change subject: engine: Block changing a used label
......................................................................

engine: Block changing a used label

Changing a used label isn't supported and should
be blocked until it does.

Change-Id: I473ff703c35be305abec7b78c44e983c58d4cb03
Bug-Url: https://bugzilla.redhat.com/1091714
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/dc/UpdateNetworkCommand.java
1 file changed, 25 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/27479/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/dc/UpdateNetworkCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/dc/UpdateNetworkCommand.java
index 13691fc..cfa2480 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/dc/UpdateNetworkCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/dc/UpdateNetworkCommand.java
@@ -151,7 +151,8 @@
                 Objects.equals(oldNetwork.getProvidedBy(), 
newNetwork.getProvidedBy()) &&
                 Objects.equals(oldNetwork.getStp(), newNetwork.getStp()) &&
                 Objects.equals(oldNetwork.getVlanId(), newNetwork.getVlanId()) 
&&
-                Objects.equals(oldNetwork.isVmNetwork(), 
newNetwork.isVmNetwork());
+                Objects.equals(oldNetwork.isVmNetwork(), 
newNetwork.isVmNetwork() &&
+                Objects.equals(oldNetwork.getLabel(), newNetwork.getLabel()));
     }
 
     private boolean oldAndNewNetworkIsNotExternal() {
@@ -182,15 +183,22 @@
             super(network);
         }
 
-        public ValidationResult notRenamingLabel(String oldLabel) {
-            if (network.getLabel() == null || oldLabel == null || 
network.getLabel().equals(oldLabel)) {
+        public ValidationResult notRenamingLabel(String newLabel) {
+            String oldLabel = network.getLabel();
+            if (oldLabel == null || newLabel == null || 
oldLabel.equals(newLabel)) {
                 return ValidationResult.VALID;
             }
 
             List<VdsNetworkInterface> nics =
                     
getDbFacade().getInterfaceDao().getVdsInterfacesByNetworkId(network.getId());
             for (VdsNetworkInterface nic : nics) {
-                if (NetworkUtils.isLabeled(nic) && 
nic.getLabels().contains(oldLabel)) {
+                VdsNetworkInterface labeledNic = null;
+                if (NetworkUtils.isVlan(nic)) {
+                    labeledNic = getBaseInterface(nic);
+                }
+
+                labeledNic = labeledNic == null ? nic : labeledNic;
+                if (NetworkUtils.isLabeled(labeledNic) && 
labeledNic.getLabels().contains(oldLabel)) {
                     new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_LABEL_RENAMING_NOT_SUPPORTED);
                 }
             }
@@ -198,6 +206,19 @@
             return ValidationResult.VALID;
         }
 
+        private VdsNetworkInterface getBaseInterface(VdsNetworkInterface vlan) 
{
+            List<VdsNetworkInterface> hostNics =
+                    
getDbFacade().getInterfaceDao().getAllInterfacesForVds(vlan.getVdsId());
+
+            for (VdsNetworkInterface hostNic : hostNics) {
+                if (NetworkUtils.interfaceBasedOn(vlan, hostNic.getName())) {
+                    return hostNic;
+                }
+            }
+
+            return null;
+        }
+
         public ValidationResult notRenamingUsedNetwork(String networkName) {
             if (StringUtils.equals(network.getName(), networkName)) {
                 return ValidationResult.VALID;


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I473ff703c35be305abec7b78c44e983c58d4cb03
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