Muli Salem has uploaded a new change for review.

Change subject: core: STP Allowed Only in VM Network (#839546)
......................................................................

core: STP Allowed Only in VM Network (#839546)

https://bugzilla.redhat.com/839546

This patch adds a canDoAction in Add/Update NetworkCommand
to make sure the STP property is only used with VM Networks.

Change-Id: If5b628aaa62c0113d398781eca97ac5445928624
Signed-off-by: Muli Salem <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddNetworkCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/NetworkCommon.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateNetworkCommand.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
8 files changed, 25 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/7305/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddNetworkCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddNetworkCommand.java
index eef0d7a..8c0a57b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddNetworkCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddNetworkCommand.java
@@ -34,6 +34,10 @@
             return false;
         }
 
+        if (!validateStpProperty()) {
+            return false;
+        }
+
         // check that network name not start with 'bond'
         if 
(getParameters().getNetwork().getname().toLowerCase().startsWith("bond")) {
             
addCanDoActionMessage(VdcBllMessages.NETWORK_CANNOT_CONTAIN_BOND_NAME);
@@ -80,6 +84,7 @@
                 return false;
             }
         }
+
         return true;
     }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/NetworkCommon.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/NetworkCommon.java
index f89bde7..bf7fb8c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/NetworkCommon.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/NetworkCommon.java
@@ -38,4 +38,13 @@
 
         return retVal;
     }
+
+    protected boolean validateStpProperty() {
+        boolean stpIsAllowed = true;
+        if (!getParameters().getNetwork().isVmNetwork() && 
getParameters().getNetwork().getstp()) {
+            addCanDoActionMessage(VdcBllMessages.NON_VM_NETWORK_CANNOT_BE_STP);
+            stpIsAllowed = false;
+        }
+        return stpIsAllowed;
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateNetworkCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateNetworkCommand.java
index 281e16a..24495d1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateNetworkCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateNetworkCommand.java
@@ -48,6 +48,10 @@
             return false;
         }
 
+        if (!validateStpProperty()) {
+            return false;
+        }
+
         // check that network name not start with 'bond'
         if 
(getParameters().getNetwork().getname().toLowerCase().startsWith("bond")) {
             
addCanDoActionMessage(VdcBllMessages.NETWORK_CANNOT_CONTAIN_BOND_NAME);
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 39844a1..db4f622 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
@@ -397,6 +397,7 @@
     NETWORKS_DONT_EXIST_IN_CLUSTER,
     NETWORK_BONDS_INVALID_SLAVE_COUNT,
     NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS,
+    NON_VM_NETWORK_CANNOT_BE_STP,
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL,
     ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST,
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST,
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 14265ec..edbde47 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -427,6 +427,7 @@
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: ${VmNames}. Please stop 
the VMs and try again.
+NON_VM_NETWORK_CANNOT_BE_STP=Cannot ${action} ${type}. STP can only be enabled 
on VM Networks.
 CANNOT_PREIEW_CURRENT_IMAGE=The currently used VM Snapshot Image cannot be 
used in Preview command.
 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 8547610..52b890e 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
@@ -1119,6 +1119,9 @@
 
     @DefaultStringValue("Cannot ${action} ${type}. The following VMs are 
actively using the Logical Network: ${VmNames}. Please stop the VMs and try 
again.")
     String NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS();
+    
+    @DefaultStringValue("Cannot ${action} ${type}. STP can only be enabled on 
VM Networks.")
+    String NON_VM_NETWORK_CANNOT_BE_STP();
 
     @DefaultStringValue("The currently used VM Snapshot Image cannot be used 
in Preview command.")
     String CANNOT_PREIEW_CURRENT_IMAGE();
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 1dc91b5..076e745 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
@@ -425,6 +425,7 @@
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: ${VmNames}. Please stop 
the VMs and try again.
+NON_VM_NETWORK_CANNOT_BE_STP=Cannot ${action} ${type}. STP can only be enabled 
on VM Networks.
 CANNOT_PREIEW_CURRENT_IMAGE=The currently used VM Snapshot Image cannot be 
used in Preview command.
 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 b1aa351..89caca0 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
@@ -423,6 +423,7 @@
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: ${VmNames}. Please stop 
the VMs and try again.
+NON_VM_NETWORK_CANNOT_BE_STP=Cannot ${action} ${type}. STP can only be enabled 
on VM Networks.
 CANNOT_PREIEW_CURRENT_IMAGE=The currently used VM Snapshot Image cannot be 
used in Preview command.
 CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\
        -Please check configuration entry name.


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

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