Search in sources :

Example 1 with LocalPref

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref in project bgpcep by opendaylight.

the class PCEPSessionState method getLocalPref.

private static LocalPref getLocalPref(final Open open, final Channel channel) {
    final LocalPrefBuilder peerBuilder = new LocalPrefBuilder();
    peerBuilder.setDeadtimer(open.getDeadTimer());
    peerBuilder.setKeepalive(open.getKeepalive());
    peerBuilder.setIpAddress(((InetSocketAddress) channel.localAddress()).getAddress().getHostAddress());
    peerBuilder.setSessionId(open.getSessionId().intValue());
    return peerBuilder.build();
}
Also used : LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder) InetSocketAddress(java.net.InetSocketAddress)

Example 2 with LocalPref

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref in project bgpcep by opendaylight.

the class LocalPreferenceAttributeParser method serializeAttribute.

@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
    Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
    final LocalPref lp = ((Attributes) attribute).getLocalPref();
    if (lp == null) {
        return;
    }
    AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, Unpooled.copyInt(lp.getPref().intValue()), byteAggregator);
}
Also used : LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPref) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)

Example 3 with LocalPref

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref in project bgpcep by opendaylight.

the class PeerUtil method createUpdate.

static Update createUpdate(final BgpOrigin bgpOrigin, final List<Segments> pathSegments, // FIXME: consider using Uint32
final long preference, final MpReachNlri mpReach, final MpUnreachNlri mpUnreach) {
    final Origin origin = new OriginBuilder().setValue(bgpOrigin).build();
    final AsPath asPath = new AsPathBuilder().setSegments(pathSegments).build();
    final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(preference)).build();
    final AttributesBuilder attributeBuilder = new AttributesBuilder().setOrigin(origin).setAsPath(asPath).setLocalPref(localPref);
    if (mpReach != null) {
        attributeBuilder.addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReach).build());
    }
    if (mpUnreach != null) {
        attributeBuilder.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreach).build());
    }
    return new UpdateBuilder().setAttributes(new AttributesBuilder().setOrigin(origin).setAsPath(asPath).setLocalPref(localPref).addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReach).build()).build()).build();
}
Also used : Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin) BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder) AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref) AttributesReachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReachBuilder) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)

Example 4 with LocalPref

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref in project bgpcep by opendaylight.

the class PCEPSessionImplTest method testSessionStatistics.

@Test
public void testSessionStatistics() {
    this.session.handleMessage(Util.createErrorMessage(PCEPErrors.LSP_RSVP_ERROR, null));
    Assert.assertEquals(this.ipAddress, this.session.getPeerPref().getIpAddress());
    final PeerPref peerPref = this.session.getPeerPref();
    Assert.assertEquals(this.ipAddress, peerPref.getIpAddress());
    Assert.assertEquals(DEADTIMER, peerPref.getDeadtimer());
    Assert.assertEquals(KEEP_ALIVE, peerPref.getKeepalive());
    Assert.assertEquals(0, peerPref.getSessionId().intValue());
    final LocalPref localPref = this.session.getLocalPref();
    Assert.assertEquals(this.ipAddress, localPref.getIpAddress());
    Assert.assertEquals(DEADTIMER, localPref.getDeadtimer());
    Assert.assertEquals(KEEP_ALIVE, localPref.getKeepalive());
    Assert.assertEquals(0, localPref.getSessionId().intValue());
    final Messages msgs = this.session.getMessages();
    Assert.assertEquals(1, msgs.getReceivedMsgCount().longValue());
    Assert.assertEquals(0, msgs.getSentMsgCount().longValue());
    Assert.assertEquals(0, msgs.getUnknownMsgReceived().longValue());
    final ErrorMessages errMsgs = msgs.getErrorMessages();
    Assert.assertEquals(1, errMsgs.getReceivedErrorMsgCount().intValue());
    Assert.assertEquals(0, errMsgs.getSentErrorMsgCount().intValue());
    Assert.assertEquals(PCEPErrors.LSP_RSVP_ERROR.getErrorType(), errMsgs.getLastReceivedError().getErrorType());
    Assert.assertEquals(PCEPErrors.LSP_RSVP_ERROR.getErrorValue(), errMsgs.getLastReceivedError().getErrorValue());
    this.session.sendMessage(Util.createErrorMessage(PCEPErrors.UNKNOWN_PLSP_ID, null));
    final Messages msgs2 = this.session.getMessages();
    Assert.assertEquals(1, msgs2.getReceivedMsgCount().longValue());
    Assert.assertEquals(1, msgs2.getSentMsgCount().longValue());
    Assert.assertEquals(0, msgs2.getUnknownMsgReceived().longValue());
    final ErrorMessages errMsgs2 = msgs2.getErrorMessages();
    Assert.assertEquals(1, errMsgs2.getReceivedErrorMsgCount().intValue());
    Assert.assertEquals(1, errMsgs2.getSentErrorMsgCount().intValue());
    Assert.assertEquals(PCEPErrors.UNKNOWN_PLSP_ID.getErrorType(), errMsgs2.getLastSentError().getErrorType());
    Assert.assertEquals(PCEPErrors.UNKNOWN_PLSP_ID.getErrorValue(), errMsgs2.getLastSentError().getErrorValue());
}
Also used : ErrorMessages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) ErrorMessages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) PeerPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref) Test(org.junit.Test)

Example 5 with LocalPref

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref in project bgpcep by opendaylight.

the class PcepStateUtils method displayNodeState.

private static void displayNodeState(final String topologyId, final String nodeId, final PcepSessionState pcepSessionState, final PrintStream stream) {
    final ShellTable table = new ShellTable();
    table.column("Attribute").alignLeft();
    table.column("Value").alignLeft();
    showNodeState(table, topologyId, nodeId, pcepSessionState);
    addHeader(table, "Local preferences");
    final LocalPref localPref = pcepSessionState.getLocalPref();
    showPreferences(table, localPref);
    final PcepEntityIdStatsAug entAug = localPref.augmentation(PcepEntityIdStatsAug.class);
    if (entAug != null) {
        table.addRow().addContent("Speaker Entity Identifier", Arrays.toString(entAug.getSpeakerEntityIdValue()));
    }
    addHeader(table, "Peer preferences");
    final PeerPref peerPref = pcepSessionState.getPeerPref();
    showPreferences(table, peerPref);
    showCapabilities(table, pcepSessionState.getPeerCapabilities());
    final Messages messages = pcepSessionState.getMessages();
    showMessages(table, messages);
    final ErrorMessages error = messages.getErrorMessages();
    showErrorMessages(table, error);
    final ReplyTime reply = messages.getReplyTime();
    showReplyMessages(table, reply);
    table.print(stream);
}
Also used : ErrorMessages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages) PcepEntityIdStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdStatsAug) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) ErrorMessages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) PeerPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref) ReplyTime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTime)

Aggregations

LocalPref (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref)8 Messages (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages)6 ReplyTime (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTime)6 ErrorMessages (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages)5 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder)5 Test (org.junit.Test)4 MessagesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder)4 PeerCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilities)4 PeerCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilitiesBuilder)4 PeerPref (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref)4 PcepSessionStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder)4 AsPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath)3 LocalPref (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPref)3 Origin (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin)3 BgpOrigin (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin)3 StatefulMessagesStatsAug (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulMessagesStatsAug)3 ErrorMessagesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessagesBuilder)3 PeerPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPrefBuilder)3 ReplyTimeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTimeBuilder)3 Collections (java.util.Collections)2