Search in sources :

Example 21 with Messages

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getRequests.

protected List<Requests> getRequests(final Queue<Object> objects, final List<Message> errors) {
    final List<Requests> requests = new ArrayList<>();
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        if (!(obj instanceof Rp)) {
            // if RP obj is missing return error only
            errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.empty()));
            return null;
        }
        final RequestsBuilder rBuilder = new RequestsBuilder();
        final Rp rpObj = (Rp) obj;
        objects.remove();
        if (rpObj.getProcessingRule()) {
            rBuilder.setRp(rpObj);
        } else {
            errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
        }
        final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
        if (!vendorInfo.isEmpty()) {
            rBuilder.setVendorInformationObject(vendorInfo);
        }
        // expansion
        if (rpObj.getPathKey()) {
            // FIXME: this can fail on malformed messages (i.e. objects.isEmpty()), add an explicit check/error
            obj = objects.element();
            if (obj instanceof PathKey) {
                // FIXME: shouldn't we be also removing the object?
                rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) obj).build());
            }
        }
        obj = objects.peek();
        if (!(obj instanceof EndpointsObj)) {
            errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
            return null;
        }
        if (!rpObj.getP2mp()) {
            // p2p
            // FIXME: explicit check for empty/type?
            final EndpointsObj ep = (EndpointsObj) objects.remove();
            final P2pBuilder p2pBuilder = new P2pBuilder();
            if (!ep.getProcessingRule()) {
                errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
            } else {
                p2pBuilder.setEndpointsObj(ep);
            }
            final SegmentComputation segm = getP2PSegmentComputation(p2pBuilder, objects, errors, rpObj);
            if (segm != null) {
                rBuilder.setSegmentComputation(segm);
            }
        } else {
            // p2mp
            final SegmentComputation segm = getP2MPSegmentComputation(objects, errors, rpObj);
            if (segm != null) {
                rBuilder.setSegmentComputation(segm);
            }
        }
        requests.add(rBuilder.build());
    }
    return requests;
}
Also used : ArrayList(java.util.ArrayList) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKey) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) PathKeyExpansionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.PathKeyExpansionBuilder) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) RequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.RequestsBuilder) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj) P2pBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp) SegmentComputation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputation)

Example 22 with Messages

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project bgpcep by opendaylight.

the class PCEPSessionImplTest method testCapabilityNotSupported.

@Test
public void testCapabilityNotSupported() {
    this.session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED);
    Assert.assertEquals(2, this.msgsSend.size());
    Assert.assertTrue(this.msgsSend.get(0) instanceof Pcerr);
    final Pcerr pcErr = (Pcerr) this.msgsSend.get(0);
    final ErrorObject errorObj = pcErr.getPcerrMessage().getErrors().get(0).getErrorObject();
    Assert.assertEquals(PCEPErrors.CAPABILITY_NOT_SUPPORTED, PCEPErrors.forValue(errorObj.getType(), errorObj.getValue()));
    Assert.assertEquals(1, this.session.getMessages().getUnknownMsgReceived().intValue());
    // exceeded max. unknown messages count - terminate session
    Assert.assertTrue(this.msgsSend.get(1) instanceof CloseMessage);
    final CloseMessage closeMsg = (CloseMessage) this.msgsSend.get(1);
    Assert.assertEquals(TerminationReason.TOO_MANY_UNKNOWN_MSGS, TerminationReason.forValue(closeMsg.getCCloseMessage().getCClose().getReason()));
    Mockito.verify(this.channel, Mockito.times(1)).close();
}
Also used : CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.CloseMessage) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject) Test(org.junit.Test)

Example 23 with Messages

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project bgpcep by opendaylight.

the class PCCMockCommon method checkResyncSession.

static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp, final int expectedTotalMessages, final Uint64 startingDBVersion, final Uint64 expectedDBVersion, final TestingSessionListener pceSessionListener) throws Exception {
    assertNotNull(pceSessionListener.getSession());
    assertTrue(pceSessionListener.isUp());
    final List<Message> messages;
    checkReceivedMessages(pceSessionListener, expectedTotalMessages);
    if (startAtNumberLsp.isPresent()) {
        messages = pceSessionListener.messages().subList(startAtNumberLsp.get(), startAtNumberLsp.get() + expectedNumberOfLsp);
    } else {
        messages = pceSessionListener.messages();
    }
    checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
    assertEquals(expectedNumberOfLsp, messages.size());
    final PCEPSession session = pceSessionListener.getSession();
    checkSession(session, DEAD_TIMER, KEEP_ALIVE);
    assertTrue(session.getRemoteTlvs().augmentation(Tlvs1.class).getStateful().augmentation(Stateful1.class).getInitiation());
    final Uint64 pceDBVersion = session.getLocalTlvs().augmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue();
    assertEquals(startingDBVersion, pceDBVersion);
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

ArrayList (java.util.ArrayList)8 LocalPref (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref)6 Messages (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages)6 ErrorMessages (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.error.messages.grouping.ErrorMessages)5 Test (org.junit.Test)4 LocalPrefBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder)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 PcepSessionStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder)4 ReplyTime (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTime)4 MessagesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.MessagesBuilder)3 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message)3 BigInteger (java.math.BigInteger)2 HashSet (java.util.HashSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 IpVersionChoice (org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2