private void assertHostsListMatch(List<Host> modelHostsList, List<Host> trnsfHostsList) { for (Host host : modelHostsList){ boolean foundInTransformation = false; for (Host otherHost : trnsfHostsList){ if (host.getId().equals(otherHost.getId())){ foundInTransformation = true; break; } } assertTrue(foundInTransformation, "Umatching dedicated host in Placement Policy"); } }
public static void validateIsAttached(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if (action.getHost()==null || action.getHost().getId()==null) { throw new ValidationException("Parameter 'host.id' is mandatory but was not provided."); } }
private void updateIdForSingleHost(Host host, Set<Guid> guidsSet) { if (host.isSetName() && !host.isSetId()){ // find the corresponding host id Guid hostGuid = getHostId(host); if (hostGuid != null) { guidsSet.add(hostGuid); // add hostId element to host host.setId(hostGuid.toString()); } } else if (host.isSetId()){ guidsSet.add(Guid.createGuidFromString(host.getId())); } } }
protected Guid getHostId(Host host) { return host.isSetId() ? asGuid(host.getId()) : getEntity(VDS.class, QueryType.GetVdsByName, new NameQueryParameters(host.getName()), host.getName()).getId(); }
public static void validateRefreshLun(Action action) { if (action == null) { throw new ValidationException("Action is mandatory but was not provided."); } if ( (action.getHost()==null || action.getHost().getId()==null) && (action.getHost()==null || action.getHost().getName()==null) ) { throw new ValidationException("Parameters 'host.id' or 'host.name' are mandatory but both were not provided."); } }
private HostNic clone(HostNic parent) { HostNic nic = new HostNic(); nic.setId(parent.getId()); nic.setHost(new Host()); nic.getHost().setId(parent.getHost().getId()); return nic; } };
private Guid getHostId(Host host) { // presence of host ID or name already validated return host.isSetId() ? new Guid(host.getId()) : host.isSetName() ? getEntity(VdsStatic.class, QueryType.GetVdsStaticByName, new NameQueryParameters(host.getName()), "Hosts: name=" + host.getName()).getId() : null; } }
private NumaNode clone(NumaNode parent) { NumaNode node = new NumaNode(); node.setId(parent.getId()); node.setHost(new Host()); node.getHost().setId(parent.getHost().getId()); return node; } }
private Response performCreate(ImageTransfer imageTransfer, TransferDiskImageParameters params) { updateTransferType(imageTransfer, params); if (imageTransfer.isSetHost() && imageTransfer.getHost().isSetId()) { params.setVdsId(Guid.createGuidFromString(imageTransfer.getHost().getId())); } if (imageTransfer.isSetInactivityTimeout()) { params.setClientInactivityTimeout(imageTransfer.getInactivityTimeout()); } return performCreate(ActionType.TransferDiskImage, params, new QueryIdResolver<Guid>(QueryType.GetImageTransferById, IdQueryParameters.class)); }
private Guid getHostId(StorageDomain storageDomain) { // presence of host ID or name already validated return storageDomain.getHost().isSetId() ? new Guid(storageDomain.getHost().getId()) : storageDomain.getHost().isSetName() ? getEntity(VdsStatic.class, QueryType.GetVdsStaticByName, new NameQueryParameters(storageDomain.getHost().getName()), "Hosts: name=" + storageDomain.getHost().getName()).getId() : null; }
@Test public void testUpdateHostPinningPolicy() { final VmStatic vmTemplate = new VmStatic(); vmTemplate.setDedicatedVmForVdsList(Guid.newGuid()); final Vm vm = new Vm(); vm.setPlacementPolicy(createPlacementPolicy(Guid.newGuid(), Guid.newGuid())); final VmStatic mappedVm = VmMapper.map(vm, vmTemplate); final List<Guid> hosts = new ArrayList<>(); for (Host host : vm.getPlacementPolicy().getHosts().getHosts()){ hosts.add(Guid.createGuidFromString(host.getId())); } assertEquals(new HashSet(hosts), new HashSet(mappedVm.getDedicatedVmForVdsList())); }
static void verifyModelSpecific(Host model, int index) { assertEquals(GUIDS[index].toString(), model.getId()); assertEquals(NAMES[index], model.getName()); assertEquals(ADDRESSES[index], model.getAddress()); assertEquals(HOST_STATUS[index], model.getStatus()); } }
@Test public void testMapHostId() { org.ovirt.engine.core.common.businessentities.VM entity = new org.ovirt.engine.core.common.businessentities.VM(); entity.setStatus(VMStatus.Up); Guid guid = Guid.newGuid(); entity.setRunOnVds(guid); Vm model = VmMapper.map(entity, (Vm) null); assertEquals(guid.toString(), model.getHost().getId()); }
@Override protected void verifyModel(ExternalNetworkProviderConfiguration model, int index) { assertEquals(HexUtils.string2hex(GUIDS[index].toString()), model.getId()); assertEquals(GUIDS[index+1].toString(), model.getHost().getId()); assertEquals(GUIDS[index].toString(), model.getExternalNetworkProvider().getId()); verifyLinks(model); }
@Override protected void verifyModel(ExternalNetworkProviderConfiguration model, int index) { assertEquals(HexUtils.string2hex(GUIDS[index].toString()), model.getId()); assertEquals(GUIDS[index+1].toString(), model.getHost().getId()); assertEquals(GUIDS[index].toString(), model.getExternalNetworkProvider().getId()); verifyLinks(model); } }
@Test public void testSubjectEntities() { org.ovirt.engine.core.common.job.Step bllStep = createBLLStep(); Guid executionHostId = Guid.newGuid(); bllStep.setSubjectEntities( Arrays.asList(new StepSubjectEntity(bllStep.getId(), VdcObjectType.EXECUTION_HOST, executionHostId), new StepSubjectEntity(bllStep.getId(), VdcObjectType.Disk, Guid.Empty))); Step model = StepMapper.map(bllStep, null); assertNotNull(model.getExecutionHost()); assertEquals(executionHostId.toString(), model.getExecutionHost().getId()); bllStep = StepMapper.map(model, null); assertNull(bllStep.getSubjectEntities(), "subject entities shouldn't be mapped back to the model"); }
protected void verifyQuery(AbstractStatisticalQuery<Host, VDS> query, VDS entity) throws Exception { assertEquals(Host.class, query.getParentType()); assertSame(entity, query.resolve(GUIDS[0])); List<Statistic> statistics = query.getStatistics(entity); verifyStatistics(statistics, new String[] {"memory.total", "memory.used", "memory.free", "memory.shared", "memory.buffers", "memory.cached", "swap.total", "swap.free", "swap.used", "swap.cached", "ksm.cpu.current", "cpu.current.user", "cpu.current.system", "cpu.current.idle", "cpu.load.avg.5m", "boot.time"}, new BigDecimal[] {asDec(5120*Mb), asDec(1024*Mb), asDec(4096*Mb), asDec(38*Mb), asDec(0), asDec(0), asDec(30*Mb), asDec(25*Mb), asDec(5*Mb), asDec(0), asDec(40), asDec(45), asDec(50), asDec(55), new BigDecimal(0.0060, new MathContext(2)), asDec(0)}); Statistic adopted = query.adopt(new Statistic()); assertTrue(adopted.isSetHost()); assertEquals(GUIDS[0].toString(), adopted.getHost().getId()); }
@Override protected void verify(Host model, Host transform) { assertNotNull(transform); assertEquals(model.getName(), transform.getName()); assertEquals(model.getComment(), transform.getComment()); assertEquals(model.getId(), transform.getId()); assertNotNull(transform.getCluster()); assertEquals(model.getCluster().getId(), transform.getCluster().getId()); assertEquals(model.getAddress(), transform.getAddress()); assertEquals(model.getPort(), transform.getPort()); assertEquals(model.getSpm().getPriority(), transform.getSpm().getPriority()); assertEquals(model.getDisplay().getAddress(), transform.getDisplay().getAddress()); }
protected static void verifyHostDevice(HostDevice device) { assertEquals(VM_ID.toString(), device.getVm().getId()); assertEquals(HOST_ID.toString(), device.getHost().getId()); assertEquals(DEVICE_NAME, device.getName()); assertEquals(DEVICE_NAME, HexUtils.hex2string(device.getId())); assertEquals(PARENT_NAME, HexUtils.hex2string(device.getParentDevice().getId())); assertEquals(NAMES[0], device.getProduct().getName()); assertEquals(NAMES[1], device.getVendor().getName()); } }