Search in sources :

Example 21 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class InstanceImageLineModel method attachDisk.

public void attachDisk() {
    if (parentModel.getUnitVmModel().getSelectedCluster() == null || parentModel.getUnitVmModel().getSelectedDataCenter() == null) {
        return;
    }
    InstanceImagesAttachDiskModel model = new InstanceImagesAttachDiskModel() {

        @Override
        public void onSave() {
            if (validate()) {
                flush();
                List<EntityModel<DiskModel>> selectedDisks = getSelectedDisks();
                if (selectedDisks.size() == 1) {
                    // only 0 or 1 is allowed
                    setDisk(selectedDisks.iterator().next().getEntity().getDisk());
                }
                getDiskModel().setEntity(this);
                InstanceImageLineModel.this.setChanged(true);
                setDiskModel(null);
                // from now on only editing is possible
                attachCommand.setIsAvailable(false);
                fillData();
            }
        }

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

        @Override
        protected void updateBootableDiskAvailable() {
            updateBootableFrom(parentModel.getAllCurrentDisksModels());
        }

        @Override
        protected List<Disk> getAttachedNotSubmittedDisks() {
            return parentModel.getNotYetAttachedNotAttachableDisks();
        }
    };
    VM realOrFakeVm = vm;
    Version compatibilityVersion = parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion();
    if (realOrFakeVm == null) {
        realOrFakeVm = new VM();
        realOrFakeVm.setId(null);
        realOrFakeVm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
        realOrFakeVm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
        realOrFakeVm.setClusterCompatibilityVersion(compatibilityVersion);
    }
    model.setVm(realOrFakeVm);
    setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().attachVirtualDiskTitle(), HelpTag.attach_virtual_disk, // $NON-NLS-1$
    "attach_virtual_disk");
    setDiskModel(model);
    model.initialize(parentModel.getAllCurrentDisksModels());
    maybeLoadAttachableDisks(model);
}
Also used : Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 22 with Version

use of org.ovirt.engine.core.compat.Version 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 23 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class UnitVmModel method updateMigrationOptions.

private void updateMigrationOptions() {
    DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
    if (dataCenterWithCluster == null) {
        return;
    }
    Cluster cluster = dataCenterWithCluster.getCluster();
    Version version = getCompatibilityVersion();
    // test migration support for VM/cluster level along with the cluster architecture
    Boolean isMigrationSupported = AsyncDataProvider.getInstance().isMigrationSupported(cluster.getArchitecture(), version);
    if (isMigrationSupported && getVmType().getSelectedItem() != VmType.HighPerformance) {
        getMigrationMode().setItems(Arrays.asList(MigrationSupport.values()));
    } else {
        getMigrationMode().setItems(Arrays.asList(MigrationSupport.PINNED_TO_HOST));
    }
    autoConverge.setIsChangeable(true);
    migrateCompressed.setIsChangeable(true);
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 24 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class UnitVmModel method refreshMigrationPolicies.

private void refreshMigrationPolicies() {
    Version version = getCompatibilityVersion();
    Guid selectedPolicyId = null;
    if (getMigrationPolicies() != null && getMigrationPolicies().getSelectedItem() != null) {
        selectedPolicyId = getMigrationPolicies().getSelectedItem().getId();
    }
    List<MigrationPolicy> policies = AsyncDataProvider.getInstance().getMigrationPolicies(version);
    getMigrationPolicies().setItems(policies);
    if (selectedPolicyId != null) {
        for (MigrationPolicy policy : policies) {
            if (Objects.equals(policy.getId(), selectedPolicyId)) {
                getMigrationPolicies().setSelectedItem(policy);
                break;
            }
        }
    }
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Guid(org.ovirt.engine.core.compat.Guid) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy)

Example 25 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class UnitVmModel method getCompatibilityVersion.

public Version getCompatibilityVersion() {
    ListModel<Version> customCompatibilityVersion = getCustomCompatibilityVersion();
    if (customCompatibilityVersion != null && customCompatibilityVersion.getSelectedItem() != null) {
        return customCompatibilityVersion.getSelectedItem();
    }
    Cluster cluster = getSelectedCluster();
    if (cluster != null) {
        return cluster.getCompatibilityVersion();
    }
    return null;
}
Also used : TemplateWithVersion(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateWithVersion) Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Aggregations

Version (org.ovirt.engine.core.compat.Version)102 ArrayList (java.util.ArrayList)24 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)20 Guid (org.ovirt.engine.core.compat.Guid)20 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)17 Map (java.util.Map)16 List (java.util.List)15 HashSet (java.util.HashSet)14 VDS (org.ovirt.engine.core.common.businessentities.VDS)14 HashMap (java.util.HashMap)13 ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)12 VM (org.ovirt.engine.core.common.businessentities.VM)11 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)11 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)11 Arrays (java.util.Arrays)10 MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)10 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)10 Collection (java.util.Collection)9 Collections (java.util.Collections)9 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)9