Adding OpenConfig YANG models.

Change-Id: I0a2fdd5826e80933cf4b9ae939ff3051acec02aa
diff --git a/models/openconfig/src/main/yang/network-instance/openconfig-network-instance-types.yang b/models/openconfig/src/main/yang/network-instance/openconfig-network-instance-types.yang
new file mode 100644
index 0000000..bcbe8ca
--- /dev/null
+++ b/models/openconfig/src/main/yang/network-instance/openconfig-network-instance-types.yang
@@ -0,0 +1,255 @@
+module openconfig-network-instance-types {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/network-instance-types";
+
+  prefix "oc-ni-types";
+
+  import openconfig-extensions { prefix "oc-ext"; }
+
+  // meta
+  organization "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "Types associated with a network instance";
+
+  oc-ext:openconfig-version "0.8.0";
+
+  revision "2017-02-28" {
+    description
+      "Add OSPFv2 to network instance";
+    reference "0.8.0";
+  }
+
+  revision "2017-01-26" {
+    description
+      "Add policy forwarding to network instance";
+    reference "0.7.0";
+  }
+
+  revision "2017-01-13" {
+    description
+      "Add AFT to the network instance";
+    reference "0.6.0";
+  }
+
+  revision "2016-12-15" {
+    description
+      "Add segment routing to network instance";
+    reference "0.5.0";
+  }
+
+  revision "2016-11-10" {
+    description
+      "Update model to include IS-IS.";
+    reference "0.4.1";
+  }
+
+  revision "2016-10-12" {
+    description
+      "Update table connections";
+    reference "0.4.0";
+  }
+
+  revision "2016-09-28" {
+    description
+      "Change L2 instance to submodule; add MAC table";
+    reference "0.3.0";
+  }
+
+  revision "2016-08-11" {
+    description
+      "Resolve repeated container names in routing protocols";
+    reference "0.2.3";
+  }
+
+  revision "2016-07-08" {
+    description
+      "Updated with refactored routing protocol models";
+    reference "0.2.1";
+  }
+
+  revision "2016-03-29" {
+    description
+      "Initial revision";
+    reference "0.2.0";
+  }
+
+  revision "2015-10-18" {
+    description
+      "Initial revision";
+    reference "0.1.0";
+  }
+
+  // identity statements
+  identity NETWORK_INSTANCE_TYPE {
+  	description
+  	 "A base identity which can be extended to indicate different
+     types of network instance supported by a device.";
+  }
+
+  identity DEFAULT_INSTANCE {
+    base NETWORK_INSTANCE_TYPE;
+    description
+      "A special routing instance which acts as the 'default' or
+      'global' routing instance for a network device.";
+  }
+
+  identity L3VRF {
+    base NETWORK_INSTANCE_TYPE;
+    description
+      "A private Layer 3 only routing instance which is formed of
+      one or more RIBs";
+  }
+
+  identity L2VSI {
+    base NETWORK_INSTANCE_TYPE;
+    description
+      "A private Layer 2 only switch instance which is formed of
+      one or more L2 forwarding tables";
+  }
+
+  identity L2P2P {
+    base NETWORK_INSTANCE_TYPE;
+    description
+      "A private Layer 2 only forwarding instance which acts as
+      a point to point connection between two endpoints";
+  }
+
+  identity L2L3 {
+    base NETWORK_INSTANCE_TYPE;
+    description
+      "A private Layer 2 and Layer 2 forwarding instance";
+  }
+
+  identity ENDPOINT_TYPE {
+    description
+      "Specification of the type of endpoint that is being associated
+      with a network instance";
+  }
+
+  identity LOCAL {
+    base ENDPOINT_TYPE;
+    description
+      "A local interface which is being associated with the endpoint";
+  }
+
+  identity REMOTE {
+    base ENDPOINT_TYPE;
+    description
+      "A remote interface which is being associated with the
+      endpoint";
+  }
+
+  identity LABEL_ALLOCATION_MODE {
+    description
+      "Base identity to be used to express types of label allocation
+      strategies to be used within a network instance";
+  }
+
+  identity PER_PREFIX {
+    base LABEL_ALLOCATION_MODE;
+    description
+      "A label is to be allocated per prefix entry in the RIB for the
+      network instance";
+  }
+
+  identity PER_NEXTHOP {
+    base LABEL_ALLOCATION_MODE;
+    description
+      "A label is to be allocated per nexthop entry in the RIB for
+      the network instance";
+  }
+
+  identity INSTANCE_LABEL {
+    base LABEL_ALLOCATION_MODE;
+    description
+      "A single label is to be used for the instance";
+  }
+
+  identity ENCAPSULATION {
+    description
+      "On the wire encapsulations that can be used when
+      differentiating network instances";
+  }
+
+  identity MPLS {
+    base ENCAPSULATION;
+    description
+      "Use MPLS labels to distinguish network instances on the wire";
+  }
+
+  identity VXLAN {
+    base ENCAPSULATION;
+    description
+      "Use VXLAN (RFC7348) VNIs to distinguish network instances on
+      the wire";
+  }
+
+  identity SIGNALLING_PROTOCOL {
+    description
+      "The signalling protocol that should be used to diseminate
+      entries within a forwarding instance";
+  }
+
+  identity LDP {
+    base SIGNALLING_PROTOCOL;
+    description
+      "Use LDP-based setup for signalling. Where the instance is
+      a point-to-point service this refers to RFC4447 ('Martini')
+      setup. Where the service is an L2VSI, or L2L3 instance it
+      refers to RFC4762 LDP-signalled VPLS instances";
+  }
+
+  identity BGP_VPLS {
+    base SIGNALLING_PROTOCOL;
+    description
+      "Use BGP-based signalling and autodiscovery for VPLS instances
+      as per RFC4761";
+  }
+
+  identity BGP_EVPN {
+    base SIGNALLING_PROTOCOL;
+    description
+      "Use BGP-based Ethernet VPN (RFC7432) based signalling for
+      the network instance";
+  }
+
+  // rjs note:
+  // this should move to openconfig-types when merged
+  typedef route-distinguisher {
+    type union {
+      // type 0: <2-byte administrator>:<4-byte assigned number>
+      type string {
+        pattern '^(65[0-5][0-3][0-5]|[1-5][1-5][0-9][0-9][0-9]|'
+                + '[1-9]?[1-9]?[0-9][0-9]|[1-9]):'
+                + '(4[0-2][0-9][0-4][0-9][0-6][0-7][0-2][0-9][0-5]|'
+                + '[0-3][0-9]{9}|[1-9][0-9]{1,8}|[1-9])$';
+      }
+      // type 1: <ip-address>:<2-byte assigned number>
+      type string {
+        pattern
+          '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+          +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]):'
+          +  '(65[0-5][0-3][0-5]|[1-5][1-5][0-9][0-9][0-9]|'
+          +  '[1-9]?[1-9]?[0-9][0-9]|[1-9])$';
+      }
+      // type 2: <4-byte as-number>:<2-byte assigned number>
+      type string {
+        pattern
+          '^(4[0-2][0-9][0-4][0-9][0-6][0-7][0-2][0-9][0-5]|'
+          + '[0-3][0-9]{9}|[1-9][0-9]{1,8}|[1-9]):'
+          + '(65[0-5][0-3][0-5]|[1-5]{2}[0-9]{3}|'
+          + '[1-9]{0,2}[0-9][0-9]|[1-9])$';
+      }
+    }
+    description "A route distinguisher value";
+    reference "RFC4364";
+  }
+}