public ArrayList<VmTemplate> filterTemplatesByArchitecture(List<VmTemplate> list, ArchitectureType architecture) { ArrayList<VmTemplate> filteredList = new ArrayList<>(); for (VmTemplate template : list) { if (template.getId().equals(Guid.Empty) || template.getClusterArch().equals(architecture)) { filteredList.add(template); } } return filteredList; }
public Guid getVmTemplateIdRef() { if (vmTemplateId == null && getVmTemplate() != null) { vmTemplateId = getVmTemplate().getId(); } return vmTemplateId; }
/** * Check if template is base template or version of a template * @return true if template is a base template, and false if its a version of a template */ public boolean isBaseTemplate() { return getId().equals(getBaseTemplateId()); }
private boolean selectedItemsContainBlankTemplate() { if (getSelectedItems() != null) { List<VmTemplate> templates = getSelectedItems(); for (VmTemplate template : templates) { if (template != null && template.getId().equals(Guid.Empty)) { return true; } } } return false; }
protected VmTemplate getEntity() { if (template != null) { return template; } for (VmTemplate entity : parent.getEntitiesFromExportDomain()) { if (guid.equals(entity.getId())) { template = entity; return entity; } } return entityNotFound(); }
@Override protected void syncSearch() { if (getEntity() == null) { return; } super.syncSearch(QueryType.GetVmTemplatesDisks, new IdQueryParameters(getEntity().getId())); }
@Override protected void syncSearch() { if (getEntity() == null) { return; } super.syncSearch(QueryType.GetTemplateInterfacesByTemplateId, new IdQueryParameters(getEntity().getId())); }
@Override public boolean test(TemplateWithVersion templateWithVersion) { if (useLatest) { return templateWithVersion.getTemplateVersion() instanceof LatestVmTemplate; } else { return id.equals(templateWithVersion.getTemplateVersion().getId()) && !(templateWithVersion.getTemplateVersion() instanceof LatestVmTemplate); } } }
static org.ovirt.engine.core.common.businessentities.InstanceType setUpEntityExpectations(VmTemplate entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]); when(entity.getNumOfCpus()).thenReturn(8); when(entity.getNumOfSockets()).thenReturn(2); when(entity.getThreadsPerCpu()).thenReturn(1); when(entity.getCpuPerSocket()).thenReturn(4); when(entity.isBaseTemplate()).thenReturn(true); return entity; }
/** * Ensures updating the status aspect of the VM Template works. */ @Test public void testUpdateStatus() { VmTemplate before = dao.get(existingEntity.getId()); before.setStatus(VmTemplateStatus.Locked); dao.updateStatus(existingEntity.getId(), VmTemplateStatus.Locked); VmTemplate after = dao.get(existingEntity.getId()); assertEquals(before, after); }
@Override protected void syncSearch() { if (getEntity() == null) { return; } super.syncSearch(); VmTemplate template = getEntity(); super.syncSearch(QueryType.GetStorageDomainsByVmTemplateId, new IdQueryParameters(template.getId())); }
private void createVMFromTemplate() { VmTemplate template = getSelectedItem(); final List<UICommand> commands = new ArrayList<>(); commands.add(UICommand.createDefaultOkUiCommand("OnSaveVm", this)); //$NON-NLS-1$ commands.add(UICommand.createCancelUiCommand("Cancel", this)); //$NON-NLS-1$ AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(withVmInit -> setupNewVmModel(new UnitVmModel(new NewVmFromTemplateModelBehavior(withVmInit), TemplateListModel.this), withVmInit.getVmType(), commands)), template.getId()); }
private void edit() { VmTemplate template = getSelectedItem(); if (getWindow() != null) { return; } // populating VMInit AsyncDataProvider.getInstance().getTemplateById(new AsyncQuery<>(result -> vmInitLoaded(result)), template.getId()); }
/** * Assert that all versions (VM_TEMPLATE_RHEL5_V2) returns for base template (VM_TEMPLATE_RHEL5) */ @Test public void testGetTemplateVersionsForBaseTemplate() { List<VmTemplate> tVersions = dao.getTemplateVersionsForBaseTemplate(FixturesTool.VM_TEMPLATE_RHEL5); assertEquals(1, tVersions.size()); assertEquals(FixturesTool.VM_TEMPLATE_RHEL5_V2, tVersions.get(0).getId()); }
/** * Assert that latest version (VM_TEMPLATE_RHEL5_V2) returns for base template (VM_TEMPLATE_RHEL5) */ @Test public void testGetTemplateWithLatestVersionInChain() { assertEquals(FixturesTool.VM_TEMPLATE_RHEL5_V2, dao.getTemplateWithLatestVersionInChain(FixturesTool.VM_TEMPLATE_RHEL5).getId()); }
public ImportVmTemplateParameters(Guid storagePoolId, Guid sourceDomainId, Guid destDomainId, Guid clusterId, VmTemplate template) { super(template.getId(), destDomainId); this.setVmTemplate(template); this.setDestDomainId(destDomainId); this.setSourceDomainId(sourceDomainId); this.setDestDomainId(destDomainId); this.setStorageDomainId(this.getDestDomainId()); this.setStoragePoolId(storagePoolId); this.setClusterId(clusterId); }
@Override protected void build(UnitVmModel model, VM vm) { vm.setVmtGuid(model.getTemplateWithVersion().getSelectedItem().getTemplateVersion().getId()); vm.setInstanceTypeId(model.getInstanceTypes().getSelectedItem().getId()); } }
private static void assertGetResult(VmTemplate result) { assertNotNull(result); assertEquals(FixturesTool.VM_TEMPLATE_RHEL5, result.getId()); assertEquals(1, result.getDbGeneration(), "Template generation wasn't loaded as expected"); }
@Override public void oSType_SelectedItemChanged() { super.oSType_SelectedItemChanged(); VmTemplate template = getModel().getTemplateWithVersion().getSelectedItem() == null ? null : getModel().getTemplateWithVersion().getSelectedItem().getTemplateVersion(); Integer osType = getModel().getOSType().getSelectedItem(); if ((template != null || !basedOnCustomInstanceType()) && osType != null) { Guid id = basedOnCustomInstanceType() ? template.getId() : getModel().getInstanceTypes().getSelectedItem().getId(); updateVirtioScsiEnabledWithoutDetach(id, osType); } }