Oved Ourfali has uploaded a new change for review.

Change subject: rest: setting permissions on new created VM in user level api 
(#869699)
......................................................................

rest: setting permissions on new created VM in user level api (#869699)

https://bugzilla.redhat.com/show_bug.cgi?id=869699

When creating a VM in the user-level API, the creator should be set as
the owner of it.

Change-Id: Ia9734547ab6a6a91c64982f854b4713cd7bfdab9
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/06/8806/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
index 056b185..286ef70 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
@@ -120,6 +120,11 @@
         return removeRestrictedInfoFromResponse(response);
     }
 
+    private boolean shouldMakeCreatorExplicitOwner() {
+        // In the user level API we should make the creator the owner of the 
new created machine
+        return isFiltered();
+    }
+
     private boolean isCreateFromSnapshot(VM vm) {
         return vm.isSetSnapshots() && vm.getSnapshots().getSnapshots() != null
                 && !vm.getSnapshots().getSnapshots().isEmpty();
@@ -213,6 +218,7 @@
         AddVmFromSnapshotParameters params =
                 new AddVmFromSnapshotParameters(staticVm, sourceSnapshotId);
         params.setDiskInfoDestinationMap(images);
+        params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
         return performCreation(VdcActionType.AddVmFromSnapshot,
                                 params,
                                 new QueryIdResolver(VdcQueryType.GetVmByVmId, 
GetVmByVmIdParameters.class));
@@ -224,6 +230,7 @@
         if (vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetBallooning()) {
             params.setBalloonEnabled(vm.getMemoryPolicy().isBallooning());
         }
+        params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
         return performCreation(VdcActionType.AddVmFromTemplate,
                                params,
                                new QueryIdResolver(VdcQueryType.GetVmByVmId, 
GetVmByVmIdParameters.class));
@@ -270,6 +277,7 @@
         }
         params.setStorageDomainId(storageDomainId);
         params.setDiskInfoDestinationMap(getDisksToClone(vm.getDisks(), 
templateId));
+        params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
         return performCreation(VdcActionType.AddVm,
                                params,
                                new QueryIdResolver(VdcQueryType.GetVmByVmId, 
GetVmByVmIdParameters.class));
@@ -281,6 +289,7 @@
         if (vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetBallooning()) {
             params.setBalloonEnabled(vm.getMemoryPolicy().isBallooning());
         }
+        params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
         params.setStorageDomainId(storageDomainId);
         return performCreation(VdcActionType.AddVmFromScratch,
                                params,


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

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

Reply via email to