Search in sources :

Example 76 with VmTemplate

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

the class AuditLogableBaseTest method getVmTemplateWithId.

@Test
public void getVmTemplateWithId() {
    b.setVmTemplate(null);
    b.setVmTemplateId(GUID);
    final VmTemplate t = b.getVmTemplate();
    assertNotNull(t);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 77 with VmTemplate

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

the class TemplateModule method getTemplateListProvider.

// Main List Model
@Provides
@Singleton
public MainModelProvider<VmTemplate, TemplateListModel> getTemplateListProvider(EventBus eventBus, final Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<TemplateEditPresenterWidget> popupProvider, final Provider<VmExportPopupPresenterWidget> exportPopupProvider, final Provider<VmPopupPresenterWidget> createVmPopupProvider, final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<TemplateListModel> modelProvider, final Provider<VmDiskPopupPresenterWidget> newDiskPopupProvider, final Provider<SingleSelectionVmDiskAttachPopupPresenterWidget> attachDiskPopupProvider, final Provider<VmHighPerformanceConfigurationPresenterWidget> highPerformanceConfigurationProvider) {
    MainViewModelProvider<VmTemplate, TemplateListModel> result = new MainViewModelProvider<VmTemplate, TemplateListModel>(eventBus, defaultConfirmPopupProvider) {

        @Override
        public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(TemplateListModel source, UICommand lastExecutedCommand, Model windowModel) {
            TemplateListModel model = getModel();
            if (lastExecutedCommand == model.getEditCommand()) {
                return popupProvider.get();
            } else if (lastExecutedCommand == getModel().getExportCommand()) {
                return exportPopupProvider.get();
            } else if (lastExecutedCommand == getModel().getCreateVmFromTemplateCommand()) {
                if (windowModel instanceof AttachDiskModel) {
                    return attachDiskPopupProvider.get();
                } else if ((windowModel instanceof NewDiskModel) || (windowModel instanceof EditDiskModel)) {
                    return newDiskPopupProvider.get();
                } else {
                    return createVmPopupProvider.get();
                }
            } else {
                return super.getModelPopup(source, lastExecutedCommand, windowModel);
            }
        }

        @Override
        public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(TemplateListModel source, UICommand lastExecutedCommand) {
            if (lastExecutedCommand == getModel().getRemoveCommand()) {
                return removeConfirmPopupProvider.get();
            } else if ("OnSave".equals(lastExecutedCommand.getName())) {
                // $NON-NLS-1$
                return defaultConfirmPopupProvider.get();
            } else if (// $NON-NLS-1$
            "OnSaveVm".equals(lastExecutedCommand.getName()) && source.getConfirmWindow() instanceof VmHighPerformanceConfigurationModel) {
                return highPerformanceConfigurationProvider.get();
            } else {
                return super.getConfirmModelPopup(source, lastExecutedCommand);
            }
        }
    };
    result.setModelProvider(modelProvider);
    return result;
}
Also used : MainViewModelProvider(org.ovirt.engine.ui.common.uicommon.model.MainViewModelProvider) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) EditDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.EditDiskModel) NewDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel) TemplateInterfaceListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateInterfaceListModel) TemplateEventListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateEventListModel) AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) NewDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel) TemplateListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateListModel) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) TemplateVmListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateVmListModel) TemplateStorageListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateStorageListModel) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) EditDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.EditDiskModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) TemplateDiskListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateDiskListModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) TemplateGeneralModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateGeneralModel) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) TemplateListModel(org.ovirt.engine.ui.uicommonweb.models.templates.TemplateListModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 78 with VmTemplate

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

the class CommonVmPoolCommandTestAbstract method mockVmTemplate.

/**
 * Mock VM Template.
 */
private VmTemplate mockVmTemplate() {
    VmTemplate template = new VmTemplate();
    template.setId(vmTemplateId);
    template.setStoragePoolId(storagePoolId);
    template.setClusterArch(ArchitectureType.x86_64);
    setDiskList(template);
    return template;
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Example 79 with VmTemplate

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

the class AddVmCommandTestBase method initVmTemplate.

private void initVmTemplate() {
    vmTemplate = new VmTemplate();
    vmTemplate.setStoragePoolId(STORAGE_POOL_ID);
    vmTemplate.getDiskTemplateMap().putAll(cmd.storageToDisksMap.values().stream().flatMap(List::stream).collect(Collectors.toMap(DiskImage::getImageId, Function.identity())));
    HashMap<Guid, DiskImage> diskImageMap = new HashMap<>();
    DiskImage diskImage = createDiskImage(STORAGE_DOMAIN_ID_1);
    diskImageMap.put(diskImage.getId(), diskImage);
    vmTemplate.setDiskImageMap(diskImageMap);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 80 with VmTemplate

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

the class AsyncDataProvider method getTemplateListByStorage.

public void getTemplateListByStorage(AsyncQuery<List<VmTemplate>> aQuery, Guid storageId) {
    aQuery.converterCallback = source -> {
        ArrayList<VmTemplate> list = new ArrayList<>();
        if (source != null) {
            for (VmTemplate template : (ArrayList<VmTemplate>) source) {
                if (template.getStatus() == VmTemplateStatus.OK) {
                    list.add(template);
                }
            }
            Collections.sort(list, new NameableComparator());
        }
        return list;
    };
    Frontend.getInstance().runQuery(QueryType.GetVmTemplatesFromStorageDomain, new GetVmTemplatesFromStorageDomainParameters(storageId, false), aQuery);
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ArrayList(java.util.ArrayList) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) GetVmTemplatesFromStorageDomainParameters(org.ovirt.engine.core.common.queries.GetVmTemplatesFromStorageDomainParameters)

Aggregations

VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)149 ArrayList (java.util.ArrayList)42 Guid (org.ovirt.engine.core.compat.Guid)40 Test (org.junit.Test)30 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)23 HashMap (java.util.HashMap)22 List (java.util.List)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)16 Map (java.util.Map)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)13 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)9 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)9 Collection (java.util.Collection)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)8