/** * Check if template is special 'Blank' template or its version. * <p>Blank template is recognized by id being {@link org.ovirt.engine.core.compat.Guid#Empty}</p> * @return true if this is Blank template, false otherwise */ public boolean isBlank() { return Guid.Empty.equals(getBaseTemplateId()); } }
private StoragePool findDataCenterById(List<StoragePool> list, Guid id) { if (id == null) { return null; } for (StoragePool dc : list) { if (dc.getId().equals(id)) { return dc; } } return null; }
public Network findNetworkById(Guid networkId) { for (Network network : clusterNetworks) { if (network.getId().equals(networkId)) { return network; } } return null; }
public VmDeviceFeEntity(VmDevice vmDevice, VM vm, boolean beingUnplugged) { if (!vmDevice.getVmId().equals(vm.getId())) { throw new IllegalArgumentException("IDs of VM and device's VM doesn't match."); //$NON-NLS-1$ } this.vmDevice = vmDevice; this.vm = vm; this.beingUnplugged = beingUnplugged; }
private boolean containsDisk(DiskImage snapshotDisk, List<DiskImage> disks) { for (DiskImage disk : disks) { if (disk.getId().equals(snapshotDisk.getId())) { return true; } } return false; }
@Override public void buildDisk() { XmlNodeList list = selectNodes(_document, "//*/Section/Disk"); for (XmlNode node : list) { Guid guid = new Guid(node.attributes.get("ovf:diskId").getValue()); _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().ifPresent(img -> readDisk(node, img)); luns.stream().filter(d -> d.getId().equals(guid)).findFirst().ifPresent(lun -> readLunDisk(node, lun)); } }
public void updateFactor(PolicyUnit policyUnit, Integer factor) { for (int i = 0; i < usedFunctions.size(); i++) { if (usedFunctions.get(i).getFirst().getId().equals(policyUnit.getId())) { usedFunctions.get(i).setSecond(factor); break; } } }
protected org.ovirt.engine.core.common.businessentities.Snapshot getSnapshotById(Guid id) { //TODO: move to 'GetSnapshotBySnapshotId' once Backend supplies it. for (org.ovirt.engine.core.common.businessentities.Snapshot snapshot : getBackendCollection(QueryType.GetAllVmSnapshotsByVmId, new IdQueryParameters(parentId))) { if (snapshot.getId().equals(id)) { return snapshot; } } return null; }
@Override public boolean equals(Object obj) { boolean returnValue = super.equals(obj); if (!returnValue && obj != null && obj instanceof VmTemplate) { returnValue = getId() .equals(((VmTemplate) obj).getId()); } return returnValue; }
public org.ovirt.engine.core.common.businessentities.network.Network lookupNetwork(Guid id, String name) { for (org.ovirt.engine.core.common.businessentities.network.Network entity : getBackendCollection(queryType, getQueryParameters())) { if ((id != null && id.equals(entity.getId())) || (name != null && name.equals(entity.getName()))) { return entity; } } return null; }
protected org.ovirt.engine.core.common.businessentities.VM getEntity() { if (vm != null) { return vm; } for (org.ovirt.engine.core.common.businessentities.VM entity : parent.getEntitiesFromExportDomain()) { if (guid.equals(entity.getId())) { vm = entity; return entity; } } return entityNotFound(); }
protected VmTemplate getEntity() { if (template != null) { return template; } for (VmTemplate entity : parent.getEntitiesFromExportDomain()) { if (guid.equals(entity.getId())) { template = entity; return entity; } } return entityNotFound(); }
private StoragePool getPreviousDataCenter(List<StoragePool> dataCenters) { Guid previousDataCenterId = getProxyHostPropertiesModel().getLastStoragePoolId(); for (StoragePool dataCenter : dataCenters) { if (dataCenter.getId().equals(previousDataCenterId)) { return dataCenter; } } return null; } }));
public DiskImage getImageByDiskId(Guid diskId) { for (DiskImage disk : getEntity().getDiskImages()) { if (disk.getId().equals(diskId)) { return disk; } } return null; }
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; }
public StoragePool getStoragePool() { if (storagePool == null && getStoragePoolId() != null && !Guid.Empty.equals(getStoragePoolId())) { storagePool = storagePoolDao.get(getStoragePoolId()); } return storagePool; }
@Override public boolean equals(Object o) { if (getEntity() == null && !(o instanceof NetworkFilterParameterModel)) { return false; } return getEntity().getId().equals(((NetworkFilterParameterModel) o).getEntity().getId()) && getEntity().getVmInterfaceId().equals(((NetworkFilterParameterModel) o).getEntity().getVmInterfaceId()); }
@Test public void testNUllVmElementForFloatingDisk() { List<DiskVmElement> allDves = dao.getAll(); assertTrue(allDves.stream().noneMatch(dve -> dve.getDiskId().equals(FixturesTool.FLOATING_DISK_ID))); }
/** * Ensures that updating a cluster status works as expected. */ @Test public void testUpdateStatus() { existingNetworkCluster.setStatus(NetworkStatus.NON_OPERATIONAL); dao.updateStatus(existingNetworkCluster); List<NetworkCluster> result = dao.getAll(); assertTrue(result.stream().anyMatch(t -> t.getClusterId().equals(existingNetworkCluster.getClusterId()) && t.getNetworkId().equals(existingNetworkCluster.getNetworkId()) && t.getStatus() == existingNetworkCluster.getStatus())); }