@Test public void createIpv4DhcpRelayTest() throws ExecutionException, InterruptedException { DhcpRelayHandler dhcpRelayHandler = new DhcpRelayHandler(dataBroker); List<DhcpRelayCommand> createdIpv4DhcpRelays = dhcpRelayHandler.getCreatedIpv4DhcpRelays(RX_VRF_ID, subnet, vppNodesByL2Fd); createdIpv4DhcpRelays.forEach(dhcpRelayHandler::submitDhcpRelay); Optional<Relay> relayOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION, VppIidFactory.getDhcpRelayIid(DHCP_RELAY_COMMAND.getDhcpBuilder().getKey()), dataBroker.newReadOnlyTransaction()); Assert.assertTrue(relayOptional.isPresent()); Assert.assertEquals(RELAY, relayOptional.get()); }
public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; }
DhcpRelayHandler { public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; } }
DhcpRelayHandler { public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; } DhcpRelayHandler(DataBroker dataBroker); }
DhcpRelayHandler { public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; } DhcpRelayHandler(DataBroker dataBroker); List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); List<DhcpRelayCommand> getDeletedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); boolean submitDhcpRelay(DhcpRelayCommand dhcpRelayCommand); }
DhcpRelayHandler { public List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet, SetMultimap<String, NodeId> vppNodesByL2Fd) { List<DhcpRelayCommand> dhcpRelayCommandsCreated = new ArrayList<>(); if (subnet.getDefaultSubnetGatewayIp() == null) { return dhcpRelayCommandsCreated; } for (String bd : vppNodesByL2Fd.keySet()) { Set<NodeId> vppNodes = vppNodesByL2Fd.get(bd); for (NodeId vppNode : vppNodes) { IpAddress ipAddress = resolveDhcpIpAddress(vppNode, subnet); if (ipAddress != null) { dhcpRelayCommandsCreated.add( getDhcpRelayBuilder(vni_vrfid, subnet, ipAddress, General.Operations.PUT, vppNode).build()); } } } return dhcpRelayCommandsCreated; } DhcpRelayHandler(DataBroker dataBroker); List<DhcpRelayCommand> getCreatedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); List<DhcpRelayCommand> getDeletedIpv4DhcpRelays(long vni_vrfid, Subnet subnet,
        SetMultimap<String, NodeId> vppNodesByL2Fd); boolean submitDhcpRelay(DhcpRelayCommand dhcpRelayCommand);  }