Search in sources :

Example 6 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfileHelper method updateDiskImageProfilesList.

/**
 * Updates the disk profiles list of the given disk image according to the storageDomainID.
 * The disk profiles list will be set with the first disk profile that matches the storage domain id.
 *
 * @param diskImage       disk image to be updated with the relevant disk profiles list
 * @param storageDomainId storage domain id to match a disk profile with
 * @return valid disk profile in case there is a match with the given storage domain ID. otherwise return an
 * invalid disk profile.
 */
private DiskProfile updateDiskImageProfilesList(DiskImage diskImage, Guid storageDomainId) {
    DiskProfile diskProfile = null;
    if (storageDomainId != null) {
        List<Guid> diskProfileIds = diskImage.getDiskProfileIds();
        List<DiskProfile> diskProfilesListByStorageDomain = diskProfileDao.getAllForStorageDomain(storageDomainId);
        Optional<DiskProfile> match = diskProfilesListByStorageDomain.stream().filter(profile -> diskProfileIds.contains(profile.getId())).findFirst();
        if (match.isPresent()) {
            diskProfile = match.get();
            diskImage.setDiskProfileIds(new ArrayList<Guid>(Arrays.asList(diskProfile.getId())));
        }
    }
    return diskProfile;
}
Also used : Arrays(java.util.Arrays) Guid(org.ovirt.engine.core.compat.Guid) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) ArrayList(java.util.ArrayList) DiskProfileDao(org.ovirt.engine.core.dao.profiles.DiskProfileDao) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Map(java.util.Map) Logger(org.slf4j.Logger) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) Set(java.util.Set) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) PermissionDao(org.ovirt.engine.core.dao.PermissionDao) List(java.util.List) Injector(org.ovirt.engine.core.di.Injector) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Entry(java.util.Map.Entry) Optional(java.util.Optional) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Guid(org.ovirt.engine.core.compat.Guid) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 7 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class StorageDomainCommandBase method createDefaultDiskProfile.

/**
 * Creates default disk profile for existing storage domain.
 */
protected void createDefaultDiskProfile() {
    executeInNewTransaction(() -> {
        final DiskProfile diskProfile = diskProfileHelper.createDiskProfile(getStorageDomain().getId(), getStorageDomainName());
        DiskProfileParameters diskProfileParameters = new DiskProfileParameters(diskProfile, true);
        runInternalActionWithTasksContext(ActionType.AddDiskProfile, diskProfileParameters);
        getCompensationContext().snapshotNewEntity(diskProfile);
        getCompensationContext().stateChanged();
        return null;
    });
}
Also used : DiskProfileParameters(org.ovirt.engine.core.common.action.DiskProfileParameters) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 8 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class AbstractDiskModel method updateDiskProfiles.

private void updateDiskProfiles(StoragePool selectedItem) {
    StorageDomain storageDomain = getStorageDomain().getSelectedItem();
    if (storageDomain == null) {
        return;
    }
    Frontend.getInstance().runQuery(QueryType.GetDiskProfilesByStorageDomainId, new IdQueryParameters(storageDomain.getId()), new AsyncQuery<QueryReturnValue>(value -> setDiskProfilesList((List<DiskProfile>) value.getReturnValue())));
}
Also used : Arrays(java.util.Arrays) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Event(org.ovirt.engine.ui.uicompat.Event) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) QuotaEnforcementTypeEnum(org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) Predicate(java.util.function.Predicate) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) Collectors(java.util.stream.Collectors) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) StorageModel(org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel) NotEmptyQuotaValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyQuotaValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) CinderVolumeType(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeType) SanStorageModelBase(org.ovirt.engine.ui.uicommonweb.models.storage.SanStorageModelBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) Quota(org.ovirt.engine.core.common.businessentities.Quota) VM(org.ovirt.engine.core.common.businessentities.VM) ScsiGenericIO(org.ovirt.engine.core.common.businessentities.storage.ScsiGenericIO) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 9 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfilesListModelTable method updatePermissionPanel.

private void updatePermissionPanel() {
    final DiskProfile diskProfile = getModel().getSelectedItem();
    Scheduler.get().scheduleDeferred(() -> {
        if (permissionListModelTable.isVisible() && diskProfile == null) {
            permissionListModelTable.setVisible(false);
        } else if (!permissionListModelTable.isVisible() && diskProfile != null) {
            permissionListModelTable.setVisible(true);
        }
    });
}
Also used : DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Example 10 with DiskProfile

use of org.ovirt.engine.core.common.businessentities.profiles.DiskProfile in project ovirt-engine by oVirt.

the class DiskProfileDaoTest method testGetByQos.

@Test
public void testGetByQos() {
    List<DiskProfile> allForQos = dao.getAllForQos(FixturesTool.QOS_ID_1);
    assertNotNull(allForQos);
    assertEquals(2, allForQos.size());
    for (DiskProfile diskProfile : allForQos) {
        assertEquals(FixturesTool.QOS_ID_1, diskProfile.getQosId());
    }
}
Also used : DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile) Test(org.junit.Test)

Aggregations

DiskProfile (org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)19 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)7 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)5 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 HashMap (java.util.HashMap)3 List (java.util.List)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 DiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)2 StorageQos (org.ovirt.engine.core.common.businessentities.qos.StorageQos)2 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1