Mike Kolesnik has uploaded a new change for review. Change subject: core: Block attaching unsupported external networks ......................................................................
core: Block attaching unsupported external networks External networks can't be used on clusters where per-device custom properties aren't supported, so blocked attaching the networks to such clusters. Change-Id: Ia4391fdf62419c9f54f134eaba7a337f4ca0725c Bug-Url: https://bugzilla.redhat.com/987817 Signed-off-by: Mike Kolesnik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/AttachNetworkToVdsGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidator.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidatorTest.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 8 files changed, 41 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/17385/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/AttachNetworkToVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/AttachNetworkToVdsGroupCommand.java index bfafc5a..9afd745 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/AttachNetworkToVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/AttachNetworkToVdsGroupCommand.java @@ -81,7 +81,8 @@ } private boolean validateExternalNetwork(NetworkClusterValidator validator) { - return validate(validator.externalNetworkNotDisplay(getNetworkName())) + return validate(validator.externalNetworkSupported()) + && validate(validator.externalNetworkNotDisplay(getNetworkName())) && validate(validator.externalNetworkNotRequired(getNetworkName())); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidator.java index 5bd7205..bcafb22 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidator.java @@ -3,8 +3,8 @@ import org.ovirt.engine.core.bll.ValidationResult; import org.ovirt.engine.core.common.FeatureSupported; import org.ovirt.engine.core.common.businessentities.network.NetworkCluster; -import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.compat.Version; /** * Validator class for {@link NetworkCluster} instances. @@ -46,6 +46,17 @@ } /** + * Make sure the external network attachment is supported for the version. + * + * @return Error iff the external network attachment is not supported. + */ + public ValidationResult externalNetworkSupported() { + return FeatureSupported.deviceCustomProperties(version) + ? ValidationResult.VALID + : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED); + } + + /** * Make sure the external network attachment is valid: The network cannot be used as a display network. * * @param networkName diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidatorTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidatorTest.java index 0c4a62f..1a4990d 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidatorTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/cluster/NetworkClusterValidatorTest.java @@ -18,9 +18,9 @@ import org.ovirt.engine.core.bll.ValidationResult; import org.ovirt.engine.core.common.businessentities.network.NetworkCluster; import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.utils.MockConfigRule; -import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.utils.RandomUtils; @RunWith(MockitoJUnitRunner.class) @@ -103,4 +103,23 @@ assertThat(validator.migrationPropertySupported(NETWORK_NAME), matcher); } + + @Test + public void externalNetworkNotSupported() throws Exception { + externalNetworkSupportTest(failsWith(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED), + false); + } + + @Test + public void externalNetworkSupported() throws Exception { + externalNetworkSupportTest(isValid(), + true); + } + + private void externalNetworkSupportTest(Matcher<ValidationResult> matcher, + boolean externalNetworkSupported) { + mockConfigRule.mockConfigValue(ConfigValues.SupportCustomDeviceProperties, version, externalNetworkSupported); + + assertThat(validator.externalNetworkSupported(), matcher); + } } 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 a4a963e..8d744fd 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 @@ -430,6 +430,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_ALREADY_EXISTS(ErrorType.CONFLICT), ACTION_TYPE_FAILED_EXTERNAL_NETWORK_DETAILS_CANNOT_BE_EDITED(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_EXTERNAL_NETWORK_MUST_BE_VM_NETWORK(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_PROVIDER_NETWORKS_USED(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 975457a..b0112ae 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -497,6 +497,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_ALREADY_EXISTS=Cannot ${action} ${type}. The external network already exists as '${NetworkName}' in the data center. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_MUST_BE_VM_NETWORK=Cannot ${action} ${type}. An external network cannot be a non-VM network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_DETAILS_CANNOT_BE_EDITED=Cannot ${action} ${type}. External network details (except name and description) cannot be changed. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED=Cannot ${action} ${type}. External networks are not supported for this cluster's compatibility version. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. 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 04156bd..fbfc319 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 @@ -1345,6 +1345,9 @@ @DefaultStringValue("Cannot ${action} ${type}. External network details (except name and description) cannot be changed.") String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_DETAILS_CANNOT_BE_EDITED(); + @DefaultStringValue("Cannot ${action} ${type}. External networks are not supported for this cluster's compatibility version.") + String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED(); + @DefaultStringValue("Cannot ${action} ${type}. External network cannot be used as a display network.") String ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY(); 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 caef826..573b013 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 @@ -485,6 +485,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_ALREADY_EXISTS=Cannot ${action} ${type}. The external network already exists as '${NetworkName}' in the data center. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_MUST_BE_VM_NETWORK=Cannot ${action} ${type}. An external network cannot be a non-VM network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_DETAILS_CANNOT_BE_EDITED=Cannot ${action} ${type}. External network details (except name and description) cannot be changed. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED=Cannot ${action} ${type}. External networks are not supported for this cluster's compatibility version. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. 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 b4d3ba3..2bfd719 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 @@ -502,6 +502,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_ALREADY_EXISTS=Cannot ${action} ${type}. The external network already exists as '${NetworkName}' in the data center. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_MUST_BE_VM_NETWORK=Cannot ${action} ${type}. An external network cannot be a non-VM network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_DETAILS_CANNOT_BE_EDITED=Cannot ${action} ${type}. External network details (except name and description) cannot be changed. +ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED=Cannot ${action} ${type}. External networks are not supported for this cluster's compatibility version. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY=Cannot ${action} ${type}. External network cannot be used as a display network. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} ${type}. External network cannot be set as required in the cluster. ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED=Cannot ${action} ${type}. External network cannot be used when port mirroring is set. -- To view, visit http://gerrit.ovirt.org/17385 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4391fdf62419c9f54f134eaba7a337f4ca0725c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Mike Kolesnik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
