Liron Aravot has posted comments on this change.

Change subject: restapi: Allow override of allocation policy of imported disks
......................................................................


Patch Set 2: Code-Review-1

(6 comments)

http://gerrit.ovirt.org/#/c/36131/2/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java
File 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainVmResource.java:

Line 80:             
params.setCopyCollapse(action.getVm().getSnapshots().isCollapseSnapshots());
Line 81:         }
Line 82: 
Line 83:         // The caller may override the format and allocation policy 
for each disk of the virtual machine:
Line 84:         if (action.isSetVm()) {
i suggest to export this whole part to a separate method to ease the read of 
this method (now it's really long)
Line 85:             VM modelVm = action.getVm();
Line 86:             if (modelVm.isSetDisks()) {
Line 87:                 Map<Guid, 
org.ovirt.engine.core.common.businessentities.Disk> entityDisks = getDiskMap();
Line 88:                 for (Disk modelDisk : modelVm.getDisks().getDisks()) {


Line 82: 
Line 83:         // The caller may override the format and allocation policy 
for each disk of the virtual machine:
Line 84:         if (action.isSetVm()) {
Line 85:             VM modelVm = action.getVm();
Line 86:             if (modelVm.isSetDisks()) {
when it's moved to a different method, we can also remove the indentation..to 
ease the read

if (!model.isSetDisks()) {

return;

}
Line 87:                 Map<Guid, 
org.ovirt.engine.core.common.businessentities.Disk> entityDisks = getDiskMap();
Line 88:                 for (Disk modelDisk : modelVm.getDisks().getDisks()) {
Line 89:                     if (modelDisk.isSetId()) {
Line 90:                         Guid modelDiskId = 
Guid.createGuidFromString(modelDisk.getId());


Line 84:         if (action.isSetVm()) {
Line 85:             VM modelVm = action.getVm();
Line 86:             if (modelVm.isSetDisks()) {
Line 87:                 Map<Guid, 
org.ovirt.engine.core.common.businessentities.Disk> entityDisks = getDiskMap();
Line 88:                 for (Disk modelDisk : modelVm.getDisks().getDisks()) {
don't we need to check that modelVm.getDisks().getDisks() is set?
Line 89:                     if (modelDisk.isSetId()) {
Line 90:                         Guid modelDiskId = 
Guid.createGuidFromString(modelDisk.getId());
Line 91:                         DiskImage entityDisk = (DiskImage) 
entityDisks.get(modelDiskId);
Line 92:                         if (entityDisk != null) {


Line 85:             VM modelVm = action.getVm();
Line 86:             if (modelVm.isSetDisks()) {
Line 87:                 Map<Guid, 
org.ovirt.engine.core.common.businessentities.Disk> entityDisks = getDiskMap();
Line 88:                 for (Disk modelDisk : modelVm.getDisks().getDisks()) {
Line 89:                     if (modelDisk.isSetId()) {
don't we need to validate those things and show an appropriate error if not 
present rather then ignore?
Line 90:                         Guid modelDiskId = 
Guid.createGuidFromString(modelDisk.getId());
Line 91:                         DiskImage entityDisk = (DiskImage) 
entityDisks.get(modelDiskId);
Line 92:                         if (entityDisk != null) {
Line 93:                             if (modelDisk.isSetFormat()) {


Line 88:                 for (Disk modelDisk : modelVm.getDisks().getDisks()) {
Line 89:                     if (modelDisk.isSetId()) {
Line 90:                         Guid modelDiskId = 
Guid.createGuidFromString(modelDisk.getId());
Line 91:                         DiskImage entityDisk = (DiskImage) 
entityDisks.get(modelDiskId);
Line 92:                         if (entityDisk != null) {
general to this whole block - I'd replace the ifs on this method with negative 
if's and "continue" statements..to reduce the indentation and ease the read, 
that's matter of preference..so it's up to you :)
Line 93:                             if (modelDisk.isSetFormat()) {
Line 94:                                 DiskFormat modelDiskFormat = 
DiskFormat.fromValue(modelDisk.getFormat());
Line 95:                                 VolumeFormat entityDiskFormat = 
DiskMapper.map(modelDiskFormat, null);
Line 96:                                 
entityDisk.setvolumeFormat(entityDiskFormat);


Line 95:                                 VolumeFormat entityDiskFormat = 
DiskMapper.map(modelDiskFormat, null);
Line 96:                                 
entityDisk.setvolumeFormat(entityDiskFormat);
Line 97:                             }
Line 98:                             if (modelDisk.isSetSparse()) {
Line 99:                                 VolumeType entityDiskType = 
modelDisk.isSparse()? VolumeType.Sparse: VolumeType.Preallocated;
this line should be in a method added to the mapper imo (same as the format)
Line 100:                                 
entityDisk.setVolumeType(entityDiskType);
Line 101:                             }
Line 102:                         }
Line 103:                     }


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Idc9945968b7cd2b8a82d953f659967d72064d583
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Liron Aravot <lara...@redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to