Vitor de Lima has uploaded a new change for review. Change subject: core, engine, restapi: Proper default migration policies for ppc64 ......................................................................
core, engine, restapi: Proper default migration policies for ppc64 This patch changes the default option when creating clusters and VMs using the REST API. When omitted, the Migrate On Error parameter for new clusters is disabled when the architecture of the cluster does not support migration. Also, if the user does not specify a migration policy for a new VM, the REST API will disable it in architectures that do not support it. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1057178 Change-Id: Ib34c4a01fe0c667bafc47bf70b33bb2990ffb7d3 Signed-off-by: Vitor de Lima <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java 7 files changed, 43 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/25053/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsGroupCommand.java index 6f5e667..49a2ed4 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsGroupCommand.java @@ -29,6 +29,8 @@ public AddVdsGroupCommand(T parameters) { super(parameters); + + updateMigrateOnError(); } @Override diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 5964183..42e44a6 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -162,6 +162,17 @@ diskInfoDestinationMap = new HashMap<Guid, DiskImage>(); } + // Fill the migration policy if it was omitted + if (getParameters().getVmStaticData().getMigrationSupport() == null) { + boolean isMigrationSupported = + FeatureSupported.isMigrationSupported(getVdsGroup().getArchitecture(), + getVdsGroup().getcompatibility_version()); + + MigrationSupport migrationSupport = + isMigrationSupported ? MigrationSupport.MIGRATABLE : MigrationSupport.PINNED_TO_HOST; + + getParameters().getVmStaticData().setMigrationSupport(migrationSupport); + } } protected AddVmCommand(Guid commandId) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java index 6fe0134..050193a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java @@ -45,6 +45,8 @@ public UpdateVdsGroupCommand(T parameters) { super(parameters); + + updateMigrateOnError(); } protected UpdateVdsGroupCommand(Guid commandId) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java index 259f4f7..f45a0c5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java @@ -8,8 +8,10 @@ import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.scheduling.SchedulingManager; +import org.ovirt.engine.core.common.FeatureSupported; import org.ovirt.engine.core.common.action.VdsGroupOperationParameters; import org.ovirt.engine.core.common.businessentities.ArchitectureType; +import org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; @@ -49,6 +51,19 @@ return getVdsGroup().getArchitecture(); } + protected void updateMigrateOnError() { + if (getVdsGroup().getMigrateOnError() == null) { + boolean isMigrationSupported = + FeatureSupported.isMigrationSupported(getArchitecture(), + getVdsGroup().getcompatibility_version()); + + MigrateOnErrorOptions migrateOnError = + isMigrationSupported ? MigrateOnErrorOptions.YES : MigrateOnErrorOptions.NO; + + getVdsGroup().setMigrateOnError(migrateOnError); + } + } + protected void checkMaxMemoryOverCommitValue() { if (getVdsGroup().getmax_vds_memory_over_commit() <= 0) { getVdsGroup().setmax_vds_memory_over_commit( diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java index d04514c..09fe2c3 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java @@ -57,7 +57,6 @@ private boolean transparentHugepages; - @NotNull(message = "VALIDATION.VDS_GROUP.MigrateOnError.NOT_NULL") private MigrateOnErrorOptions migrateOnError; private boolean virtService; diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java index 62e847b..180bbc6 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendClustersResource.java @@ -75,6 +75,11 @@ validateEnums(Cluster.class, cluster); StoragePool pool = getStoragePool(cluster, this); VDSGroup entity = map(cluster, map(pool)); + + if (!cluster.isSetErrorHandling() || !cluster.getErrorHandling().isSetOnError()) { + entity.setMigrateOnError(null); + } + return performCreate(VdcActionType.AddVdsGroup, new VdsGroupOperationParameters(entity), new QueryIdResolver<Guid>(VdcQueryType.GetVdsGroupById, IdQueryParameters.class)); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java index aa36aa0..fe5b9fb 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java @@ -130,6 +130,14 @@ } else { vm.setPlacementPolicy(null); } + + // If the user omits the placement policy in the incoming XML and the selected template + // is the blank one, the AddVmCommand must auto-select a proper default value for the + // migration support (disabling it in architectures that do not support this feature) + if (!vm.isSetPlacementPolicy() && templateId.equals(Guid.Empty)) { + staticVm.setMigrationSupport(null); + } + Guid storageDomainId = (vm.isSetStorageDomain() && vm.getStorageDomain().isSetId()) ? asGuid(vm.getStorageDomain() .getId()) -- To view, visit http://gerrit.ovirt.org/25053 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib34c4a01fe0c667bafc47bf70b33bb2990ffb7d3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Vitor de Lima <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
