private VdsNetworkInterface generateVdsNetworkInterface(String value) { VdsNetworkInterface iface = new VdsNetworkInterface(); setIfaceProperty(iface, value); return iface; }
private static VdsNetworkInterface createVdsNetworkInterfaceWithStaticIp(String ip) { VdsNetworkInterface networkInterface = new VdsNetworkInterface(); networkInterface.setIpv4Address(ip); networkInterface.setIpv4BootProtocol(Ipv4BootProtocol.STATIC_IP); return networkInterface; }
@Test public void serializeVdsNetworkInterface() { VdsNetworkInterface nic = new VdsNetworkInterface(); JsonObjectSerializer serializer = new JsonObjectSerializer(); assertTrue(serializer.serialize(nic).length() > 0); }
private VdsNetworkInterface createNic(String nicName) { VdsNetworkInterface result = new VdsNetworkInterface(); result.setId(Guid.newGuid()); result.setName(nicName); return result; }
/** * Prepares expectations so that any request to get a host by id will return a valid response, including a dummy * host object. */ private void setUpVerifyHostExpectations() { QueryReturnValue result = new QueryReturnValue(); VDS host = mock(VDS.class); result.setSucceeded(true); result.setReturnValue(host); when(backend.runQuery(eq(QueryType.GetVdsByVdsId), any())).thenReturn(result); QueryReturnValue interfacesByVdsIdResult = new QueryReturnValue(); interfacesByVdsIdResult.setSucceeded(true); VdsNetworkInterface hostNic = new VdsNetworkInterface(); hostNic.setId(HOST_NIC_ID); List<VdsNetworkInterface> hostNics = Collections.singletonList(hostNic); interfacesByVdsIdResult.setReturnValue(hostNics); when(backend.runQuery(eq(QueryType.GetVdsInterfacesByVdsId), any())).thenReturn(interfacesByVdsIdResult); } }
public static VdsNetworkInterface getSlave() { VdsNetworkInterface entity = new VdsNetworkInterface(); entity.setId(SLAVE_GUID); entity.setName(SLAVE_NAME); entity.setNetworkName(NETWORK_NAME); entity.setSpeed(NIC_SPEED); entity.setBondName(MASTER_NAME); entity.setIpv4BootProtocol(IPV4_BOOT_PROTOCOL); entity.setIpv6BootProtocol(IPV6_BOOT_PROTOCOL); return setUpStatistics(entity, SLAVE_GUID); }
public static VdsNetworkInterface getMaster() { VdsNetworkInterface entity = new VdsNetworkInterface(); entity.setId(MASTER_GUID); entity.setName(MASTER_NAME); entity.setNetworkName(NETWORK_NAME); entity.setSpeed(NIC_SPEED); entity.setBonded(true); entity.setIpv4BootProtocol(IPV4_BOOT_PROTOCOL); entity.setIpv6BootProtocol(IPV6_BOOT_PROTOCOL); return setUpStatistics(entity, MASTER_GUID); }
public static VdsNetworkInterface getEntitySpecific(int index) { VdsNetworkInterface entity = new VdsNetworkInterface(); entity.setId(GUIDS[index]); entity.setName(NAMES[index]); entity.setNetworkName(NETWORK_NAME); entity.setSpeed(NIC_SPEED); entity = setUpStatistics(entity, GUIDS[index]); entity.getStatistics().setStatus(NIC_STATUS); entity.setIpv4BootProtocol(IPV4_BOOT_PROTOCOL); entity.setIpv6BootProtocol(IPV6_BOOT_PROTOCOL); return entity; }
@Test public void testCustomNetworkConfigurationMapped() { VdsNetworkInterface entity = new VdsNetworkInterface(); HostNic model = HostNicMapper.map(entity, null); assertFalse(model.isSetCustomConfiguration()); entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(false, true)); model = HostNicMapper.map(entity, null); assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration()); entity.setNetworkImplementationDetails(new VdsNetworkInterface.NetworkImplementationDetails(true, true)); model = HostNicMapper.map(entity, null); assertEquals(entity.getNetworkImplementationDetails().isInSync(), !model.isCustomConfiguration()); }
@BeforeEach public void setUp() { sampleDnsResolverConfiguration = new DnsResolverConfiguration(); sampleDnsResolverConfiguration.setNameServers(Arrays.asList( new NameServer("192.168.1.1"), new NameServer("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))); sampleDnsResolverConfiguration2 = new DnsResolverConfiguration(); sampleDnsResolverConfiguration2.setNameServers(Arrays.asList( new NameServer("192.168.1.2"), new NameServer("2002:0db8:85a3:0000:0000:8a2e:0370:7334"))); sampleDnsResolverConfigurationWithReversedNameServers = reverseNameServersOrder(sampleDnsResolverConfiguration); ifaceQos = new HostNetworkQos(); networkQos = new HostNetworkQos(); iface = new VdsNetworkInterface(); //needed because network is vm network by default iface.setBridged(true); iface.setQos(ifaceQos); iface.setReportedSwitchType(SwitchType.LEGACY); iface.setIpv4DefaultRoute(false); iface.setMtu(getDefaultHostMtu()); network = new Network(); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration); testedNetworkAttachment = new NetworkAttachment(); testedNetworkAttachment.setIpConfiguration(new IpConfiguration()); cluster = new Cluster(); cluster.setCompatibilityVersion(Version.v4_2); cluster.setRequiredSwitchTypeForCluster(SwitchType.LEGACY); }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingVdsInterface = dao.get(FixturesTool.VDS_NETWORK_INTERFACE); newQos = new HostNetworkQos(); newQos.setOutAverageLinkshare(30); newQos.setOutAverageUpperlimit(30); newQos.setOutAverageRealtime(30); newVdsInterface = new VdsNetworkInterface(); newVdsInterface.setStatistics(new VdsNetworkStatistics()); newVdsInterface.setId(Guid.newGuid()); newVdsInterface.setName("eth77"); newVdsInterface.setNetworkName("enginet"); newVdsInterface.setSpeed(1000); newVdsInterface.setType(3); newVdsInterface.setMacAddress("01:C0:81:21:71:17"); newVdsInterface.setIpv4BootProtocol(Ipv4BootProtocol.STATIC_IP); newVdsInterface.setIpv4Address("192.168.122.177"); newVdsInterface.setIpv4Subnet("255.255.255.0"); newVdsInterface.setIpv4Gateway("192.168.122.1"); newVdsInterface.setIpv6BootProtocol(Ipv6BootProtocol.AUTOCONF); newVdsInterface.setIpv6Address("ipv6 address"); newVdsInterface.setIpv6Prefix(666); newVdsInterface.setIpv6Gateway("ipv6 gateway"); newVdsInterface.setMtu(1500); newVdsInterface.setQos(newQos); newVdsStatistics = newVdsInterface.getStatistics(); }