Martin Mucha has uploaded a new change for review. Change subject: restapi: rest part of UpdateAndReorderVmNicsCommand ......................................................................
restapi: rest part of UpdateAndReorderVmNicsCommand Change-Id: I633276253651d486b4d890413548bc3317357781 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Martin Mucha <mmu...@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, 72 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/35054/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 32787b5..8670b49 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 @@ -32,10 +32,16 @@ @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|clone|maintenance)}/{oid}") + @Path("{action: (start|stop|shutdown|reboot|suspend|detach|migrate|export|move|ticket|cancelmigration|preview_snapshot|commit_snapshot|undo_snapshot|clone|maintenance|manipulate_nics)}/{oid}") public ActionResource getActionSubresource(@PathParam("action")String action, @PathParam("oid")String oid); @POST + @Consumes({ ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML }) + @Actionable + @Path("update_and_reorder_nics") + public Response manipulateNics(Action action); + + @POST @Consumes({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON, ApiMediaType.APPLICATION_X_YAML}) @Actionable @Path("start") 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 10b7170..00cbf9b 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 @@ -226,6 +226,23 @@ <!-- Represents a potentially asynchronous operation --> + <xs:element name="updateAndReorderVmNicsParameters" type="UpdateAndReorderVmNicsParameters"/> + + + <xs:complexType name="UpdateAndReorderVmNicsParameters"> + <xs:complexContent> + <xs:extension base="BaseResource"> + <xs:sequence> + <xs:element name="osType" type="xs:positiveInteger"/> + <xs:element name="version" type="xs:string"/> + <xs:element name="vmId" type="xs:string"/> + <xs:element name="reorderNics" type="xs:boolean" minOccurs="1"/> + <xs:element ref="nics"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <xs:element name="action" type="Action"/> <xs:complexType name="Action"> @@ -250,6 +267,8 @@ <xs:group ref="ActionResponseGroup"/> <!-- also link to original action (rel="replay") and parent resource (rel="parent") --> + + <xs:element ref="updateAndReorderVmNicsParameters" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:extension> </xs:complexContent> 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 13f8dbe..45f3ee0 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 @@ -359,6 +359,16 @@ headers: Content-Type: {value: application/xml|json, required: true} Correlation-Id: {value: 'any string', required: false} +- name: /vms/{vm:id}/update_and_reorder_nics|rel=update_and_reorder_nics + description: updates and reorder nics. + request: + body: + parameterType: Action + signatures: [] + urlparams: {} + headers: + Content-Type: {value: application/xml|json, required: true} + Correlation-Id: {value: 'any string', required: false} - name: /vms/{vm:id}/start|rel=start description: start a virtual machine in the system identified by the given id 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 e8c58f3..871b4f6 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 @@ -3,6 +3,7 @@ import static org.ovirt.engine.api.restapi.resource.BackendVmsResource.SUB_COLLECTIONS; import static org.ovirt.engine.core.utils.Ticketing.generateOTP; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -22,6 +23,7 @@ import org.ovirt.engine.api.model.CloudInit; import org.ovirt.engine.api.model.CreationStatus; import org.ovirt.engine.api.model.Display; +import org.ovirt.engine.api.model.NIC; import org.ovirt.engine.api.model.Statistic; import org.ovirt.engine.api.model.Statistics; import org.ovirt.engine.api.model.Template; @@ -43,6 +45,7 @@ import org.ovirt.engine.api.resource.VmSessionsResource; import org.ovirt.engine.api.resource.WatchdogsResource; import org.ovirt.engine.api.restapi.logging.Messages; +import org.ovirt.engine.api.restapi.types.Mapper; import org.ovirt.engine.api.restapi.types.RngDeviceMapper; import org.ovirt.engine.api.restapi.types.VmMapper; import org.ovirt.engine.api.utils.LinkHelper; @@ -62,6 +65,7 @@ import org.ovirt.engine.core.common.action.StopVmParameters; import org.ovirt.engine.core.common.action.StopVmTypeEnum; import org.ovirt.engine.core.common.action.TryBackToAllSnapshotsOfVmParameters; +import org.ovirt.engine.core.common.action.UpdateAndReorderVmNicsParam; import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VmManagementParametersBase; @@ -74,6 +78,7 @@ import org.ovirt.engine.core.common.businessentities.VmInit; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmTemplate; +import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters; import org.ovirt.engine.core.common.queries.GetVmTemplateParameters; import org.ovirt.engine.core.common.queries.IdQueryParameters; @@ -81,6 +86,7 @@ import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.Version; public class BackendVmResource extends AbstractBackendActionableResource<VM, org.ovirt.engine.core.common.businessentities.VM> implements @@ -180,8 +186,8 @@ @Override public DevicesResource<CdRom, CdRoms> getCdRomsResource() { return inject(new BackendCdRomsResource(guid, - VdcQueryType.GetVmByVmId, - new IdQueryParameters(guid))); + VdcQueryType.GetVmByVmId, + new IdQueryParameters(guid))); } @Override @@ -338,6 +344,34 @@ } @Override + public Response manipulateNics(Action action) { + org.ovirt.engine.api.model.UpdateAndReorderVmNicsParameters updateAndReorderVmNicsParameters + = action.getUpdateAndReorderVmNicsParameters(); + + UpdateAndReorderVmNicsParam commandParameters = new UpdateAndReorderVmNicsParam(); + commandParameters.vmId = Guid.createGuidFromString(updateAndReorderVmNicsParameters.getVmId()); + commandParameters.version = new Version(updateAndReorderVmNicsParameters.getVersion()); + commandParameters.osType = updateAndReorderVmNicsParameters.getOsType().intValue(); + commandParameters.updatedVmNetworkInterfaces = mapAllNics(updateAndReorderVmNicsParameters.getNics().getNics()); + commandParameters.reorderNics = Boolean.TRUE.equals(updateAndReorderVmNicsParameters.isReorderNics()); + + return doAction(VdcActionType.UpdateAndReorderVmNics, + commandParameters, + action); + } + + private List<VmNetworkInterface> mapAllNics(List<NIC> nics) { + Mapper<NIC, VmNetworkInterface> mapper = getMapper(NIC.class, VmNetworkInterface.class); + List<VmNetworkInterface> result = new ArrayList<>(nics.size()); + + for (NIC nic : nics) { + result.add(mapper.map(nic, null)); + } + + return result; + } + + @Override public Response start(Action action) { RunVmParams params; VdcActionType actionType; -- To view, visit http://gerrit.ovirt.org/35054 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I633276253651d486b4d890413548bc3317357781 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Mucha <mmu...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches