Search in sources :

Example 1 with CustomInstanceType

use of org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType in project ovirt-engine by oVirt.

the class ExistingPoolInstanceTypeManager method getSource.

@Override
protected VmBase getSource() {
    boolean customInstanceTypeUsed = getModel().getInstanceTypes() != null && getModel().getInstanceTypes().getSelectedItem() instanceof CustomInstanceType;
    if (!customInstanceTypeUsed) {
        return (VmBase) getModel().getInstanceTypes().getSelectedItem();
    }
    if (getModel().getTemplateWithVersion() == null || getModel().getTemplateWithVersion().getSelectedItem() == null || getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion() == null) {
        return pool.getStaticData();
    }
    VmTemplate template = getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion();
    boolean isLatestPropertyChanged = pool.isUseLatestVersion() != (template instanceof LatestVmTemplate);
    // template ID changed but latest is not set, as it would cause false-positives
    boolean isTemplateIdChangedSinceInit = !pool.getVmtGuid().equals(template.getId()) && !pool.isUseLatestVersion();
    if (isTemplateIdChangedSinceInit || isLatestPropertyChanged) {
        return template;
    }
    return pool.getStaticData();
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) LatestVmTemplate(org.ovirt.engine.ui.uicommonweb.models.templates.LatestVmTemplate) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) CustomInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType) LatestVmTemplate(org.ovirt.engine.ui.uicommonweb.models.templates.LatestVmTemplate)

Example 2 with CustomInstanceType

use of org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType in project ovirt-engine by oVirt.

the class InstanceTypeManager method updateAll.

/**
 * First updates the list of instance types and selects the one which is supposed to be selected and then
 * updates all the fields which are taken from the instance type (by calling the updateFields()).
 */
public void updateAll() {
    final Guid selectedInstanceTypeId = getSelectedInstanceTypeId();
    Frontend.getInstance().runQuery(QueryType.GetAllInstanceTypes, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(returnValue -> {
        if (returnValue == null || !returnValue.getSucceeded()) {
            return;
        }
        List<InstanceType> instanceTypes = new ArrayList<>();
        // add this only if the user is allowed to
        if (!getModel().isCreateInstanceOnly()) {
            instanceTypes.add(CustomInstanceType.INSTANCE);
        }
        for (InstanceType instanceType : (Iterable<InstanceType>) returnValue.getReturnValue()) {
            instanceTypes.add(instanceType);
        }
        getModel().getInstanceTypes().setItems(instanceTypes);
        for (InstanceType instanceType : instanceTypes) {
            if ((instanceType instanceof CustomInstanceType) && selectedInstanceTypeId == null) {
                getModel().getInstanceTypes().setSelectedItem(CustomInstanceType.INSTANCE);
                break;
            }
            if (instanceType.getId() == null || selectedInstanceTypeId == null) {
                continue;
            }
            if (instanceType.getId().equals(selectedInstanceTypeId)) {
                getModel().getInstanceTypes().setSelectedItem(instanceType);
                break;
            }
        }
        if (getModel().getInstanceTypes().getSelectedItem() instanceof CustomInstanceType) {
            // detach if the instance type is "custom"
            getModel().getAttachedToInstanceType().setEntity(false);
        }
        updateFields();
    }));
}
Also used : VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) PriorityUtil(org.ovirt.engine.ui.uicommonweb.models.vms.PriorityUtil) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) CustomInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType) Event(org.ovirt.engine.ui.uicompat.Event) VmEntityType(org.ovirt.engine.core.common.businessentities.VmEntityType) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) VmWatchdogType(org.ovirt.engine.core.common.businessentities.VmWatchdogType) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) AsyncQuery(org.ovirt.engine.ui.frontend.AsyncQuery) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) VmWatchdog(org.ovirt.engine.core.common.businessentities.VmWatchdog) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) Collection(java.util.Collection) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) VirtioScsiUtil(org.ovirt.engine.ui.uicommonweb.models.vms.VirtioScsiUtil) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) CustomInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType) CustomInstanceType(org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType)

Aggregations

VmBase (org.ovirt.engine.core.common.businessentities.VmBase)2 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)2 CustomInstanceType (org.ovirt.engine.ui.uicommonweb.models.vms.CustomInstanceType)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 DisplayType (org.ovirt.engine.core.common.businessentities.DisplayType)1 GraphicsDevice (org.ovirt.engine.core.common.businessentities.GraphicsDevice)1 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)1 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)1 MigrationSupport (org.ovirt.engine.core.common.businessentities.MigrationSupport)1 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)1 VmDeviceGeneralType (org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType)1 VmEntityType (org.ovirt.engine.core.common.businessentities.VmEntityType)1 VmRngDevice (org.ovirt.engine.core.common.businessentities.VmRngDevice)1 VmWatchdog (org.ovirt.engine.core.common.businessentities.VmWatchdog)1 VmWatchdogType (org.ovirt.engine.core.common.businessentities.VmWatchdogType)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1