ONOS-5454 [TE Tunnel NBI ] Interact with tetunnel APP to provide CRUD interfaces for RESTconf request

Change-Id: I5b2dad9d65c72cb9adc7f313272319ea8046a6a8
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang
new file mode 100755
index 0000000..40374fe
--- /dev/null
+++ b/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang
@@ -0,0 +1,882 @@
+module ietf-te {
+
+  namespace "urn:ietf:params:xml:ns:yang:ietf-te";
+
+  /* Replace with IANA when assigned */
+  prefix "te";
+
+  /* Import TE generic types */
+  import ietf-te-types {
+    prefix te-types;
+  }
+
+  import ietf-inet-types {
+    prefix inet;
+  }
+
+  organization
+    "IETF Traffic Engineering Architecture and Signaling (TEAS)
+     Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/teas/>
+     WG List:  <mailto:teas@ietf.org>
+
+     WG Chair: Lou Berger
+               <mailto:lberger@labn.net>
+
+     WG Chair: Vishnu Pavan Beeram
+               <mailto:vbeeram@juniper.net>
+
+     Editor:   Tarek Saad
+               <mailto:tsaad@cisco.com>
+
+     Editor:   Rakesh Gandhi
+               <mailto:rgandhi@cisco.com>
+
+     Editor:   Vishnu Pavan Beeram
+               <mailto:vbeeram@juniper.net>
+
+     Editor:   Himanshu Shah
+               <mailto:hshah@ciena.com>
+
+     Editor:   Xufeng Liu
+               <mailto:xufeng.liu@ericsson.com>
+
+     Editor:   Xia Chen
+               <mailto:jescia.chenxia@huawei.com>
+
+     Editor:   Raqib Jones
+               <mailto:raqib@Brocade.com>
+
+     Editor:   Bin Wen
+               <mailto:Bin_Wen@cable.comcast.com>";
+
+  description
+    "YANG data module for TE configuration,
+    state, RPC and notifications.";
+
+  revision "2016-07-05" {
+    description "Latest update to TE generic YANG module.";
+    reference "TBD";
+  }
+
+  typedef tunnel-ref {
+    type leafref {
+      path "/te:te/te:tunnels/te:tunnel/te:name";
+    }
+    description
+      "This type is used by data models that need to reference
+       configured TE tunnel.";
+  }
+
+  /**
+   * TE tunnel generic groupings
+   */
+
+  grouping p2p-secondary-path-params {
+    description
+      "tunnel path properties.";
+    container config {
+      description
+        "Configuration parameters relating to
+        tunnel properties";
+      uses path-properties_config;
+      uses path-params_config;
+    }
+    container state {
+      config false;
+      description
+        "State information associated with tunnel
+        properties";
+      uses path-properties_config;
+      uses path-params_config;
+      uses p2p-secondary-path-params_state;
+    }
+  }
+
+  grouping p2p-primary-path-params {
+    description
+      "TE tunnel primary path properties grouping";
+    container config {
+      description
+        "Configuration parameters relating to
+        tunnel properties";
+      uses path-properties_config;
+      uses path-params_config;
+    }
+    container state {
+      config false;
+      description
+        "State information associated with tunnel
+        properties";
+      uses path-params_config;
+      uses p2p-primary-path-params_state;
+    }
+  }
+
+  grouping p2p-primary-path-params_state {
+    description "TE primary path state parameters";
+    list lsp {
+      key
+        "source destination tunnel-id lsp-id "+
+        "extended-tunnel-id type";
+      description "List of LSPs associated with the tunnel.";
+
+      leaf source {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/source";
+        }
+        description
+          "Tunnel sender address extracted from
+          SENDER_TEMPLATE  object";
+        reference "RFC3209";
+      }
+      leaf destination {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/destination";
+        }
+        description
+          "Tunnel endpoint address extracted from
+          SESSION object";
+        reference "RFC3209";
+      }
+      leaf tunnel-id {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/tunnel-id";
+        }
+        description
+          "Tunnel identifier used in the SESSION
+          that remains constant over the life
+          of the tunnel.";
+        reference "RFC3209";
+      }
+      leaf lsp-id {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/lsp-id";
+        }
+        description
+          "Identifier used in the SENDER_TEMPLATE
+          and the FILTER_SPEC that can be changed
+          to allow a sender to share resources with
+          itself.";
+        reference "RFC3209";
+      }
+      leaf extended-tunnel-id {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/extended-tunnel-id";
+        }
+        description
+          "Extended Tunnel ID of the LSP.";
+        reference "RFC3209";
+      }
+      leaf type {
+        type leafref {
+          path "../../../../../../lsps-state/lsp/type";
+        }
+        description "LSP type P2P or P2MP";
+      }
+    }
+  }
+
+  grouping p2p-secondary-path-params_state {
+    description "TE secondary path state parameters";
+    list lsp {
+      key "source";
+      description "List of LSPs associated with the tunnel.";
+
+      leaf source {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/source";
+        }
+        description
+          "Tunnel sender address extracted from
+          SENDER_TEMPLATE  object";
+        reference "RFC3209";
+      }
+      leaf destination {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/destination";
+        }
+        description
+          "Tunnel endpoint address extracted from
+          SESSION object";
+        reference "RFC3209";
+      }
+      leaf tunnel-id {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/tunnel-id";
+        }
+        description
+          "Tunnel identifier used in the SESSION
+          that remains constant over the life
+          of the tunnel.";
+        reference "RFC3209";
+      }
+      leaf lsp-id {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/lsp-id";
+        }
+        description
+          "Identifier used in the SENDER_TEMPLATE
+          and the FILTER_SPEC that can be changed
+          to allow a sender to share resources with
+          itself.";
+        reference "RFC3209";
+      }
+      leaf extended-tunnel-id {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/extended-tunnel-id";
+        }
+        description
+          "Extended Tunnel ID of the LSP.";
+        reference "RFC3209";
+      }
+      leaf type {
+        type leafref {
+          path "../../../../../../../lsps-state/lsp/type";
+        }
+        description "LSP type P2P or P2MP";
+      }
+    }
+  }
+
+  grouping path-params_config {
+    description
+      "TE tunnel path parameters configuration grouping";
+    leaf path-named-constraint {
+      if-feature te-types:named-path-constraints;
+      type string;
+      description
+        "Reference to a globally defined named path
+        constraint set";
+    }
+    uses te-types:tunnel-path-selection;
+    choice type {
+      description
+        "Describes the path type";
+      case dynamic {
+        leaf dynamic {
+          type empty;
+          description
+            "A CSPF dynamically computed path";
+        }
+      }
+      case explicit {
+        leaf explicit-path-name {
+          type string;
+          description
+            "The explicit-path name";
+        }
+
+        list explicit-route-objects {
+          key "index";
+          description
+            "List of explicit route objects";
+          leaf index {
+            type uint8 {
+              range "0..255";
+            }
+            description
+              "Index of this explicit route object";
+          }
+          leaf explicit-route-usage {
+            type identityref {
+              base te-types:route-usage-type;
+            }
+            description "An explicit-route hop action.";
+          }
+          uses te-types:explicit-route-subobject;
+        }
+      }
+    }
+    leaf no-cspf {
+      type empty;
+      description
+        "Indicates no CSPF is to be attempted on this
+        path.";
+    }
+    leaf lockdown {
+      type empty;
+      description
+        "Indicates no reoptimization to be attempted for
+        this path.";
+    }
+  }
+
+  /* TE tunnel configuration data */
+  grouping tunnel-params_config {
+    description
+      "Configuration parameters relating to TE tunnel";
+    leaf name {
+      type string;
+      description "TE tunnel name.";
+    }
+    leaf type {
+      type identityref {
+        base te-types:tunnel-type;
+      }
+      description "TE tunnel type.";
+    }
+    leaf identifier {
+      type uint16;
+      description
+        "TE tunnel Identifier.";
+    }
+    leaf description {
+      type string;
+      description
+        "Textual description for this TE tunnel";
+    }
+    leaf lsp-priority-setup {
+      type uint8 {
+        range "0..7";
+      }
+      description
+        "TE LSP setup priority";
+    }
+    leaf lsp-priority-hold {
+      type uint8 {
+        range "0..7";
+      }
+      description
+        "TE LSP hold priority";
+    }
+    leaf lsp-protection-type {
+      type identityref {
+        base te-types:lsp-prot-type;
+      }
+      description "LSP protection type.";
+    }
+    leaf admin-status {
+      type identityref {
+        base te-types:state-type;
+      }
+      default te-types:state-up;
+      description "TE tunnel administrative state.";
+    }
+    leaf source {
+      type inet:ip-address;
+      description
+        "TE tunnel source address.";
+    }
+    leaf destination {
+      /* Add when check */
+      type inet:ip-address;
+      description
+        "P2P tunnel destination address";
+    }
+    leaf src-tp-id {
+      type binary;
+      description
+        "TE tunnel source termination point identifier.";
+    } 
+    leaf dst-tp-id {
+      /* Add when check */
+      type binary;
+      description
+        "TE tunnel destination termination point identifier.";
+    }
+    container hierarchical-link-id {
+        description
+          "Identifies a hierarchical link (in server layer)
+           that this tunnel is associated with.";
+        leaf local-te-node-id {
+          type te-types:te-node-id;
+          description
+            "Local TE node identifier";
+        }
+        leaf local-te-link-tp-id {
+          type te-types:te-tp-id;
+          description
+            "Local TE link termination point identifier";
+        }
+        leaf remote-te-node-id {
+          type te-types:te-node-id;
+          description
+            "Remote TE node identifier";
+        }
+        leaf te-topology-id {
+          type te-types:te-topology-id;
+          description
+            "It is presumed that a datastore will contain many
+             topologies. To distinguish between topologies it is
+             vital to have UNIQUE topology identifiers.";
+        }
+    }
+    uses te-types:tunnel-bidir-assoc-properties;
+  }
+
+  grouping tunnel-params_state {
+    description
+      "State parameters relating to TE tunnel";
+    leaf oper-status {
+      type identityref {
+        base te-types:state-type;
+      }
+      description "TE tunnel operational state.";
+    }
+  }
+
+  grouping path-properties_config {
+    description "TE path properties grouping";
+    leaf name {
+      type string;
+      description "TE path name";
+    }
+    leaf preference {
+      type uint8 {
+        range "1..255";
+      }
+      description
+        "Specifies a preference for this path. The lower the
+        number higher the preference";
+    }
+  }
+
+  /* TE tunnel configuration/state grouping */
+  grouping tunnel-properties {
+    description
+      "Top level grouping for tunnel properties.";
+    container config {
+      description
+        "Configuration parameters relating to
+         tunnel properties";
+      uses tunnel-params_config;
+    }
+    container state {
+      config false;
+      description
+        "State information associated with tunnel
+         properties";
+      uses tunnel-params_config;
+      uses tunnel-params_state;
+    }
+    list primary-paths {
+      key "name";
+      description
+        "List of primary paths for this tunnel.";
+      leaf name {
+        type leafref {
+          path "../config/name";
+        }
+        description "TE path name";
+      }
+      leaf preference {
+        type leafref {
+          path "../config/preference";
+        }
+        description
+          "Specifies a preference for this path. The lower the
+           number higher the preference";
+      }
+      uses p2p-primary-path-params;
+      list secondary-paths {
+        key "name";
+        description
+          "List of secondary paths for this tunnel.";
+        leaf name {
+          type leafref {
+            path "../config/name";
+          }
+          description "TE path name";
+        }
+        leaf preference {
+          type leafref {
+            path "../config/preference";
+          }
+          description
+            "Specifies a preference for this path. The lower the
+            number higher the preference";
+        }
+        uses p2p-secondary-path-params;
+      }
+    }
+  }
+  /*** End of TE tunnel groupings ***/
+
+  /**
+   * LSP related generic groupings
+   */
+  grouping lsp-record-route-information_state {
+    description "recorded route information grouping";
+    container lsp-record-route {
+      description "RSVP recorded route object information";
+      list record-route-subobjects {
+        when "../origin-type != 'ingress'" {
+          description "Applicable on non-ingress LSPs only";
+        }
+        key "subobject-index";
+        description "";
+        leaf subobject-index {
+          type uint32;
+          description "RRO subobject index";
+        }
+        uses te-types:record-route-subobject;
+      }
+    }
+  }
+
+  grouping lsp-properties_state {
+    description
+      "State parameters relating to LSP";
+    leaf oper-status {
+      type identityref {
+        base te-types:state-type;
+      }
+      description "LSP operational state.";
+    }
+
+    leaf origin-type {
+      type enumeration {
+        enum ingress {
+          description
+            "Origin ingress";
+        }
+        enum egress {
+          description
+            "Origin egress";
+        }
+        enum transit {
+          description
+            "transit";
+        }
+      }
+      description
+        "Origin type of LSP relative to the location 
+        of the local switch in the path.";
+    }
+
+    leaf lsp-resource-status {
+      type enumeration {
+        enum primary {
+          description
+            "A primary LSP is a fully established LSP for
+             which the resource allocation has been committed
+             at the data plane";
+        }
+        enum secondary {
+          description
+            "A secondary LSP is an LSP that has been provisioned
+             in the control plane only; e.g. resource allocation
+             has not been committed at the data plane";
+        }
+      }
+      description "LSP resource allocation type";
+      reference "rfc4872, section 4.2.1";
+    }
+
+    leaf lsp-protection-role {
+      type enumeration {
+        enum working {
+          description
+            "A working LSP must be a primary LSP whilst a protecting
+             LSP can be either a primary or a secondary LSP. Also,
+             known as protected LSPs when working LSPs are associated
+             with protecting LSPs.";
+        }
+        enum protecting {
+          description
+            "A secondary LSP is an LSP that has been provisioned
+             in the control plane only; e.g. resource allocation
+             has not been committed at the data plane";
+        }
+      }
+      description "LSP role type";
+      reference "rfc4872, section 4.2.1";
+    }
+
+    leaf lsp-operational-status {
+      type empty;
+      description
+        "This bit is set when a protecting LSP is carrying the normal
+         traffic after protection switching";
+    }
+  }
+  /*** End of TE LSP groupings ***/
+
+  /**
+   * TE global generic groupings
+   */
+
+  /* Global named admin-groups configuration data */
+  grouping named-admin-groups_config {
+    description
+      "Global named administrative groups configuration
+      grouping";
+    list named-admin-groups {
+      if-feature te-types:extended-admin-groups;
+      if-feature te-types:named-extended-admin-groups;
+      key "name";
+      description
+        "List of named TE admin-groups";
+      leaf name {
+        type string;
+        description
+          "A string name that uniquely identifies a TE
+          interface named admin-group";
+      }
+      leaf bit-position {
+        type uint32;
+        description
+          "Bit position representing the administrative group";
+      }
+    }
+  }
+
+  /* Global named admin-srlgs configuration data */
+  grouping named-srlgs_config {
+    description
+      "Global named SRLGs configuration
+      grouping";
+    list named-srlgs {
+      if-feature te-types:named-srlg-groups;
+      key "name";
+      description
+        "A list of named SRLG groups";
+      leaf name {
+        type string;
+        description
+          "A string name that uniquely identifies a TE
+          interface named srlg";
+      }
+      leaf group {
+        type te-types:srlg;
+        description "An SRLG value";
+      }
+    }
+  }
+
+  /* Global named explicit-paths configuration data */
+  grouping named-explicit-paths_config {
+    description
+      "Global explicit path configuration
+      grouping";
+    list named-explicit-paths {
+      key "name";
+      description
+        "A list of explicit paths";
+      leaf name {
+        type string;
+        description
+          "A string name that uniquely identifies an
+          explicit path";
+      }
+      list explicit-route-objects {
+        key "index";
+        description
+          "List of explicit route objects";
+        leaf index {
+          type uint8 {
+            range "0..255";
+          }
+          description
+            "Index of this explicit route object";
+        }
+        leaf explicit-route-usage {
+          type identityref {
+            base te-types:route-usage-type;
+          }
+          description "An explicit-route hop action.";
+        }
+        uses te-types:explicit-route-subobject;
+      }
+    }
+  }
+
+  /* Global named paths constraints configuration data */
+  grouping named-path-constraints_config {
+    description
+      "Global named path constraints configuration
+      grouping";
+    list named-constraints {
+      if-feature te-types:named-path-constraints;
+      key "name";
+      description
+        "A list of named path constraints";
+      leaf name {
+        type string;
+        description
+          "A string name that uniquely identifies a
+          path constraint set";
+      }
+      uses te-types:tunnel-path-selection;
+    }
+  }
+
+  /* TE globals container data */
+  grouping globals-grouping {
+    description
+      "Globals TE system-wide configuration data grouping";
+    container globals {
+      description
+        "Globals TE system-wide configuration data container";
+      container config {
+        description
+          "Configuration parameters for system-wide
+           parameters";
+        uses named-admin-groups_config;
+        uses named-srlgs_config;
+        uses named-explicit-paths_config;
+        uses named-path-constraints_config;
+      }
+      container state {
+        config false;
+        description
+          "State for system-wide parameters";
+        uses named-admin-groups_config;
+        uses named-srlgs_config;
+        uses named-explicit-paths_config;
+        uses named-path-constraints_config;
+      }
+    }
+  }
+
+  /* TE tunnels container data */
+  grouping tunnels-grouping {
+    description
+      "Tunnels TE configuration data grouping";
+    container tunnels {
+      description
+        "Tunnels TE configuration data container";
+
+      list tunnel {
+        key "name type";
+        unique "identifier";
+        description "TE tunnel.";
+        leaf name {
+          type leafref {
+            path "../config/name";
+          }
+          description "TE tunnel name.";
+        }
+        leaf type {
+          type leafref {
+            path "../config/type";
+          }
+          description "TE tunnel type.";
+        }
+        leaf identifier {
+          type leafref {
+            path "../config/identifier";
+          }
+          description
+            "TE tunnel Identifier.";
+        }
+        uses tunnel-properties;
+      }
+    }
+  }
+
+  /* TE LSPs ephemeral state container data */
+  grouping lsps-state-grouping {
+    description
+      "LSPs state operational data grouping";
+    container lsps-state {
+      config "false";
+      description "LSPs operational state data.";
+
+      list lsp {
+        key
+          "source destination tunnel-id lsp-id "+
+          "extended-tunnel-id type";
+        description
+          "List of LSPs associated with the tunnel.";
+        leaf source {
+          type inet:ip-address;
+          description
+            "Tunnel sender address extracted from
+            SENDER_TEMPLATE  object";
+          reference "RFC3209";
+        }
+        leaf destination {
+          type inet:ip-address;
+          description
+            "Tunnel endpoint address extracted from
+            SESSION object";
+          reference "RFC3209";
+        }
+        leaf tunnel-id {
+          type uint16;
+          description
+            "Tunnel identifier used in the SESSION
+            that remains constant over the life
+            of the tunnel.";
+          reference "RFC3209";
+        }
+        leaf lsp-id {
+          type uint16;
+          description
+            "Identifier used in the SENDER_TEMPLATE
+            and the FILTER_SPEC that can be changed
+            to allow a sender to share resources with
+            itself.";
+          reference "RFC3209";
+        }
+        leaf extended-tunnel-id {
+          type inet:ip-address;
+           description
+            "Extended Tunnel ID of the LSP.";
+          reference "RFC3209";
+        }
+        leaf type {
+          type identityref {
+            base te-types:tunnel-type;
+          }
+          description "The LSP type P2P or P2MP";
+        }
+        uses lsp-properties_state;
+        uses lsp-record-route-information_state;
+      }
+    }
+  }
+  /*** End of TE global groupings ***/
+
+  /**
+   * TE configurations container
+   */
+  container te {
+    presence "Enable TE feature.";
+    description
+       "TE global container.";
+
+    /* TE Global Configuration Data */
+    uses globals-grouping;
+
+    /* TE Tunnel Configuration Data */
+    uses tunnels-grouping;
+
+    /* TE LSPs State Data */
+    uses lsps-state-grouping;
+  }
+
+  /* TE Global RPCs/execution Data */
+  rpc globals-rpc {
+    description
+      "Execution data for TE global.";
+  }
+
+  /* TE interfaces RPCs/execution Data */
+  rpc interfaces-rpc {
+    description
+      "Execution data for TE interfaces.";
+  }
+
+  /* TE Tunnel RPCs/execution Data */
+  rpc tunnels-rpc {
+    description
+      "TE tunnels RPC nodes";
+  }
+
+  /* TE Global Notification Data */
+  notification globals-notif {
+    description
+      "Notification messages for Global TE.";
+  }
+
+  /* TE Tunnel Notification Data */
+  notification tunnels-notif {
+    description
+      "Notification messages for TE tunnels.";
+  }
+}