Tomas Jelinek has uploaded a new change for review. Change subject: restapi: clone vm ......................................................................
restapi: clone vm REST API part of the clone VM: - added new action: 'clone_vm' - contains a parameter 'clone_configuration' where the type is VM - only the 'name' is used from this VM, but used the VM for simple extensebility in the future Change-Id: I18cb01dc83f0a57a7a572fa0da0c7e3397c43707 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1058832 Signed-off-by: Tomas Jelinek <tjeli...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmResource.java M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd 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 4 files changed, 41 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/26526/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmResource.java index 9493851..8ebe00b 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmResource.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmResource.java @@ -34,7 +34,7 @@ @Produces({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) public interface VmResource extends UpdatableResource<VM>, AsynchronouslyCreatedResource, MeasurableResource { - @Path("{action: (start|stop|shutdown|reboot|suspend|detach|migrate|export|move|ticket|cancelmigration|preview_snapshot|commit_snapshot|undo_snapshot)}/{oid}") + @Path("{action: (start|stop|shutdown|reboot|suspend|detach|migrate|export|move|ticket|cancelmigration|preview_snapshot|commit_snapshot|undo_snapshot|clone_vm)}/{oid}") public ActionResource getActionSubresource(@PathParam("action")String action, @PathParam("oid")String oid); @POST @@ -131,6 +131,13 @@ @POST @Formatted + @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) + @Actionable + @Path("clone_vm") + public Response cloneVm(Action action); + + @POST + @Formatted @Consumes({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML }) @Actionable @Path("cancelmigration") diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index 87ab2b2..96f775c 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -203,6 +203,8 @@ <xs:element name="job" type="Job" minOccurs="0"/> <!-- indicates whether to import the image as template or not --> <xs:element name="import_as_template" type="xs:boolean" minOccurs="0" maxOccurs="1"/> + <!--for clone vm--> + <xs:element name="clone_configuration" type="VM" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:group> 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 705bbb2..f50db39 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 @@ -402,6 +402,16 @@ headers: Content-Type: {value: application/xml|json, required: true} Correlation-Id: {value: 'any string', required: false} +- name: /api/vms/{vm:id}/clone_vm|rel=clone_vm + request: + body: + parameterType: Action + signatures: + - mandatoryArguments: {action.clone_configuration.name} + urlparams: {} + headers: + Content-Type: {value: application/xml|json, required: true} + Correlation-Id: {value: 'any string', required: false} - name: /vms/{vm:id}/detach|rel=detach description: detach a virtual machine in the system identified by the given id from the storage domain request: 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 8744e70..b02e64f 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 @@ -44,6 +44,7 @@ import org.ovirt.engine.api.utils.LinkHelper; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.ChangeVMClusterParameters; +import org.ovirt.engine.core.common.action.CloneVmParameters; import org.ovirt.engine.core.common.action.MigrateVmParameters; import org.ovirt.engine.core.common.action.MigrateVmToServerParameters; import org.ovirt.engine.core.common.action.MoveVmParameters; @@ -146,8 +147,8 @@ return vm.getCluster().isSetId() ? asGuid(vm.getCluster().getId()) : getEntity(VDSGroup.class, - SearchType.Cluster, - "Cluster: name=" + vm.getCluster().getName()).getId(); + SearchType.Cluster, + "Cluster: name=" + vm.getCluster().getName()).getId(); } @Override @@ -258,6 +259,24 @@ } @Override + public Response cloneVm(Action action) { + org.ovirt.engine.core.common.businessentities.VM vm = getEntity(org.ovirt.engine.core.common.businessentities.VM.class, VdcQueryType.GetVmByVmId, new IdQueryParameters(guid), "GetVmByVmId"); + // in case not set let the server to handle it in canDoAction + String newName = ""; + if (action.isSetCloneConfiguration() && action.getCloneConfiguration().isSetName()) { + newName = action.getCloneConfiguration().getName(); + } + + CloneVmParameters cloneVmParameters = new CloneVmParameters(vm, newName); + cloneVmParameters.setMakeCreatorExplicitOwner(isFiltered()); + Response response = doAction(VdcActionType.CloneVm, + cloneVmParameters, + action); + + return response; + } + + @Override public Response commitSnapshot(Action action) { RestoreAllSnapshotsParameters restoreParams = new RestoreAllSnapshotsParameters(guid, SnapshotActionEnum.COMMIT); Response response = doAction(VdcActionType.RestoreAllSnapshots, -- To view, visit http://gerrit.ovirt.org/26526 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I18cb01dc83f0a57a7a572fa0da0c7e3397c43707 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