Arik Hadas has uploaded a new change for review.

Change subject: core, restapi: move destinationVdsId from to RunVmOnceParams
......................................................................

core, restapi: move destinationVdsId from to RunVmOnceParams

It should be possible to set destination VDS only when running VM in run
once mode, but nevertheless this property resided in RunVmParams instead
of RunVmOnceParams. Thus, it is being moved.

Change-Id: Id6bb75da2c2030f71da26c8690a6931319f6904f
Signed-off-by: Arik Hadas <aha...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java
3 files changed, 37 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/24256/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
index 280173d..37314ef 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmOnceParams.java
@@ -11,12 +11,10 @@
     private static final long serialVersionUID = -4968552684343593622L;
 
     private String sysPrepDomainName;
-
     private String sysPrepUserName;
-
     private String sysPrepPassword;
-
     private VmInit vmInit;
+    private Guid destinationVdsId;
 
     @NullOrStringContainedInConfigValueList(configValue = 
ConfigValues.VncKeyboardLayoutValidValues,
             groups = { StartEntity.class }, message = 
"VALIDATION.VM.INVALID_KEYBOARD_LAYOUT")
@@ -73,4 +71,11 @@
         this.vncKeyboardLayout = vncKeyboardLayout;
     }
 
+    public Guid getDestinationVdsId() {
+        return destinationVdsId;
+    }
+
+    public void setDestinationVdsId(Guid destinationVdsId) {
+        this.destinationVdsId = destinationVdsId;
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
index 047b6b6..8d53a1f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java
@@ -20,7 +20,6 @@
     private String privateFloppyPath;
     private String privateClientIp;
     private DbUser requestingUser;
-    private Guid _destinationVdsId;
     private InitializationType privateInitializationType;
     private Boolean privateRunAsStateless;
     private String initrd_url;
@@ -62,14 +61,6 @@
 
     public RunVmParams(Guid vmId, boolean isInternal) {
         this(vmId);
-    }
-
-    public Guid getDestinationVdsId() {
-        return _destinationVdsId;
-    }
-
-    public void setDestinationVdsId(Guid value) {
-        _destinationVdsId = value;
     }
 
     public BootSequence getBootSequence() {
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 3a24d08..c3b1d4d 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
@@ -252,29 +252,7 @@
             VM vm = action.getVm();
             validateEnums(VM.class, vm);
             actionType = VdcActionType.RunVmOnce;
-            params = map(vm, map(map(getEntity(entityType, 
VdcQueryType.GetVmByVmId, new IdQueryParameters(guid), id, true), new VM()),
-                                 new RunVmOnceParams(guid)));
-            if (vm.isSetPlacementPolicy() && 
vm.getPlacementPolicy().isSetHost()) {
-                validateParameters(vm.getPlacementPolicy(), "host.id|name");
-                
params.setDestinationVdsId(getHostId(vm.getPlacementPolicy().getHost()));
-            }
-            if (vm.isSetInitialization() && 
vm.getInitialization().isSetCloudInit()) {
-                CloudInit cloudInit = vm.getInitialization().getCloudInit();
-                // currently only 'root' user is supported, alert the user if 
other user sent
-                if (cloudInit.isSetAuthorizedKeys()) {
-                    for (AuthorizedKey authKey : 
cloudInit.getAuthorizedKeys().getAuthorizedKeys()) {
-                        if (!"root".equals(authKey.getUser().getUserName())) {
-                            throw new 
WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
-.entity("Currently only the user 'root' is supported for authorized keys")
-.build());
-                        }
-                    }
-                }
-                params.setInitializationType(InitializationType.CloudInit);
-                ((RunVmOnceParams) params).setVmInit(
-                        getMapper(CloudInit.class, VmInit.class)
-                                .map(cloudInit, null));
-            }
+            params = createRunVmOnceParams(vm);
         } else {
             actionType = VdcActionType.RunVm;
             params = new RunVmParams(guid);
@@ -285,6 +263,34 @@
         return doAction(actionType, params, action);
     }
 
+    private RunVmOnceParams createRunVmOnceParams(VM vm) {
+        RunVmOnceParams params = map(vm, map(map(getEntity(entityType, 
VdcQueryType.GetVmByVmId, new IdQueryParameters(guid), id, true), new VM()),
+                new RunVmOnceParams(guid)));
+        if (vm.isSetPlacementPolicy() && vm.getPlacementPolicy().isSetHost()) {
+            validateParameters(vm.getPlacementPolicy(), "host.id|name");
+            
params.setDestinationVdsId(getHostId(vm.getPlacementPolicy().getHost()));
+        }
+        if (vm.isSetInitialization() && 
vm.getInitialization().isSetCloudInit()) {
+            CloudInit cloudInit = vm.getInitialization().getCloudInit();
+            // currently only 'root' user is supported, alert the user if 
other user sent
+            if (cloudInit.isSetAuthorizedKeys()) {
+                for (AuthorizedKey authKey : 
cloudInit.getAuthorizedKeys().getAuthorizedKeys()) {
+                    if (!"root".equals(authKey.getUser().getUserName())) {
+                        throw new 
WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
+                                .entity("Currently only the user 'root' is 
supported for authorized keys")
+                                .build());
+                    }
+                }
+            }
+            params.setInitializationType(InitializationType.CloudInit);
+            ((RunVmOnceParams) params).setVmInit(
+                    getMapper(CloudInit.class, VmInit.class)
+                    .map(cloudInit, null));
+        }
+
+        return params;
+    }
+
     @Override
     public Response stop(Action action) {
         return doAction(VdcActionType.StopVm,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6bb75da2c2030f71da26c8690a6931319f6904f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <aha...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to