Yevgeny Zaspitsky has uploaded a new change for review. Change subject: engine: add management net validation on host move to another cluster ......................................................................
engine: add management net validation on host move to another cluster Add management network validation on host move to another cluster. The operatin is banned if management network name in the target cluster is differs from the source one. Change-Id: I7ef330309ccc90142c8734454ddcf6f2f3587abc Signed-off-by: Yevgeny Zaspitsky <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.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, 34 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/39183/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java index 51666a4..b1acca5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ChangeVDSClusterCommand.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; +import javax.inject.Inject; + import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.bll.network.NetworkParametersBuilder; @@ -45,6 +47,7 @@ import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; import org.ovirt.engine.core.dao.gluster.GlusterDBUtils; +import org.ovirt.engine.core.dao.network.NetworkDao; import org.ovirt.engine.core.utils.NetworkUtils; import org.ovirt.engine.core.utils.ObjectIdentityChecker; import org.ovirt.engine.core.utils.lock.EngineLock; @@ -54,6 +57,9 @@ @NonTransactiveCommandAttribute(forceCompensation = true) public class ChangeVDSClusterCommand<T extends ChangeVDSClusterParameters> extends VdsCommand<T> { + + @Inject + private NetworkDao networkDao; private StoragePool targetStoragePool; @@ -131,6 +137,10 @@ } } + if (!isDetachedSourceCluster() && !isSameManagementNetwork()) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_CHANGED); + } + if (FeatureSupported.hostNetworkQos(getSourceCluster().getCompatibilityVersion()) && !FeatureSupported.hostNetworkQos(getTargetCluster().getCompatibilityVersion())) { for (VdsNetworkInterface iface : getHostNics()) { @@ -158,6 +168,18 @@ } return true; + } + + private boolean isDetachedSourceCluster() { + return getSourceCluster().getStoragePoolId() == null; + } + + private boolean isSameManagementNetwork() { + final Network sourceManagementNetwork = getNetworkDao().getManagementNetwork(getSourceCluster().getId()); + final Network targetManagementNetwork = getNetworkDao().getManagementNetwork(getTargetCluster().getId()); + + return targetManagementNetwork != null + && sourceManagementNetwork.getName().equals(targetManagementNetwork.getName()); } private boolean hostHasLabeledNics() { @@ -400,6 +422,10 @@ return targetCluster; } + private NetworkDao getNetworkDao() { + return networkDao; + } + private class ChangeClusterParametersBuilder extends NetworkParametersBuilder { public ChangeClusterParametersBuilder(CommandContext commandContext) { @@ -407,7 +433,7 @@ } public PersistentSetupNetworksParameters buildParameters(Guid hostId, Guid sourceClusterId, Guid targetClusterId) { - List<Network> targetClusterNetworks = getNetworkDAO().getAllForCluster(targetClusterId); + List<Network> targetClusterNetworks = getNetworkDao().getAllForCluster(targetClusterId); Map<String, Network> targetClusterNetworksByName = Entities.entitiesByName(targetClusterNetworks); PersistentSetupNetworksParameters params = createSetupNetworksParameters(hostId); @@ -415,7 +441,7 @@ Entities.hostInterfacesByNetworkName(params.getInterfaces()); Map<String, List<Network>> targetNetworksByLabel = getClusterNetworksByLabel(targetClusterNetworks); Map<String, List<Network>> sourceNetworksByLabel = - getClusterNetworksByLabel(getNetworkDAO().getAllForCluster(sourceClusterId)); + getClusterNetworksByLabel(getNetworkDao().getAllForCluster(sourceClusterId)); List<VdsNetworkInterface> hostNics = new ArrayList<>(params.getInterfaces()); // Detect which networks should be added and which should be removed 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 65f70b2..33388d4 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 @@ -519,6 +519,7 @@ ACTION_TYPE_FAILED_NETWORK_FROM_DIFFERENT_DC(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_DEFAULT_MANAGEMENT_NETWORK_NOT_FOUND(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_CHANGED(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_TARGET_CLUSTER_WITH_DIFF_MANAGEMENT_NETWORK(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_EXTERNAL(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT(ErrorType.BAD_PARAMETERS), NETWORK_NOT_EXISTS(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 80a75a1..e8bc9ee 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -619,6 +619,7 @@ ACTION_TYPE_FAILED_NETWORK_FROM_DIFFERENT_DC=Cannot ${action} ${type}. Network belongs to a different data-center. ACTION_TYPE_FAILED_DEFAULT_MANAGEMENT_NETWORK_NOT_FOUND=Cannot ${action} ${type}. Default management network is not found or is ambiguous. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_CHANGED=Cannot ${action} ${type}. Changing management network in a non-empty cluster is not allowed. +ACTION_TYPE_FAILED_TARGET_CLUSTER_WITH_DIFF_MANAGEMENT_NETWORK=Cannot ${action} ${type}. Moving a host to cluster with different management network is not allowed. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_EXTERNAL=Cannot ${action} ${type}. Management network has to be not external one. ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT=Cannot ${action} ${type}. Network cluster ${NetworkCluster} appears more then once. ACTION_TYPE_FAILED_MIGRATION_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Migration network is not supported for this cluster version. 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 58a9e8a..0d0d329 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 @@ -1702,6 +1702,9 @@ @DefaultStringValue("Cannot ${action} ${type}. Changing management network in a non-empty cluster is not allowed.") String ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_CHANGED(); + @DefaultStringValue("Cannot ${action} ${type}. Moving a host to cluster with different management network is not allowed.") + String ACTION_TYPE_FAILED_TARGET_CLUSTER_WITH_DIFF_MANAGEMENT_NETWORK(); + @DefaultStringValue("Cannot ${action} ${type}. Management network has to be not external one.") String ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_EXTERNAL(); 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 c8925a2..9a5175d 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 @@ -623,6 +623,7 @@ ACTION_TYPE_FAILED_NETWORK_FROM_DIFFERENT_DC=Cannot ${action} ${type}. Network belongs to a different data-center. ACTION_TYPE_FAILED_DEFAULT_MANAGEMENT_NETWORK_NOT_FOUND=Cannot ${action} ${type}. Default management network is not found or is ambiguous. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_CHANGED=Cannot ${action} ${type}. Changing management network in a non-empty cluster is not allowed. +ACTION_TYPE_FAILED_TARGET_CLUSTER_WITH_DIFF_MANAGEMENT_NETWORK=Cannot ${action} ${type}. Moving a host to cluster with different management network is not allowed. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_CANNOT_BE_EXTERNAL=Cannot ${action} ${type}. Management network has to be not external one. ACTION_TYPE_FAILED_DUPLICATE_NETWORK_CLUSTER_INPUT=Cannot ${action} ${type}. Network cluster ${NetworkCluster} appears more then once. ACTION_TYPE_FAILED_MIGRATION_NETWORK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Migration network is not supported for this cluster version. -- To view, visit https://gerrit.ovirt.org/39183 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7ef330309ccc90142c8734454ddcf6f2f3587abc Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yevgeny Zaspitsky <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
