server: fix checking disk offering access for snapshot volume (#3791)

Fixes #3783
As reported in the issue, creating volumes from pure snapshot fails with NPE. This is due to order of calls where disk offering access is checked before checking disk offering value. This PR fixes the same.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2020-01-31 15:24:26 +05:30 committed by GitHub
parent 75aa6e3659
commit a71874682c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -673,8 +673,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
zoneId = snapshotCheck.getDataCenterId();
}
_configMgr.checkDiskOfferingAccess(null, diskOffering, _dcDao.findById(zoneId));
if (diskOffering == null) { // Pure snapshot is being used to create volume.
diskOfferingId = snapshotCheck.getDiskOfferingId();
diskOffering = _diskOfferingDao.findById(diskOfferingId);
@ -689,6 +687,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
}
}
_configMgr.checkDiskOfferingAccess(null, diskOffering, _dcDao.findById(zoneId));
// check snapshot permissions
_accountMgr.checkAccess(caller, null, true, snapshotCheck);