Search in sources :

Example 16 with Quota

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

the class ImportVmFromExternalProviderModel method initQuotaForStorageDomains.

private void initQuotaForStorageDomains() {
    List<QueryType> queryTypeList = new ArrayList<>();
    List<QueryParametersBase> queryParamsList = new ArrayList<>();
    for (StorageDomain storage : getStorage().getItems()) {
        queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
        queryParamsList.add(new IdQueryParameters(storage.getId()));
    }
    storageQuotaMap = new HashMap<>();
    Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
        Iterator<QueryReturnValue> returnValuesIter = result.getReturnValues().iterator();
        Iterator<StorageDomain> domainsIter = getStorage().getItems().iterator();
        boolean noQuota = true;
        while (domainsIter.hasNext()) {
            ArrayList<Quota> quotaList = returnValuesIter.next().getReturnValue();
            noQuota = noQuota && quotaList.isEmpty();
            storageQuotaMap.put(domainsIter.next().getId(), quotaList);
        }
        if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
            showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
        }
        initDisksStorageDomainsList();
    });
}
Also used : ArrayList(java.util.ArrayList) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 17 with Quota

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

the class InstanceImageLineModel method showNewDialog.

private void showNewDialog() {
    final AbstractDiskModel model = new NewDiskModel() {

        @Override
        public void onSave() {
            if (validate()) {
                flush();
                getDiskModel().setEntity(this);
                InstanceImageLineModel.this.setChanged(true);
                setDiskModel(null);
                // the "new" turns into "edit" - no need for attach anymore
                attachCommand.setIsAvailable(false);
                fillData();
                Disk disk = super.getDisk();
                if (disk.getDiskStorageType() == DiskStorageType.IMAGE || disk.getDiskStorageType() == DiskStorageType.CINDER) {
                    ((DiskImage) disk).setActive(true);
                }
            }
        }

        @Override
        public void updateInterface(Version clusterVersion) {
            InstanceImageLineModel.this.updateInterface(clusterVersion, this);
        }

        @Override
        protected void updateBootableDiskAvailable() {
            updateBootableFrom(parentModel.getAllCurrentDisksModels());
        }
    };
    VM vm = new VM();
    vm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
    vm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
    vm.setClusterCompatibilityVersion(parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion());
    Quota selectedQuota = parentModel.getUnitVmModel().getQuota().getSelectedItem();
    vm.setQuotaId(selectedQuota == null ? null : selectedQuota.getId());
    model.setVm(vm);
    model.getSizeExtend().setIsAvailable(false);
    setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().newVirtualDiskTitle(), HelpTag.new_virtual_disk, // $NON-NLS-1$
    "new_virtual_disk");
    setDiskModel(model);
    model.initialize(parentModel.getAllCurrentDisksModels());
    if (model.getIsBootable().getIsChangable()) {
        model.getIsBootable().setEntity(true);
    }
    if (getVm() != null) {
        model.setVm(getVm());
        ((NewDiskModel) model).updateSuggestedDiskAliasFromServer();
    } else {
        String currentVmName = parentModel.getUnitVmModel().getName().getEntity();
        if (StringHelper.isNotNullOrEmpty(currentVmName)) {
            // if already set the VM name on the new VM dialog, suggest the name according to the name
            model.getAlias().setEntity(suggestAliasForNewVm(currentVmName));
        }
    }
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota) Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 18 with Quota

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

the class BaseVmListModelTest method setUpUnitVmModelExpectations.

protected void setUpUnitVmModelExpectations(UnitVmModel model) {
    when(model.getVmType().getSelectedItem()).thenReturn(VM_TYPE);
    VmTemplate template = new VmTemplate();
    template.setId(TEMPLATE_GUID);
    TemplateWithVersion templateWithVersion = mock(TemplateWithVersion.class);
    when(templateWithVersion.getTemplateVersion()).thenReturn(template);
    when(model.getTemplateWithVersion().getSelectedItem()).thenReturn(templateWithVersion);
    when(model.getName().getEntity()).thenReturn(VM_NAME);
    InstanceType instanceType = new VmTemplate();
    instanceType.setId(INSTANCE_TYPE_ID);
    when(model.getInstanceTypes().getSelectedItem()).thenReturn(instanceType);
    when(model.getOSType().getSelectedItem()).thenReturn(OS_TYPE);
    when(model.getNumOfMonitors().getSelectedItem()).thenReturn(NUM_OF_MONITORS);
    when(model.getDescription().getEntity()).thenReturn(DESCRIPTION);
    when(model.getComment().getEntity()).thenReturn(COMMENT);
    when(model.getEmulatedMachine().getSelectedItem()).thenReturn(EMULATED_MACHINE);
    when(model.getCustomCpu().getSelectedItem()).thenReturn(CUSTOM_CPU_NAME);
    when(model.getMemSize().getEntity()).thenReturn(MEM_SIZE);
    when(model.getMaxMemorySize().getEntity()).thenReturn(MAX_MEMORY_SIZE);
    when(model.getMinAllocatedMemory().getEntity()).thenReturn(MIN_MEM);
    when(model.getSelectedCluster().getId()).thenReturn(CLUSTER_ID);
    ListModel<TimeZoneModel> timeZoneModelListModel = mockTimeZoneListModel();
    when(model.getTimeZone()).thenReturn(timeZoneModelListModel);
    when(model.getNumOfSockets().getSelectedItem()).thenReturn(NUM_OF_SOCKETS);
    when(model.getCoresPerSocket().getSelectedItem()).thenReturn(CORES_PER_SOCKET);
    when(model.getThreadsPerCore().getSelectedItem()).thenReturn(THREADS_PER_CORE);
    SerialNumberPolicyModel serialNumberPolicyModel = mockSerialNumberPolicyModel();
    when(model.getSerialNumberPolicy()).thenReturn(serialNumberPolicyModel);
    when(model.getAllowConsoleReconnect().getEntity()).thenReturn(true);
    when(model.getIsSingleQxlEnabled().getEntity()).thenReturn(true);
    when(model.getTotalCPUCores().getEntity()).thenReturn(Integer.toString(TOTAL_CPU));
    when(model.getUsbPolicy().getSelectedItem()).thenReturn(USB_POLICY);
    when(model.getIsStateless().getEntity()).thenReturn(true);
    when(model.getIsSmartcardEnabled().getEntity()).thenReturn(true);
    when(model.getIsDeleteProtected().getEntity()).thenReturn(true);
    when(model.extractSelectedSsoMethod()).thenReturn(SSO_METHOD);
    when(model.getBootSequence()).thenReturn(BOOT_SEQUENCE);
    ListModel<RepoImage> cdListModel = mockCdListModel();
    when(model.getCdImage()).thenReturn(cdListModel);
    when(model.getIsHighlyAvailable().getEntity()).thenReturn(true);
    when(model.getInitrd_path().getEntity()).thenReturn(INITRD_PATH);
    when(model.getKernel_path().getEntity()).thenReturn(KERNEL_PATH);
    when(model.getKernel_parameters().getEntity()).thenReturn(KERNEL_PARAMS);
    when(model.getCustomPropertySheet().serialize()).thenReturn(CUSTOM_PROPERTIES);
    ListModel<Quota> quotaListModel = mockQuotaListModel();
    when(model.getQuota()).thenReturn(quotaListModel);
    when(model.getVncKeyboardLayout().getSelectedItem()).thenReturn(VNC_KEYBOARD_LAYOUT);
    when(model.getDisplayType().getSelectedItem()).thenReturn(DISPLAY_TYPE);
    EntityModel<Integer> priorityEntityModel = mockEntityModel(PRIORITY);
    when(model.getPriority().getSelectedItem()).thenReturn(priorityEntityModel);
    when(model.getIsRunAndPause().getEntity()).thenReturn(true);
    VDS defaultHost = new VDS();
    defaultHost.setId(HOST_ID);
    when(model.getDefaultHost().getSelectedItem()).thenReturn(defaultHost);
    when(model.getDefaultHost().getSelectedItems()).thenReturn(Collections.singletonList(defaultHost));
    when(model.getIsAutoAssign().getEntity()).thenReturn(false);
    when(model.getMigrationMode().getSelectedItem()).thenReturn(MIGRATION_SUPPORT);
    when(model.getSelectedMigrationDowntime()).thenReturn(MIGRATION_DOWNTIME);
    when(model.getBootMenuEnabled().getEntity()).thenReturn(true);
    when(model.getSpiceFileTransferEnabled().getEntity()).thenReturn(true);
    when(model.getSpiceCopyPasteEnabled().getEntity()).thenReturn(true);
    ListModel<CpuProfile> cpuProfiles = mockCpuProfiles();
    when(model.getCpuProfiles()).thenReturn(cpuProfiles);
    when(model.getNumaNodeCount().getEntity()).thenReturn(0);
    when(model.getNumaTuneMode().getSelectedItem()).thenReturn(NumaTuneMode.INTERLEAVE);
    when(model.getAutoConverge().getSelectedItem()).thenReturn(true);
    when(model.getMigrateCompressed().getSelectedItem()).thenReturn(true);
    when(model.getIcon().getEntity()).thenReturn(new IconWithOsDefault(LARGE_ICON_DATA, LARGE_OS_DEFAULT_ICON_DATA, SMALL_ICON_ID, ValidationResult.ok()));
    when(model.getIoThreadsEnabled().getEntity()).thenReturn(true);
    when(model.getConsoleDisconnectAction().getSelectedItem()).thenReturn(ConsoleDisconnectAction.REBOOT);
    when(model.getCustomCompatibilityVersion().getSelectedItem()).thenReturn(Version.v3_6);
    when(model.getOverrideMigrationPolicy().getEntity()).thenReturn(false);
    when(model.getLease().getSelectedItem()).thenReturn(null);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) RepoImage(org.ovirt.engine.core.common.businessentities.storage.RepoImage) Quota(org.ovirt.engine.core.common.businessentities.Quota) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) CpuProfile(org.ovirt.engine.core.common.businessentities.profiles.CpuProfile) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

Example 19 with Quota

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

the class SubTabDataCenterQuotaView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    QuotaDcStatusColumn dcStatusColumn = new QuotaDcStatusColumn();
    dcStatusColumn.setContextMenuTitle(constants.dcStatusQuota());
    // $NON-NLS-1$
    getTable().addColumn(dcStatusColumn, constants.empty(), "30px");
    AbstractTextColumn<Quota> nameColumn = new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            // $NON-NLS-1$
            return object.getQuotaName() == null ? "" : object.getQuotaName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameQuota(), "400px");
    AbstractTextColumn<Quota> descriptionColumn = new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            // $NON-NLS-1$
            return object.getDescription() == null ? "" : object.getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionQuota(), "400px");
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaDcStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.QuotaDcStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)

Example 20 with Quota

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

the class QuotaCRUDCommand method fillQuotaParameter.

/**
 * Fills missing data in the quota parameter
 */
private void fillQuotaParameter() {
    Quota quotaParameter = getParameters().getQuota();
    setQuotaStorage(quotaParameter);
    setQuotaCluster(quotaParameter);
    setQuotaThresholdDefaults(quotaParameter);
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota)

Aggregations

Quota (org.ovirt.engine.core.common.businessentities.Quota)101 ArrayList (java.util.ArrayList)23 Guid (org.ovirt.engine.core.compat.Guid)22 Test (org.junit.Test)17 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)16 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 HashMap (java.util.HashMap)9 List (java.util.List)9 QueryType (org.ovirt.engine.core.common.queries.QueryType)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)6 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)6 Map (java.util.Map)5 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5