Search in sources :

Example 1 with GracefulRestartBuilder

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder in project bgpcep by opendaylight.

the class NeighborUtilTest method buildAfisSafisState.

@Test
public void buildAfisSafisState() {
    assertEquals(Collections.emptyMap(), NeighborUtil.buildAfisSafisState(this.bgpAfiSafiState, this.tableRegistry));
    final GracefulRestart graceful = new GracefulRestartBuilder().setState(new StateBuilder().addAugmentation(new NeighborAfiSafiGracefulRestartStateAugmentationBuilder().setAdvertised(false).setReceived(false).setLlReceived(false).setLlAdvertised(false).setLlStaleTimer(Uint32.ZERO).build()).build()).build();
    final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State afiSafiState = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().addAugmentation(new NeighborAfiSafiStateAugmentationBuilder().setActive(false).build()).build();
    this.afiSafi = IPV4UNICAST.class;
    final AfiSafi expected = new AfiSafiBuilder().setAfiSafiName(this.afiSafi).setState(afiSafiState).setGracefulRestart(graceful).build();
    assertEquals(Collections.singletonMap(expected.key(), expected), NeighborUtil.buildAfisSafisState(this.bgpAfiSafiState, this.tableRegistry));
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder) NeighborAfiSafiGracefulRestartStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiGracefulRestartStateAugmentationBuilder) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GracefulRestart(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestart) NeighborAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiStateAugmentationBuilder) Test(org.junit.Test)

Example 2 with GracefulRestartBuilder

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method getGracefulRestartTimerTest.

@Test
public void getGracefulRestartTimerTest() {
    final int neighborTimer = 5;
    final int peerGroupTimer = 10;
    Neighbor neighbor = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setGracefulRestart(new GracefulRestartBuilder().setConfig(createGracefulConfig(Uint16.valueOf(neighborTimer))).build()).build();
    PeerGroup peerGroup = new PeerGroupBuilder().setPeerGroupName("foo").setGracefulRestart(new GracefulRestartBuilder().setConfig(createGracefulConfig(Uint16.valueOf(peerGroupTimer))).build()).build();
    // both timers present, pick peer group one
    int timer = OpenConfigMappingUtil.getGracefulRestartTimer(neighbor, peerGroup, HOLDTIMER);
    assertEquals(peerGroupTimer, timer);
    // peer group missing graceful restart, use neighbor timer
    timer = OpenConfigMappingUtil.getGracefulRestartTimer(neighbor, EMPTY_PEERGROUP, HOLDTIMER);
    assertEquals(neighborTimer, timer);
    // graceful restart enabled but timer not set, use hold time
    peerGroup = new PeerGroupBuilder().setPeerGroupName("bar").setGracefulRestart(new GracefulRestartBuilder().setConfig(createGracefulConfig(null)).build()).build();
    timer = OpenConfigMappingUtil.getGracefulRestartTimer(EMPTY_NEIGHBOR, peerGroup, HOLDTIMER);
    assertEquals(HOLDTIMER, timer);
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) PeerGroup(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder) Test(org.junit.Test)

Example 3 with GracefulRestartBuilder

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder in project netvirt by opendaylight.

the class BgpConfigurationManager method addGracefulRestart.

public void addGracefulRestart(int staleTime) {
    InstanceIdentifier.InstanceIdentifierBuilder<GracefulRestart> iib = InstanceIdentifier.builder(Bgp.class).child(GracefulRestart.class);
    InstanceIdentifier<GracefulRestart> iid = iib.build();
    GracefulRestart dto = new GracefulRestartBuilder().setStalepathTime((long) staleTime).build();
    update(iid, dto);
}
Also used : GracefulRestart(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Bgp(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestartBuilder)

Example 4 with GracefulRestartBuilder

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder in project bgpcep by opendaylight.

the class GracefulRestartUtilTest method getLlGracefulTimersTest.

@Test
public void getLlGracefulTimersTest() {
    final List<AfiSafi> afiSafi = new ArrayList<>();
    afiSafi.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setGracefulRestart(new GracefulRestartBuilder().setConfig(new ConfigBuilder().addAugmentation(new Config1Builder().setLlGracefulRestart(new LlGracefulRestartBuilder().setConfig(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.ll.graceful.restart.rev181112.afi.safi.ll.graceful.restart.ll.graceful.restart.ConfigBuilder().setLongLivedStaleTime(new Uint24(Uint32.valueOf(STALE_TIME))).build()).build()).build()).build()).build()).build());
    final Map<TablesKey, Integer> llGracefulTimers = GracefulRestartUtil.getLlGracefulTimers(afiSafi, this.tableRegistry);
    assertNotNull(llGracefulTimers);
    assertEquals(1, llGracefulTimers.size());
    assertEquals(STALE_TIME, llGracefulTimers.get(IPV4_KEY).intValue());
}
Also used : Assert.assertNotNull(org.junit.Assert.assertNotNull) Config1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.ll.graceful.restart.rev181112.Config1Builder) Collections(java.util.Collections) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) ArrayList(java.util.ArrayList) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder) LlGracefulRestartBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.ll.graceful.restart.rev181112.afi.safi.ll.graceful.restart.LlGracefulRestartBuilder) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.ConfigBuilder) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) LlGracefulRestartBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.ll.graceful.restart.rev181112.afi.safi.ll.graceful.restart.LlGracefulRestartBuilder) Mockito.doReturn(org.mockito.Mockito.doReturn) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) Test(org.junit.Test)

Example 5 with GracefulRestartBuilder

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder in project bgpcep by opendaylight.

the class StateProviderImplTest method buildAfiSafis.

private static AfiSafis buildAfiSafis() {
    final NeighborAfiSafiStateAugmentationBuilder neighborAfiSafiStateAugmentation = new NeighborAfiSafiStateAugmentationBuilder().setActive(true).setPrefixes(new PrefixesBuilder().setSent(Uint32.ONE).setReceived(Uint32.TWO).setInstalled(Uint32.ONE).build());
    final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setGracefulRestart(new GracefulRestartBuilder().setState(new StateBuilder().setEnabled(false).addAugmentation(new NeighborAfiSafiGracefulRestartStateAugmentationBuilder().setAdvertised(true).setReceived(true).setLlStaleTimer(Uint32.valueOf(60)).setLlAdvertised(true).setLlReceived(true).build()).build()).build()).setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().setEnabled(false).addAugmentation(neighborAfiSafiStateAugmentation.build()).build()).build();
    return new AfiSafisBuilder().setAfiSafi(Map.of(afiSafi.key(), afiSafi)).build();
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder) NeighborAfiSafiGracefulRestartStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiGracefulRestartStateAugmentationBuilder) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) NeighborAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiStateAugmentationBuilder) PrefixesBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder) AfiSafisBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)

Aggregations

Test (org.junit.Test)3 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)3 AfiSafiBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder)3 GracefulRestartBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder)3 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder)2 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)2 NeighborAfiSafiGracefulRestartStateAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiGracefulRestartStateAugmentationBuilder)2 NeighborAfiSafiStateAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAfiSafiStateAugmentationBuilder)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1 GracefulRestart (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestart)1 ConfigBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.ConfigBuilder)1 PrefixesBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder)1 GracefulRestartBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestartBuilder)1 AfiSafisBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder)1 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)1 NeighborBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder)1 PeerGroup (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup)1