mirror of https://github.com/apache/cloudstack.git
Bug 13999 - Non-admin user should not be able to take snapshots
Changes: If Zone is disabled, deny permission to regular user while creating snapshots
This commit is contained in:
parent
989e88e03f
commit
4cd55d4dfc
|
|
@ -51,6 +51,7 @@ import com.cloud.configuration.Config;
|
|||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
|
|
@ -68,6 +69,7 @@ import com.cloud.exception.StorageUnavailableException;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.projects.ProjectManager;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
|
|
@ -1278,10 +1280,20 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
|||
@Override
|
||||
public SnapshotVO allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
VolumeVO volume = _volsDao.findById(volumeId);
|
||||
if (volume == null) {
|
||||
throw new InvalidParameterValueException("Creating snapshot failed due to volume:" + volumeId + " doesn't exist");
|
||||
}
|
||||
DataCenter zone = _dcDao.findById(volume.getDataCenterId());
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Can't find zone by id " + volume.getDataCenterId());
|
||||
}
|
||||
|
||||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
|
||||
throw new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled: " + zone.getName());
|
||||
}
|
||||
|
||||
if (volume.getState() != Volume.State.Ready) {
|
||||
throw new InvalidParameterValueException("VolumeId: " + volumeId + " is not in " + Volume.State.Ready + " state but " + volume.getState() + ". Cannot take snapshot.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue