Moti Asayag has uploaded a new change for review.

Change subject: engine: Block provide type change
......................................................................

engine: Block provide type change

There is no sense to modify the provider type, i.e. when
an OpenStack provider is created, the ovirt-engine creates
the required storage domain for it. Modifying the type of
a provider to a different type modifies the entire nature
of the provider.

Each provider has its own definition based on its type and
modifying the type will not be supported.

Change-Id: I3f5b0980977bc9fe556b1e3a72b1942bd8d86cdc
Bug-Url: https://bugzilla.redhat.com/1227320
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/UpdateProviderCommand.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/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
5 files changed, 14 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/41934/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/UpdateProviderCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/UpdateProviderCommand.java
index 6352748..3bc227e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/UpdateProviderCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/UpdateProviderCommand.java
@@ -5,6 +5,7 @@
 
 import org.ovirt.engine.core.bll.CommandBase;
 import org.ovirt.engine.core.bll.RenamedEntityInfoProvider;
+import org.ovirt.engine.core.bll.ValidationResult;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
@@ -50,7 +51,13 @@
         ProviderValidator validatorOld = new 
ProviderValidator(getOldProvider());
         ProviderValidator validatorNew = new ProviderValidator(getProvider());
         return validate(validatorOld.providerIsSet())
-                && (nameKept() || validate(validatorNew.nameAvailable()));
+                && (nameKept() || validate(validatorNew.nameAvailable()))
+                && validate(providerTypeNotChanged(getOldProvider(), 
getProvider()));
+    }
+
+    private ValidationResult providerTypeNotChanged(Provider<?> oldProvider, 
Provider<?> newProvider) {
+        return 
ValidationResult.failWith(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_CHANGE_PROVIDER_TYPE)
+                .when(oldProvider.getType() != newProvider.getType());
     }
 
     private boolean nameKept() {
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 38902b9..ce5cce8 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
@@ -610,6 +610,7 @@
     ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_MIGRATION_NETWORK_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_PROVIDER_DOESNT_EXIST(ErrorType.BAD_PARAMETERS),
+    ACTION_TYPE_FAILED_CANNOT_CHANGE_PROVIDER_TYPE(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_UNSET(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_GLUSTER_NETWORK_INUSE(ErrorType.BAD_PARAMETERS),
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 94420fe..3854717 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -647,6 +647,7 @@
 ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT=Cannot ${action} ${type}. 
Network cluster ${NetworkCluster} appears more than once.
 ACTION_TYPE_FAILED_MIGRATION_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} 
${type}. Migration network is not supported for this cluster version.
 ACTION_TYPE_FAILED_PROVIDER_DOESNT_EXIST=Cannot ${action} ${type}. The 
provider does not exist in the system.
+ACTION_TYPE_FAILED_CANNOT_CHANGE_PROVIDER_TYPE=Cannot ${action} ${type}. The 
provider type cannot be changed.
 ACTION_TYPE_FAILED_PROVIDER_TYPE_MISMATCH=Cannot ${action} ${type}. The 
provider type should be 'OpenStack Networking'.
 ACTION_TYPE_FAILED_HOST_PROVIDER_TYPE_MISMATCH=Cannot ${action} ${type}. The 
provider type should be 'External Host Provider (Foreman/Satellite)'.
 ACTION_TYPE_FAILED_MISSING_NETWORK_MAPPINGS=Cannot ${action} ${type}. The 
network mappings should be provided as a parameter or configured on the network 
provider.
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 902a4be..c685190 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
@@ -1792,6 +1792,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. The provider does not exist 
in the system.")
     String ACTION_TYPE_FAILED_PROVIDER_DOESNT_EXIST();
 
+    @DefaultStringValue("Cannot ${action} ${type}. The provider type cannot be 
changed.")
+    String ACTION_TYPE_FAILED_CANNOT_CHANGE_PROVIDER_TYPE();
+
     @DefaultStringValue("Cannot ${action} ${type}. The provider type should be 
'OpenStack Networking'.")
     String ACTION_TYPE_FAILED_PROVIDER_TYPE_MISMATCH();
 
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 1d8a9c3..ff328b3 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
@@ -655,6 +655,7 @@
 ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT=Cannot ${action} ${type}. 
Network cluster ${NetworkCluster} appears more than once.
 ACTION_TYPE_FAILED_MIGRATION_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} 
${type}. Migration network is not supported for this cluster version.
 ACTION_TYPE_FAILED_PROVIDER_DOESNT_EXIST=Cannot ${action} ${type}. The 
provider does not exist in the system.
+ACTION_TYPE_FAILED_CANNOT_CHANGE_PROVIDER_TYPE=Cannot ${action} ${type}. The 
provider type cannot be changed.
 ACTION_TYPE_FAILED_PROVIDER_TYPE_MISMATCH=Cannot ${action} ${type}. The 
provider type should be 'OpenStack Networking'.
 ACTION_TYPE_FAILED_HOST_PROVIDER_TYPE_MISMATCH=Cannot ${action} ${type}. The 
provider type should be 'External Host Provider (Foreman/Satellite)'.
 ACTION_TYPE_FAILED_MISSING_NETWORK_MAPPINGS=Cannot ${action} ${type}. The 
network mappings should be provided as a parameter or configured on the network 
provider.


-- 
To view, visit https://gerrit.ovirt.org/41934
To unsubscribe, visit https://gerrit.ovirt.org/settings

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