Search in sources :

Example 6 with Path1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1 in project openflowplugin by opendaylight.

the class OpenflowpluginMeterTestCommandProvider method writeMeter.

private void writeMeter(final CommandInterpreter ci, Meter meter, Meter meter1) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
    InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId()));
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void notUsed) {
            ci.println("Status of Group Data Loaded Transaction: success.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 7 with Path1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1 in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method validateReportedLsp.

@Override
protected Lsp validateReportedLsp(final Optional<ReportedLsp> rep, final LspId input) {
    if (!rep.isPresent()) {
        LOG.debug("Node {} does not contain LSP {}", input.getNode(), input.getName());
        return null;
    }
    // it doesn't matter how many lsps there are in the path list, we only need data that is the same in each path
    final Path1 ra = rep.get().getPath().get(0).getAugmentation(Path1.class);
    Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
    final Lsp reportedLsp = ra.getLsp();
    Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
    return reportedLsp;
}
Also used : ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp) Path1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1)

Example 8 with Path1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1 in project bgpcep by opendaylight.

the class Stateful07TopologySessionListener method buildPath.

private Path buildPath(final Reports report, final Srp srp, final Lsp lsp) {
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
    if (report.getPath() != null) {
        pb.fieldsFrom(report.getPath());
    }
    // LSP is mandatory (if there is none, parser will throw an exception)
    // this is to ensure a path will be created at any rate
    final Path1Builder p1Builder = new Path1Builder();
    p1Builder.setLsp(report.getLsp());
    final PathSetupType pst;
    if (srp != null && srp.getTlvs() != null && srp.getTlvs().getPathSetupType() != null) {
        pst = srp.getTlvs().getPathSetupType();
        p1Builder.setPathSetupType(pst);
    } else {
        pst = null;
    }
    pb.addAugmentation(Path1.class, p1Builder.build());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs tlvs = report.getLsp().getTlvs();
    if (tlvs != null) {
        if (tlvs.getLspIdentifiers() != null) {
            pb.setLspId(tlvs.getLspIdentifiers().getLspId());
        } else if (!PSTUtil.isDefaultPST(pst)) {
            pb.setLspId(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId(lsp.getPlspId().getValue()));
        }
    }
    return pb.build();
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.LspId) Preconditions(com.google.common.base.Preconditions) Collections(java.util.Collections) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType) Path1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1Builder) StatefulTlv1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.StatefulTlv1)

Example 9 with Path1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1 in project bgpcep by opendaylight.

the class TopologyProviderTest method testOnReportMessage.

@Test
public void testOnReportMessage() throws ReadFailedException {
    this.listener.onSessionUp(this.session);
    Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", 1L, true);
    this.listener.onMessage(this.session, pcRptMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check sr-path
        final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(1, reportedLsps.size());
        final ReportedLsp lsp = reportedLsps.get(0);
        assertEquals("sr-path1", lsp.getName());
        assertEquals(1, lsp.getPath().get(0).getAugmentation(Path1.class).getPathSetupType().getPst().intValue());
        final List<Subobject> subobjects = lsp.getPath().get(0).getEro().getSubobject();
        assertEquals(1, subobjects.size());
        assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
        return pcc;
    });
    pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", 2L, false);
    this.listener.onMessage(this.session, pcRptMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check second lsp sr-path
        final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(2, reportedLsps.size());
        return pcc;
    });
    pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", 1L, true);
    this.listener.onMessage(this.session, pcRptMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check updated sr-path
        final List<ReportedLsp> reportedLsps = pcc.getReportedLsp();
        assertNotNull(reportedLsps);
        assertEquals(2, reportedLsps.size());
        for (final ReportedLsp rlsp : reportedLsps) {
            if (rlsp.getName().equals("sr-path1")) {
                final List<Subobject> subobjects = rlsp.getPath().get(0).getEro().getSubobject();
                assertEquals(1, subobjects.size());
                assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4Address().getValue());
            }
        }
        return pcc;
    });
}
Also used : ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) SrEroType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.network.topology.topology.node.path.computation.client.reported.lsp.path.ero.subobject.subobject.type.SrEroType) AbstractPCEPSessionTest(org.opendaylight.bgpcep.pcep.topology.provider.AbstractPCEPSessionTest) Test(org.junit.Test)

Example 10 with Path1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1 in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method writeFlow.

private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
    final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
    final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void notUsed) {
            ci.println("Status of Group Data Loaded Transaction: success.");
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error(throwable.getMessage(), throwable);
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)13 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)13 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)12 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)8 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)5 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)5 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)5 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)4 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)4 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)4 ReportedLsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)3 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)3 Path1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1)3 Preconditions (com.google.common.base.Preconditions)2 BigInteger (java.math.BigInteger)2 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)2 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)2 Path1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1Builder)2