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. Change-Id: Ib34c4a01fe0c667bafc47bf70b33bb2990ffb7d3 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1057178 Signed-off-by: Vitor de Lima <vdel...@redhat.com> --- 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, 50 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/18/34618/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 35868ef..327a71c 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 @@ -32,6 +32,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 2ff1986..710820c 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 @@ -182,6 +182,11 @@ } VmHandler.updateDefaultTimeZone(parameters.getVmStaticData()); + // Fill the migration policy if it was omitted + if (getParameters().getVmStaticData() != null && + getParameters().getVmStaticData().getMigrationSupport() == null) { + setDefaultMigrationPolicy(); + } } @Override @@ -312,6 +317,19 @@ .getImageId().equals(VmTemplateHandler.BLANK_VM_TEMPLATE_ID); } + protected void setDefaultMigrationPolicy() { + if (getVdsGroup() != null) { + boolean isMigrationSupported = + FeatureSupported.isMigrationSupported(getVdsGroup().getArchitecture(), + getVdsGroup().getcompatibility_version()); + + MigrationSupport migrationSupport = + isMigrationSupported ? MigrationSupport.MIGRATABLE : MigrationSupport.PINNED_TO_HOST; + + getParameters().getVmStaticData().setMigrationSupport(migrationSupport); + } + } + protected Guid getStoragePoolIdFromSourceImageContainer() { return vmDisksSource.getStoragePoolId(); } 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 fde0389..8313f41 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 @@ -50,6 +50,8 @@ public UpdateVdsGroupCommand(T parameters) { this(parameters, null); + + updateMigrateOnError(); } public UpdateVdsGroupCommand(T parameters, CommandContext commandContext) { 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 c117b73..6d4ae0f 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 @@ -10,8 +10,10 @@ import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.bll.scheduling.SchedulingManager; import org.ovirt.engine.core.common.AuditLogType; +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; @@ -57,6 +59,19 @@ return getVdsGroup().getArchitecture(); } + protected void updateMigrateOnError() { + if (getVdsGroup() != null && 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 009faf6..2a66cdc 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 @@ -62,7 +62,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 3e5950c..187ead3 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 @@ -76,6 +76,11 @@ validateEnums(Cluster.class, cluster); StoragePool pool = getStoragePool(cluster.getDataCenter(), 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 45625e4..87cb57a 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 @@ -139,6 +139,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/34618 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.5 Gerrit-Owner: Vitor de Lima <vdel...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches