MD-SAL:Concepts

MD-SAL is set of model-driven infrastructure services which uses YANG as their modeling language.

RPC

In YANG, RPCs (Remote Procedure Calls) are used to model any procedure call implemented by a Provider (Server), which exposes functionality to Consumers (Clients).
In the MD-SAL terminology, the term 'RPC' is used to define the input and output for a procedure (function), which is to be provided by a Provider and adapted by the MD-SAL.
In context of the MD-SAL, there are three types of RPCs (RPC services):
  • Global - one service instance (implementation) per controller container / mount point
  • Routed - multiple service instances (implementations) per controller container / mount point
  • Mounted - multiple service instances, uniquely identified in the yang data tree.

Instance Identifier

The Instance Identifier is a unique identifier of an element (location) in the yang data tree; basically it is the path to the node that uniquely identifies all the node's parent nodes. For unique identification of list elements it is required to specify key values as well.
MD-SAL currently provides three different APIs to access data in the common data store:

Example

Consider the following simple YANG model for inventory:
module inventory {
    namespace "urn:opendaylight:inventory";
    prefix inv;
    revision "2013-06-07";
    container nodes {
        list node {
            key "id";
            leaf "id" {
                type "string";
            }
        }
    }
}
And having one instance of node with name foo;
Lets asume we want to create instance identifier for node foo, in following bindings/ formats:
  • YANG / XML / XPath version
    /inv:nodes/inv:node[id="foo"]
  • Binding-Aware version (generated APIs)
    import org.opendaylight.yang.gen.urn.opendaylight.inventory.rev130607.Nodes;
    import org.opendaylight.yang.gen.urn.opendaylight.inventory.rev130607.nodes.Node;
    import org.opendaylight.yang.gen.urn.opendaylight.inventory.rev130607.nodes.NodeKey;
    
    import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
    
    InstanceIdentifier<Node> identifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey("foo")).toInstance();
    
    Note: Last call toInstance() does not return an instance of node, but Java version of Instance identifier which uniquely identifies node "foo";
  • Binding Independent version (yang-data-api)
    import org.opendaylight.yang.common.QName;
    import org.opendaylight.yang.data.api.InstanceIdentifier;
    
    QName nodes = QName.create("urn:opendaylight:inventory","2013-06-07","nodes");
    QName node = QName.create("urn:opendaylight:inventory","2013-06-07","node");
    QName idName = QName.create("urn:opendaylight:inventory","2013-06-07","id");
    InstanceIdentifier = InstanceIdentifier.builder()
        .node(nodes)
        .nodeWithKey(node,idName,"foo")
        .toInstance();
    Note: Last call toInstance() does not return an instance of node, but Java version of Instance identifier which uniquely identifies node "foo";

  • HTTP Restconf APIs
  • http://localhost:8080/restconf/config/inventory:nodes/node/foo
    
    Note: We assume that HTTP APIs are exposed on localhost, port 8080

评论

此博客中的热门博文

openflow switch(I)

YANG Tools:YANG to Java Mapping

OpenDaylight架构简介