module topology-tunnel {
    yang-version 1;
    namespace "urn:opendaylight:params:xml:ns:yang:topology:tunnel";
    prefix "tt";

    import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
    import network-topology { prefix nt; revision-date 2013-10-21; }

    organization "Cisco Systems, Inc.";
    contact "Robert Varga <rovarga@cisco.com>";

    description
        "This module contains the tunnel extension of the base topology
        model. A tunnel is a link between two nodes, which is not a
        direct adjacency, but rather is formed by one or more paths
        routed through the network.

        Copyright (c)2013 Cisco Systems, Inc. All rights reserved.

        This program and the accompanying materials are made available
        under the terms of the Eclipse Public License v1.0 which
        accompanies this distribution, and is available at
        http://www.eclipse.org/legal/epl-v10.html";

    revision "2013-08-19" {
        description
            "Initial revision.";
        reference "";
    }

    typedef path-id {
        type inet:uri;
        description
            "Identifier of a single path. The identifier does not
             carry any semantic meaning beyond uniquely identifying
             a path.";
    }

    typedef path-ref {
        type leafref {
            path "/nt:network-topology/nt:topology/paths/path-id";
        }
    }

    grouping topology-tunnel-type {
        container topology-tunnel {
            presence "indicates a tunnel-aware topology";
        }
    }

    augment "/nt:network-topology/nt:topology/nt:topology-types" {
        uses topology-tunnel-type;
    }

    augment "/nt:network-topology/nt:topology" {
        when "../../nt:topology-types/topology-tunnel";

        list "paths" {
            config false;

            leaf path-id {
                type path-id;
            }
            key path-id;

            container path-types {
                description
                    "A path can have multiple traits, each
                     of which is indicated by a presence
                     container under this one. Such
                     containers should not carry any data.";
            }
        }
    }

    grouping tunnel-link-attributes {
        description
            "A topology link which is actually a tunnel has
             additional attributes.";

        container tunnel-types {
            config false;

            description
                "A tunnel can have multiple traits, each of
                 which is indicated by a presence container
                 under this one. Such containers should not
                 carry any data.";
        }

        leaf-list paths {
            description
                "List of paths associated with this tunnel.
                 The exact relationship between the tunnel
                 and these paths is technology-specific.";

            config false;
            type path-ref;
        }
    }

    augment "/nt:network-topology/nt:topology/nt:link" {
        when "../../nt:topology-types/topology-tunnel";
        uses tunnel-link-attributes;
    }
}