Alona Kaplan has uploaded a new change for review.

Change subject: restapi: Activate/Deactivate vnic should use edit
......................................................................

restapi: Activate/Deactivate vnic should use edit

As part of the Network Linking feature-
backend ActivateDeactivateVmNicCommand should become internal.
Plugging/Unplugging the nic will be done through the edit.

In order to keep backward compatibility in the rest, we keep the activate/
deactivate actions and deprecate them.
Their implementation is changed to use "edit" instead of
"ActivateDeactivateVmNicCommand"

Change-Id: Id6ac3ff0bf6c49aaea8dc589ca5da6495feb2d5b
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmNicResource.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmNicResource.java
2 files changed, 15 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/58/10358/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmNicResource.java
 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmNicResource.java
index dd2bfac..da559b8 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmNicResource.java
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/VmNicResource.java
@@ -14,12 +14,15 @@
 import org.ovirt.engine.api.model.Actionable;
 import org.ovirt.engine.api.model.NIC;
 
+
 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, 
MediaType.APPLICATION_X_YAML })
 public interface VmNicResource extends NicResource {
 
     @Path("{action: (activate|deactivate)}/{oid}")
     public ActionResource getActionSubresource(@PathParam("action") String 
action, @PathParam("oid") String oid);
 
+    // TODO remove on 4.1
+    @Deprecated
     @POST
     @Formatted
     @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, 
MediaType.APPLICATION_X_YAML })
@@ -27,6 +30,8 @@
     @Path("activate")
     public Response activate(Action action);
 
+    // TODO remove on 4.1
+    @Deprecated
     @POST
     @Formatted
     @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, 
MediaType.APPLICATION_X_YAML })
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmNicResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmNicResource.java
index 3e90e96..4671a7d 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmNicResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmNicResource.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.api.restapi.resource;
 
+import java.net.URI;
+
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 
@@ -12,8 +14,6 @@
 import org.ovirt.engine.api.model.PortMirroring;
 import org.ovirt.engine.api.resource.ActionResource;
 import org.ovirt.engine.api.resource.VmNicResource;
-import org.ovirt.engine.core.common.action.ActivateDeactivateVmNicParameters;
-import org.ovirt.engine.core.common.action.PlugAction;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.VmNetworkInterface;
 import org.ovirt.engine.core.compat.Guid;
@@ -168,17 +168,18 @@
 
     @Override
     public Response activate(Action action) {
-        ActivateDeactivateVmNicParameters params = new 
ActivateDeactivateVmNicParameters(guid, PlugAction.PLUG);
-        BackendNicsResource parent = (BackendNicsResource) collection;
-        params.setVmId(parent.parentId);
-        return doAction(VdcActionType.ActivateDeactivateVmNic, params, action);
+        NIC nic = get();
+        nic.setPlugged(true);
+        NIC updatedNic = update(nic);
+        return 
Response.created(URI.create(updatedNic.getHref())).entity(updatedNic).build();
     }
 
     @Override
     public Response deactivate(Action action) {
-        ActivateDeactivateVmNicParameters params = new 
ActivateDeactivateVmNicParameters(guid, PlugAction.UNPLUG);
-        params.setVmId(((BackendNicsResource) collection).parentId);
-        return doAction(VdcActionType.ActivateDeactivateVmNic, params, action);
+        NIC nic = get();
+        nic.setPlugged(false);
+        NIC updatedNic = update(nic);
+        return 
Response.created(URI.create(updatedNic.getHref())).entity(updatedNic).build();
     }
 
     @Override


--
To view, visit http://gerrit.ovirt.org/10358
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6ac3ff0bf6c49aaea8dc589ca5da6495feb2d5b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alona Kaplan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to