Search in sources :

Example 21 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testBandwidthObject.

@Test
public void testBandwidthObject() throws IOException, PCEPDeserializerException {
    final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
    final BandwidthBuilder builder = new BandwidthBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : PCEPBandwidthObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ByteBuf(io.netty.buffer.ByteBuf) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder) Test(org.junit.Test)

Example 22 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project bgpcep by opendaylight.

the class PathComputationImpl method computeEro.

@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
    VertexKey source = getSourceVertexKey(endpoints);
    VertexKey destination = getDestinationVertexKey(endpoints);
    if (source == null) {
        return null;
    }
    if (destination == null) {
        return null;
    }
    /* Create new Constraints Object from the request */
    PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
    /* Determine Path Computation Algorithm according to parameters */
    AlgorithmType algoType;
    if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
        algoType = AlgorithmType.Spf;
    } else if (cts.getDelay() == null) {
        algoType = AlgorithmType.Cspf;
    } else {
        algoType = AlgorithmType.Samcra;
    }
    PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
    if (algo == null) {
        return null;
    }
    /*
         * Request Path Computation for given source, destination and
         * constraints
         */
    final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
    LOG.info("Computed ERO: {}", cpath.getPathDescription());
    /* Check if we got a valid Path and return appropriate ERO */
    if (cpath.getStatus() == ComputationStatus.Completed) {
        return MessagesUtil.getEro(cpath.getPathDescription());
    } else {
        return null;
    }
}
Also used : AlgorithmType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.AlgorithmType) ConstrainedPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath) VertexKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey) PathComputationAlgorithm(org.opendaylight.algo.PathComputationAlgorithm) PathConstraints(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.PathConstraints)

Example 23 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project bgpcep by opendaylight.

the class NodeChangedListenerTest method createNode.

private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final Uint32 lspId, final String dstIpv4Address) throws InterruptedException, ExecutionException {
    final NodeBuilder nodeBuilder = new NodeBuilder();
    nodeBuilder.withKey(new NodeKey(nodeId));
    nodeBuilder.setNodeId(nodeId);
    final PathBuilder pathBuilder = new PathBuilder();
    pathBuilder.withKey(new PathKey(new LspId(lspId)));
    pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
    pathBuilder.addAugmentation(new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4AddressNoZone(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
    final ReportedLsp reportedLps = new ReportedLspBuilder().withKey(new ReportedLspKey(lspName)).setPath(BindingMap.of(pathBuilder.build())).build();
    final Node1Builder node1Builder = new Node1Builder();
    node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(BindingMap.of(reportedLps)).setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(ipv4Address))).build());
    nodeBuilder.addAugmentation(node1Builder.build());
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
    wTx.commit().get();
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiersBuilder) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1Builder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4Builder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder) PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathKey) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.TlvsBuilder) Ipv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4CaseBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ReportedLspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspBuilder) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Path1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1Builder) ReportedLspKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey) Ipv4ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 24 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project bgpcep by opendaylight.

the class BandwidthObjectParser method localParseObject.

@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
    final BasicBandwidthObjectBuilder builder = new BasicBandwidthObjectBuilder();
    final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
    builder.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)));
    return builder.build();
}
Also used : BasicBandwidthObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObjectBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ByteBuf(io.netty.buffer.ByteBuf)

Example 25 with Bandwidth

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth in project bgpcep by opendaylight.

the class BandwidthObjectParser method localSerializeObject.

@Override
public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
    Preconditions.checkArgument(teLspObject instanceof BasicBandwidthObject, "BandwidthObject is mandatory.");
    final BasicBandwidthObject bandObject = (BasicBandwidthObject) teLspObject;
    serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
    final Bandwidth band = bandObject.getBandwidth();
    output.writeBytes(Unpooled.wrappedBuffer(band.getValue()));
}
Also used : BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObject) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)

Aggregations

Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)27 ByteBuf (io.netty.buffer.ByteBuf)16 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 QosPolicy (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)7 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth)4 BandwidthBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder)4 Preconditions (com.google.common.base.Preconditions)3 Collections (java.util.Collections)3 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)3 ExtendedCommunities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities)3 ExtendedCommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunitiesBuilder)3 MetricsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder)3 ExecutionException (java.util.concurrent.ExecutionException)2 Before (org.junit.Before)2 ConnectedEdge (org.opendaylight.graph.ConnectedEdge)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 QosNetworkExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension)2