Tomas Jelinek has uploaded a new change for review. Change subject: restapi: added support for optionally select the target cluster ......................................................................
restapi: added support for optionally select the target cluster An optional parameter cluste.id has been added to the migrate. Change-Id: I66aa4041b5308fe4f7f1038f53715cd78c5c279f Bug-Url: https://bugzilla.redhat.com/1150191 Signed-off-by: Tomas Jelinek <tjeli...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java 3 files changed, 28 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/34348/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index 76198c1..4835a1a 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -482,7 +482,7 @@ signatures: - mandatoryArguments: {} optionalArguments: {action.host.id|name: 'xs:string', action.async: 'xs:boolean', - action.force: 'xs:boolean', action.grace_period.expiry: 'xs:long'} + action.force: 'xs:boolean', action.grace_period.expiry: 'xs:long', action.cluster.id: 'xs:string'} description: migrate a virtual machine in the system identified by the given id to another host with options specified in the request body urlparams: {} headers: diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java index d90abef..e8c58f3 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java @@ -248,17 +248,27 @@ @Override public Response migrate(Action action) { boolean forceMigration = action.isSetForce() ? action.isForce() : false; + if (!action.isSetHost()) { return doAction(VdcActionType.MigrateVm, - new MigrateVmParameters(forceMigration, guid), + new MigrateVmParameters(forceMigration, guid, getTargetClusterId(action)), action); } else { return doAction(VdcActionType.MigrateVmToServer, - new MigrateVmToServerParameters(forceMigration, guid, getHostId(action)), + new MigrateVmToServerParameters(forceMigration, guid, getHostId(action), getTargetClusterId(action)), action); } } + private Guid getTargetClusterId(Action action) { + if (action.isSetCluster() && action.getCluster().isSetId()) { + return asGuid(action.getCluster().getId()); + } + + // means use the cluster of the provided host + return null; + } + @Override public Response shutdown(Action action) { // REVISIT add waitBeforeShutdown Action paramater diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java index 7a1d489..4ece6d8 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java @@ -797,6 +797,21 @@ } @Test + public void testMigrateWithClusterId() throws Exception { + setUriInfo(setUpActionExpectations(VdcActionType.MigrateVm, + MigrateVmParameters.class, + new String[] { "VmId", "ForceMigrationForNonMigratableVm", "TargetVdsGroupId"}, + new Object[] { GUIDS[0], Boolean.FALSE, GUIDS[1]})); + + Action action = new Action(); + Cluster cluster = new Cluster(); + cluster.setId(GUIDS[1].toString()); + action.setCluster(cluster); + + verifyActionResponse(resource.migrate(action)); + } + + @Test public void testExport() throws Exception { testExportWithStorageDomainId(false, false); } -- To view, visit http://gerrit.ovirt.org/34348 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I66aa4041b5308fe4f7f1038f53715cd78c5c279f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches