Search in sources :

Example 6 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class AddVmPoolCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = new ArrayList<>();
    permissionList.add(new PermissionSubject(getParameters().getVmStaticData().getClusterId(), VdcObjectType.Cluster, getActionType().getActionGroup()));
    permissionList.add(new PermissionSubject(getVmTemplateId(), VdcObjectType.VmTemplate, ActionGroup.CREATE_VM));
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Example 7 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class AddVmTemplateCommand method getPermissionCheckSubjects.

/**
 * in case of non-existing cluster the backend query will return a null
 */
@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    if (permissionCheckSubject == null) {
        permissionCheckSubject = new ArrayList<>();
        if (getParameters().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
            Guid storagePoolId = getCluster() == null ? null : getCluster().getStoragePoolId();
            permissionCheckSubject.add(new PermissionSubject(storagePoolId, VdcObjectType.StoragePool, getActionType().getActionGroup()));
            // host-specific parameters can be changed by administration role only
            if (!new HashSet<>(getParameters().getMasterVm().getDedicatedVmForVdsList()).equals(new HashSet<>(getVm().getDedicatedVmForVdsList())) || !StringUtils.isEmpty(getParameters().getMasterVm().getCpuPinning())) {
                permissionCheckSubject.add(new PermissionSubject(storagePoolId, VdcObjectType.StoragePool, ActionGroup.EDIT_ADMIN_TEMPLATE_PROPERTIES));
            }
        } else {
            permissionCheckSubject.add(new PermissionSubject(Guid.SYSTEM, VdcObjectType.System, getActionType().getActionGroup()));
        }
    }
    return permissionCheckSubject;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class ImportVmFromExternalUrlCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    Set<PermissionSubject> permissionSet = new HashSet<>();
    // Destination domain
    permissionSet.add(new PermissionSubject(getStorageDomainId(), VdcObjectType.Storage, getActionType().getActionGroup()));
    return new ArrayList<>(permissionSet);
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 9 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class ImportVmCommand method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionList = super.getPermissionCheckSubjects();
    // Destination domains
    imageToDestinationDomainMap.values().stream().distinct().map(storageId -> new PermissionSubject(storageId, VdcObjectType.Storage, getActionType().getActionGroup())).forEach(permissionList::add);
    // Source domain
    permissionList.add(new PermissionSubject(getParameters().getSourceDomainId(), VdcObjectType.Storage, getActionType().getActionGroup()));
    // special permission is needed to use custom properties
    if (getVm() != null && !StringUtils.isEmpty(getVm().getCustomProperties())) {
        permissionList.add(new PermissionSubject(getClusterId(), VdcObjectType.Cluster, ActionGroup.CHANGE_VM_CUSTOM_PROPERTIES));
    }
    return permissionList;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) LockMessagesMatchUtil(org.ovirt.engine.core.bll.LockMessagesMatchUtil) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ImageOperation(org.ovirt.engine.core.common.businessentities.storage.ImageOperation) DiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator) EngineException(org.ovirt.engine.core.common.errors.EngineException) SnapshotDao(org.ovirt.engine.core.dao.SnapshotDao) VdsCommandsHelper(org.ovirt.engine.core.bll.storage.utils.VdsCommandsHelper) MoveOrCopyImageGroupParameters(org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) Instance(javax.enterprise.inject.Instance) RemoveMemoryVolumesParameters(org.ovirt.engine.core.common.action.RemoveMemoryVolumesParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Set(java.util.Set) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters) ImageDbOperationScope(org.ovirt.engine.core.common.businessentities.storage.ImageDbOperationScope) DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) LunHelper(org.ovirt.engine.core.bll.storage.domain.LunHelper) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) QuotaConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter) VmStatisticsDao(org.ovirt.engine.core.dao.VmStatisticsDao) QueryType(org.ovirt.engine.core.common.queries.QueryType) QuotaStorageDependent(org.ovirt.engine.core.bll.quota.QuotaStorageDependent) DiskLunMapDao(org.ovirt.engine.core.dao.DiskLunMapDao) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) ImportClonedEntity(org.ovirt.engine.core.common.validation.group.ImportClonedEntity) Guid(org.ovirt.engine.core.compat.Guid) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) DiskProfileHelper(org.ovirt.engine.core.bll.profiles.DiskProfileHelper) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) MacPool(org.ovirt.engine.core.bll.network.macpool.MacPool) ONLY_ACTIVE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE) Pair(org.ovirt.engine.core.common.utils.Pair) StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) SnapshotStatus(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) QcowCompat(org.ovirt.engine.core.common.businessentities.storage.QcowCompat) VM(org.ovirt.engine.core.common.businessentities.VM) CommandCallback(org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback) DiskDao(org.ovirt.engine.core.dao.DiskDao) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) VmInterfaceManager(org.ovirt.engine.core.bll.network.VmInterfaceManager) NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) Date(java.util.Date) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) LoggerFactory(org.slf4j.LoggerFactory) ImportEntity(org.ovirt.engine.core.common.validation.group.ImportEntity) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) DiskLunMap(org.ovirt.engine.core.common.businessentities.storage.DiskLunMap) StorageDomainValidator(org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator) DiskImageDynamicDao(org.ovirt.engine.core.dao.DiskImageDynamicDao) SnapshotVmConfigurationHelper(org.ovirt.engine.core.bll.snapshots.SnapshotVmConfigurationHelper) VmNicMacsUtils(org.ovirt.engine.core.bll.validator.VmNicMacsUtils) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) VmOverheadCalculator(org.ovirt.engine.core.common.scheduling.VmOverheadCalculator) Predicate(java.util.function.Predicate) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) BaseDiskDao(org.ovirt.engine.core.dao.BaseDiskDao) CopyVolumeType(org.ovirt.engine.core.common.businessentities.storage.CopyVolumeType) StoragePoolDomainAndGroupIdBaseVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.StoragePoolDomainAndGroupIdBaseVDSCommandParameters) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) Collectors(java.util.stream.Collectors) ConcurrentChildCommandsExecutionCallback(org.ovirt.engine.core.bll.ConcurrentChildCommandsExecutionCallback) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) DiskLunMapId(org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId) List(java.util.List) Optional(java.util.Optional) AuditLogType(org.ovirt.engine.core.common.AuditLogType) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmTemplateHandler(org.ovirt.engine.core.bll.VmTemplateHandler) GetAllFromExportDomainQueryParameters(org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters) HashMap(java.util.HashMap) TransactionSupport(org.ovirt.engine.core.utils.transaction.TransactionSupport) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) MemoryStorageHandler(org.ovirt.engine.core.bll.memory.MemoryStorageHandler) HashSet(java.util.HashSet) Inject(javax.inject.Inject) MemoryUtils(org.ovirt.engine.core.bll.memory.MemoryUtils) DiskImageDao(org.ovirt.engine.core.dao.DiskImageDao) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) LinkedList(java.util.LinkedList) StorageDomainStaticDao(org.ovirt.engine.core.dao.StorageDomainStaticDao) DisableInPrepareMode(org.ovirt.engine.core.bll.DisableInPrepareMode) ImagesHandler(org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) VmTemplateStatus(org.ovirt.engine.core.common.businessentities.VmTemplateStatus) Typed(javax.enterprise.inject.Typed) QuotaStorageConsumptionParameter(org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter) DiskImageBase(org.ovirt.engine.core.common.businessentities.storage.DiskImageBase) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) GetImageInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetImageInfoVDSCommandParameters) QemuImageInfo(org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) StorageDomainType(org.ovirt.engine.core.common.businessentities.StorageDomainType) Collections(java.util.Collections) ImageDao(org.ovirt.engine.core.dao.ImageDao) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 10 with PermissionSubject

use of org.ovirt.engine.core.bll.utils.PermissionSubject in project ovirt-engine by oVirt.

the class VmLeaseCommandBase method getPermissionCheckSubjects.

@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
    List<PermissionSubject> permissionCheckSubjects = new ArrayList<>();
    permissionCheckSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), VdcObjectType.Storage, getActionType().getActionGroup()));
    return permissionCheckSubjects;
}
Also used : PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ArrayList(java.util.ArrayList)

Aggregations

PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)71 ArrayList (java.util.ArrayList)47 Guid (org.ovirt.engine.core.compat.Guid)15 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)5 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ImagesHandler (org.ovirt.engine.core.bll.storage.disk.image.ImagesHandler)3 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)3 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)3 VmNic (org.ovirt.engine.core.common.businessentities.network.VmNic)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 DiskVmElementDao (org.ovirt.engine.core.dao.DiskVmElementDao)3 Arrays (java.util.Arrays)2