Search in sources :

Example 81 with Cluster

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

the class ExistingVmModelBehavior method updateMinAllocatedMemory.

@Override
public void updateMinAllocatedMemory() {
    if (getModel().getMemSize().getEntity() == null) {
        return;
    }
    Cluster cluster = getModel().getSelectedCluster();
    if (cluster == null) {
        return;
    }
    double overCommitFactor = 100.0 / cluster.getMaxVdsMemoryOverCommit();
    getModel().getMinAllocatedMemory().setEntity((int) (getModel().getMemSize().getEntity() * overCommitFactor));
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 82 with Cluster

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

the class TemplateVmModelBehavior method initialize.

@Override
public void initialize() {
    super.initialize();
    getModel().getTemplateWithVersion().setIsChangeable(false);
    getModel().getBaseTemplate().setIsChangeable(false);
    getModel().getTemplateWithVersion().setIsChangeable(false);
    getModel().getProvisioning().setIsChangeable(false);
    getModel().getStorageDomain().setIsChangeable(false);
    getModel().getIsSoundcardEnabled().setIsChangeable(true);
    getModel().getVmType().setIsChangeable(true);
    getModel().getTemplateVersionName().setIsChangeable(!template.isBaseTemplate());
    getModel().getName().setIsChangeable(template.isBaseTemplate());
    if (template.getStoragePoolId() != null && !template.getStoragePoolId().equals(Guid.Empty)) {
        AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(dataCenter -> AsyncDataProvider.getInstance().getClusterListByService(new AsyncQuery<>(clusters -> {
            ArrayList<Cluster> clustersSupportingVirt = new ArrayList<>();
            // filter clusters supporting virt service only
            for (Cluster cluster : clusters) {
                if (cluster.supportsVirtService()) {
                    clustersSupportingVirt.add(cluster);
                }
            }
            List<Cluster> filteredClusters = AsyncDataProvider.getInstance().filterByArchitecture(clustersSupportingVirt, template.getClusterArch());
            getModel().setDataCentersAndClusters(getModel(), new ArrayList<>(Arrays.asList(new StoragePool[] { dataCenter })), filteredClusters, template.getClusterId());
            updateRngDevice(template.getId());
            AsyncDataProvider.getInstance().isSoundcardEnabled(new AsyncQuery<>(returnValue -> {
                getModel().getIsSoundcardEnabled().setEntity(returnValue);
                initTemplate();
                initCdImage();
            }), template.getId());
            Frontend.getInstance().runQuery(QueryType.IsBalloonEnabled, new IdQueryParameters(template.getId()), new AsyncQuery<>((QueryReturnValue returnValue) -> getModel().getMemoryBalloonDeviceEnabled().setEntity((Boolean) returnValue.getReturnValue())));
            AsyncDataProvider.getInstance().isVirtioScsiEnabledForVm(new AsyncQuery<>(returnValue -> getModel().getIsVirtioScsiEnabled().setEntity(returnValue)), template.getId());
        }), true, false)), template.getStoragePoolId());
    }
    AsyncDataProvider.getInstance().getWatchdogByVmId(new AsyncQuery<>((AsyncCallback<QueryReturnValue>) returnValue -> {
        UnitVmModel model = getModel();
        @SuppressWarnings("unchecked") Collection<VmWatchdog> watchdogs = returnValue.getReturnValue();
        for (VmWatchdog watchdog : watchdogs) {
            model.getWatchdogAction().setSelectedItem(watchdog.getAction());
            model.getWatchdogModel().setSelectedItem(watchdog.getModel());
        }
    }), template.getId());
    getModel().getMigrationMode().setSelectedItem(template.getMigrationSupport());
    setupBaseTemplate(template.getBaseTemplateId());
}
Also used : DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) Arrays(java.util.Arrays) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) BuilderExecutor(org.ovirt.engine.ui.uicommonweb.builders.BuilderExecutor) NameAndDescriptionVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.NameAndDescriptionVmBaseToUnitBuilder) Guid(org.ovirt.engine.core.compat.Guid) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) CommentVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommentVmBaseToUnitBuilder) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) Collections(java.util.Collections) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) CommonVmBaseToUnitBuilder(org.ovirt.engine.ui.uicommonweb.builders.vm.CommonVmBaseToUnitBuilder) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) ArrayList(java.util.ArrayList) List(java.util.List)

Example 83 with Cluster

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

the class BaseVmModelBehaviorTest method initModel.

protected UnitVmModel initModel(VmModelBehaviorBase behavior) {
    final Cluster cluster = new Cluster();
    cluster.setCompatibilityVersion(CLUSTER_VERSION);
    UnitVmModel model = spy(createModel(behavior));
    doReturn(cluster).when(model).getSelectedCluster();
    doReturn(new EntityModel<>(true)).when(model).getIsSingleQxlEnabled();
    model.initialize();
    model.getInstanceImages().setItems(new ArrayList<InstanceImageLineModel>());
    return model;
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 84 with Cluster

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

the class SubTabNetworkClusterView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> nameColumn = new AbstractLinkColumn<PairQueryable<Cluster, NetworkCluster>>(new FieldUpdater<PairQueryable<Cluster, NetworkCluster>, String>() {

        @Override
        public void update(int index, PairQueryable<Cluster, NetworkCluster> cluster, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), cluster.getFirst().getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "400px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> versionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "130px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> attachedColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getSecond() != null;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    attachedColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(attachedColumn, constants.attachedNetworkCluster(), "120px");
    NetworkClusterStatusColumn statusColumn = new NetworkClusterStatusColumn();
    statusColumn.makeSortable(new SimpleStatusColumnComparator<>(statusColumn));
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.networkStatus(), "120px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> netRequiredColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            if (object.getSecond() != null) {
                return object.getSecond().isRequired();
            }
            return false;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    netRequiredColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(netRequiredColumn, constants.requiredNetCluster(), "120px");
    AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> netRoleColumn = createNetRoleColumn();
    netRoleColumn.makeSortable(new NetRoleColumnComparator());
    // $NON-NLS-1$
    getTable().addColumn(netRoleColumn, constants.roleNetCluster(), "120px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> descriptionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionCluster(), "400px");
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkClusterStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkClusterStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 85 with Cluster

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

the class Backend method initAttestation.

private void initAttestation() {
    List<Cluster> clusters = clusterDao.getTrustedClusters();
    List<VDS> trustedVdsList = new ArrayList<>();
    List<String> trustedVdsNames = new ArrayList<>();
    if (clusters == null || clusters.size() == 0) {
        return;
    }
    for (Cluster cluster : clusters) {
        List<VDS> hostsInCluster = vdsDao.getAllForClusterWithStatus(cluster.getId(), VDSStatus.Up);
        if (hostsInCluster != null) {
            trustedVdsList.addAll(hostsInCluster);
        }
    }
    for (VDS vds : trustedVdsList) {
        trustedVdsNames.add(vds.getHostName());
        setNonOperational(NonOperationalReason.UNINITIALIZED, vds);
    }
    try {
        AttestThread attestThread = new AttestThread(trustedVdsNames);
        // start a thread to attest the hosts
        attestThread.start();
    } catch (Exception e) {
        log.error("Failed to initialize attestation cache", e);
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) MacPoolPerCluster(org.ovirt.engine.core.bll.network.macpool.MacPoolPerCluster) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AttestThread(org.ovirt.engine.core.bll.attestationbroker.AttestThread)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22