Search in sources :

Example 16 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 OFPluginFlowTest method writeFlow.

static void writeFlow(FlowBuilder flow, InstanceIdentifier<FlowCapableNode> flowNodeIdent) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    final InstanceIdentifier<Flow> path1 = flowNodeIdent.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
    CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
    Futures.addCallback(commitFuture, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void aVoid) {
            LOG.debug("Write of flow on device succeeded.");
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.error("Write of flow on device failed.", 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) 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)

Example 17 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 OpenflowpluginTableFeaturesTestCommandProvider method writeTableFeatures.

private void writeTableFeatures(final CommandInterpreter ci, TableFeatures tableFeatures) {
    ReadWriteTransaction modification = Preconditions.checkNotNull(dataBroker).newReadWriteTransaction();
    KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, 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 : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) TableFeaturesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey) 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 18 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 OpenflowPluginBulkTransactionProvider method writeFlow.

private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, FlowBuilder flow1, FlowBuilder flow2, FlowBuilder flow3, NodeBuilder nodeBuilder) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    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.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
    InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true);
    InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true);
    InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.getKey());
    modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
    modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), 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) {
            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)

Example 19 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 OpenflowPluginBulkTransactionProvider method _removeFlows.

public void _removeFlows(final CommandInterpreter ci) {
    ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
    NodeBuilder tn = createTestNode(ci.nextArgument());
    String flowtype = ci.nextArgument();
    Integer flowcnt = Integer.parseInt(flowtype);
    FlowBuilder tf = null;
    FlowBuilder tf1 = null;
    FlowBuilder tf2 = null;
    FlowBuilder tf3 = null;
    switch(flowcnt) {
        case 1:
            // add case 1
            tf = createTestFlow(tn, "f1", "10");
            tf1 = createTestFlow(tn, "f2", "11");
            tf2 = createTestFlow(tn, "f3", "12");
            tf3 = createTestFlow(tn, "f4", "13");
            break;
        case 2:
            // modify case 1
            tf = createTestFlow(tn, "f82", "10");
            tf1 = createTestFlow(tn, "f83", "11");
            tf2 = createTestFlow(tn, "f84", "12");
            tf3 = createTestFlow(tn, "f85", "13");
            break;
        case 3:
            // add case 2
            tf = createTestFlow(tn, "f3", "3");
            tf1 = createTestFlow(tn, "f4", "4");
            tf2 = createTestFlow(tn, "f5", "5");
            tf3 = createTestFlow(tn, "f6", "6");
            break;
        case 4:
            // modify case 2
            tf = createTestFlow(tn, "f700", "3");
            tf1 = createTestFlow(tn, "f4", "4");
            tf2 = createTestFlow(tn, "f900", "5");
            tf3 = createTestFlow(tn, "f86", "6");
            break;
        case 5:
            // add case 3
            tf = createTestFlow(tn, "f7", "7");
            tf1 = createTestFlow(tn, "f8", "8");
            tf2 = createTestFlow(tn, "f9", "9");
            tf3 = createTestFlow(tn, "f10", "10");
            break;
        case 6:
            // modify case 3
            tf = createTestFlow(tn, "f91", "7");
            tf1 = createTestFlow(tn, "f92", "8");
            tf2 = createTestFlow(tn, "f93", "9");
            tf3 = createTestFlow(tn, "f94", "10");
            break;
        case 7:
            // -ve scenario
            tf = createTestFlow(tn, "f23", "3");
            tf1 = createTestFlow(tn, "f34", "4");
            tf2 = createTestFlow(tn, "f35", "5");
            tf3 = createTestFlow(tn, "f36", "6");
            break;
        case 8:
            // +ve scenario
            // modify case 6 -ve
            tf = createTestFlow(tn, "f23", "3");
            tf1 = createTestFlow(tn, "f99", "4");
            tf2 = createTestFlow(tn, "f100", "5");
            tf3 = createTestFlow(tn, "f101", "6");
            break;
        case 9:
            // modify case 6
            tf = createTestFlow(tn, "f700", "7");
            tf1 = createTestFlow(tn, "f230", "23");
            tf2 = createTestFlow(tn, "f900", "9");
            tf3 = createTestFlow(tn, "f1000", "10");
            break;
        default:
            throw new IllegalArgumentException("Invalid flowtype: " + flowtype);
    }
    InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId())).child(Flow.class, tf.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
    InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId())).child(Flow.class, tf1.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
    InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId())).child(Flow.class, tf2.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path3);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
    InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId())).child(Flow.class, tf3.getKey());
    modification.delete(LogicalDatastoreType.OPERATIONAL, path4);
    modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
    modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
    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) {
            LOG.error(throwable.getMessage(), throwable);
            ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
        }
    }, MoreExecutors.directExecutor());
}
Also used : 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) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) BigInteger(java.math.BigInteger) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)

Example 20 with Path1

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

the class ItmManagerRpcService method getInternalOrExternalInterfaceName.

@Override
public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(GetInternalOrExternalInterfaceNameInput input) {
    RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = RpcResultBuilder.failed();
    BigInteger srcDpn = input.getSourceDpid();
    IpAddress dstIp = input.getDestinationIp();
    InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(dstIp.getValue()), srcDpn.toString(), input.getTunnelType()));
    Optional<ExternalTunnel> optExtTunnel = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
    if (optExtTunnel != null && optExtTunnel.isPresent()) {
        ExternalTunnel extTunnel = optExtTunnel.get();
        GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName());
        resultBld = RpcResultBuilder.success();
        resultBld.withResult(output.build());
    } else {
        Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
        // Look for external tunnels if not look for internal tunnel
        for (DPNTEPsInfo teps : meshedDpnList) {
            TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
            if (dstIp.equals(firstEndPt.getIpAddress())) {
                Optional<InternalTunnel> optTunnel = Optional.absent();
                if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
                    optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), TunnelTypeLogicalGroup.class, dataBroker);
                    LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
                }
                if (!optTunnel.isPresent()) {
                    optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), input.getTunnelType(), dataBroker);
                }
                if (optTunnel.isPresent()) {
                    InternalTunnel tunnel = optTunnel.get();
                    List<String> tunnelInterfaces = tunnel.getTunnelInterfaceNames();
                    if (tunnelInterfaces != null && !tunnelInterfaces.isEmpty()) {
                        GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnelInterfaces.get(0));
                        resultBld = RpcResultBuilder.success();
                        resultBld.withResult(output.build());
                    } else {
                        LOG.error("No tunnel interface found between source DPN {} ans destination IP {}", srcDpn, dstIp);
                    }
                    break;
                } else {
                    LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
                }
            }
        }
    }
    return Futures.immediateFuture(resultBld.build());
}
Also used : GetInternalOrExternalInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) GetInternalOrExternalInterfaceNameOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

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