Bug 5029: Support draft-openconfig-rtgwg-network-instance 10/38510/5
authorMilos Fabian <milfabia@cisco.com>
Tue, 3 May 2016 15:56:11 +0000 (17:56 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 20 May 2016 18:39:20 +0000 (18:39 +0000)
To allow configuration of multiple BGP instances with
OpenConfig API, use openconfig-network-instance's top-level node.
The model supports multiple instances of a protocol (i.e. BGP)
to be confugured under one network instance.
Augmented the yang data model with openconfig-bgp top-levle node
as described in
https://tools.ietf.org/html/draft-openconfig-rtgwg-network-instance-01#section-2

Change-Id: I89fbee03317d198b81ce2518047d77bc7d09d137
Signed-off-by: Milos Fabian <milfabia@cisco.com>
bgp/openconfig-api/pom.xml
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-openconfig-extensions.yang
bgp/openconfig-api/src/main/yang/openconfig-interfaces.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/openconfig-local-routing.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/openconfig-network-instance-types.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/openconfig-network-instance.yang [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilderTest.java [new file with mode: 0644]

index 89b6a81bed200f085f705307b3878a56a96b3e00..56850700d6ea2f2e976f3b2267d87960b227aee4 100644 (file)
             <groupId>org.opendaylight.mdsal.model</groupId>
             <artifactId>ietf-yang-types-20130715</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-interfaces</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>yang-binding</artifactId>
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilder.java
new file mode 100644 (file)
index 0000000..29fe690
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
+ */
+
+package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.local.routing.rev151009;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.local.routing.rev151009.LocalStaticConfig.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+
+/**
+*
+* Helper builder utility for {@code NextHop} union type.
+*
+*/
+public final class LocalStaticConfigNextHopBuilder {
+
+    private LocalStaticConfigNextHopBuilder() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static NextHop getDefaultInstance(final String defaultValue) {
+        try {
+            final LocalDefinedNextHop nextHopEnum = LocalDefinedNextHop.valueOf(defaultValue.toUpperCase());
+            return new NextHop(nextHopEnum);
+        } catch (final IllegalArgumentException e) {
+            try {
+                final IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(defaultValue);
+                return new NextHop(ipAddress);
+            } catch (final IllegalArgumentException e1) {
+                return new NextHop(defaultValue);
+            }
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilder.java
new file mode 100644 (file)
index 0000000..d8b092d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
+ */
+
+package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.types.rev151018;
+
+import java.util.regex.Pattern;
+
+/**
+ *
+ * Helper builder utility for {@code RouteDistinguisher} union type.
+ *
+ */
+public final class RouteDistinguisherBuilder {
+
+    private RouteDistinguisherBuilder() {
+        throw new UnsupportedOperationException();
+    }
+
+    private static final Pattern[] PATTERNS;
+
+    static {
+        final Pattern a[] = new Pattern[RouteDistinguisher.PATTERN_CONSTANTS.size()];
+        int i = 0;
+        for (final String regEx : RouteDistinguisher.PATTERN_CONSTANTS) {
+            a[i++] = Pattern.compile(regEx);
+        }
+
+        PATTERNS = a;
+    }
+
+    public static RouteDistinguisher getDefaultInstance(final String defaultValue) {
+        if (anyMatch(defaultValue)) {
+            return new RouteDistinguisher(defaultValue);
+        } else {
+            throw new IllegalArgumentException("Cannot create RouteDistinguisher from " + defaultValue);
+        }
+    }
+
+    private static boolean anyMatch(final String defaultValue) {
+        for (final Pattern pattern : PATTERNS) {
+            if (pattern.matcher(defaultValue).matches()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}
index 212a599ec6416b3f0633066af7ac04a4434f68d9..e45185404578e2ea9ff503c786994bbde89349b9 100644 (file)
@@ -4,6 +4,8 @@ module bgp-openconfig-extensions {
     prefix "odl-oc-ext";
 
     import openconfig-bgp-types { prefix bgp-types; revision-date 2015-10-09; }
+    import openconfig-network-instance { prefix netinst; }
+    import openconfig-bgp { prefix openconfig-bgp; }
 
     organization "Cisco Systems, Inc.";
     contact "Milos Fabian <milfabia@cisco.com>";
@@ -44,4 +46,8 @@ module bgp-openconfig-extensions {
         reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03";
     }
 
+    augment /netinst:network-instances/netinst:network-instance/netinst:protocols/netinst:protocol {
+        uses openconfig-bgp:bgp-top;
+    }
+
 }
diff --git a/bgp/openconfig-api/src/main/yang/openconfig-interfaces.yang b/bgp/openconfig-api/src/main/yang/openconfig-interfaces.yang
new file mode 100644 (file)
index 0000000..f324e1e
--- /dev/null
@@ -0,0 +1,933 @@
+module openconfig-interfaces {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/interfaces";
+
+  prefix "oc-if";
+
+  // import some basic types
+  import ietf-interfaces { prefix ietf-if; }
+  import ietf-yang-types { prefix yang; }
+  import openconfig-extensions { prefix oc-ext; }
+
+  // meta
+  organization "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "Model for managing network interfaces and subinterfaces.  This
+    module also defines convenience types / groupings for other
+    models to create references to interfaces:
+
+      base-interface-ref (type) -  reference to a base interface
+      interface-ref (grouping) -  container for reference to a
+        interface + subinterface
+      interface-ref-state (grouping) - container for read-only
+        (opstate) reference to interface + subinterface
+
+    This model reuses data items defined in the IETF YANG model for
+    interfaces described by RFC 7223 with an alternate structure
+    (particularly for operational state data) and and with
+    additional configuration items.";
+
+  oc-ext:openconfig-version "1.0.1";
+
+  revision "2016-04-12" {
+    description
+      "OpenConfig public release";
+    reference "1.0.1";
+  }
+
+
+  // typedef statements
+
+  typedef base-interface-ref {
+    type leafref {
+      path "/oc-if:interfaces/oc-if:interface/oc-if:name";
+    }
+    description
+      "Reusable type for by-name reference to a base interface.
+      This type may be used in cases where ability to reference
+      a subinterface is not required.";
+  }
+
+  typedef interface-id {
+    type string;
+    description
+      "User-defined identifier for an interface, generally used to
+      name a interface reference.  The id can be arbitrary but a
+      useful convention is to use a combination of base interface
+      name and subinterface index.";
+  }
+
+  // grouping statements
+
+  grouping interface-ref-common {
+    description
+      "Reference leafrefs to interface / subinterface";
+
+    leaf interface {
+      type leafref {
+        path "/oc-if:interfaces/oc-if:interface/oc-if:name";
+      }
+      description
+        "Reference to a base interface.  If a reference to a
+        subinterface is required, this leaf must be specified
+        to indicate the base interface.";
+    }
+
+    leaf subinterface {
+      type leafref {
+        path "/oc-if:interfaces/" +
+          "oc-if:interface[oc-if:name=current()/../interface]/" +
+          "oc-if:subinterfaces/oc-if:subinterface/oc-if:index";
+      }
+      description
+        "Reference to a subinterface -- this requires the base
+        interface to be specified using the interface leaf in
+        this container.  If only a reference to a base interface
+        is requuired, this leaf should not be set.";
+    }
+  }
+
+  grouping interface-ref-state-container {
+    description
+      "Reusable opstate w/container for a reference to an
+      interface or subinterface";
+
+    container state {
+      config false;
+      description
+        "Operational state for interface-ref";
+
+      uses interface-ref-common;
+    }
+  }
+
+  grouping interface-ref {
+    description
+      "Reusable definition for a reference to an interface or
+      subinterface";
+
+    container interface-ref {
+      description
+        "Reference to an interface or subinterface";
+
+      container config {
+        description
+          "Configured reference to interface / subinterface";
+
+        uses interface-ref-common;
+      }
+
+      uses interface-ref-state-container;
+    }
+  }
+
+  grouping interface-ref-state {
+    description
+      "Reusable opstate w/container for a reference to an
+      interface or subinterface";
+
+    container interface-ref {
+      description
+        "Reference to an interface or subinterface";
+
+      uses interface-ref-state-container;
+    }
+  }
+
+
+  grouping interface-common-config {
+    description
+      "Configuration data data nodes common to physical interfaces
+      and subinterfaces";
+
+    leaf name {
+      type string;
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        The name of the interface.
+
+        A device MAY restrict the allowed values for this leaf,
+        possibly depending on the type of the interface.
+        For system-controlled interfaces, this leaf is the
+        device-specific name of the interface.  The 'config false'
+        list interfaces/interface[name]/state contains the currently
+        existing interfaces on the device.
+
+        If a client tries to create configuration for a
+        system-controlled interface that is not present in the
+        corresponding state list, the server MAY reject
+        the request if the implementation does not support
+        pre-provisioning of interfaces or if the name refers to
+        an interface that can never exist in the system.  A
+        NETCONF server MUST reply with an rpc-error with the
+        error-tag 'invalid-value' in this case.
+
+        The IETF model in RFC 7223 provides YANG features for the
+        following (i.e., pre-provisioning and arbitrary-names),
+        however they are omitted here:
+
+          If the device supports pre-provisioning of interface
+          configuration, the 'pre-provisioning' feature is
+          advertised.
+
+          If the device allows arbitrarily named user-controlled
+          interfaces, the 'arbitrary-names' feature is advertised.
+
+        When a configured user-controlled interface is created by
+        the system, it is instantiated with the same name in the
+        /interfaces/interface[name]/state list.";
+      reference
+        "RFC 7223: A YANG Data Model for Interface Management";
+    }
+
+    leaf description {
+      type string;
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        A textual description of the interface.
+
+        A server implementation MAY map this leaf to the ifAlias
+        MIB object.  Such an implementation needs to use some
+        mechanism to handle the differences in size and characters
+        allowed between this leaf and ifAlias.  The definition of
+        such a mechanism is outside the scope of this document.
+
+        Since ifAlias is defined to be stored in non-volatile
+        storage, the MIB implementation MUST map ifAlias to the
+        value of 'description' in the persistently stored
+        datastore.
+
+        Specifically, if the device supports ':startup', when
+        ifAlias is read the device MUST return the value of
+        'description' in the 'startup' datastore, and when it is
+        written, it MUST be written to the 'running' and 'startup'
+        datastores.  Note that it is up to the implementation to
+
+        decide whether to modify this single leaf in 'startup' or
+        perform an implicit copy-config from 'running' to
+        'startup'.
+
+        If the device does not support ':startup', ifAlias MUST
+        be mapped to the 'description' leaf in the 'running'
+        datastore.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifAlias";
+    }
+
+    leaf enabled {
+      type boolean;
+      default "true";
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        This leaf contains the configured, desired state of the
+        interface.
+
+        Systems that implement the IF-MIB use the value of this
+        leaf in the 'running' datastore to set
+        IF-MIB.ifAdminStatus to 'up' or 'down' after an ifEntry
+        has been initialized, as described in RFC 2863.
+
+        Changes in this leaf in the 'running' datastore are
+        reflected in ifAdminStatus, but if ifAdminStatus is
+        changed over SNMP, this leaf is not affected.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
+    }
+
+  }
+
+  grouping interface-phys-config {
+    description
+      "Configuration data for physical interfaces";
+
+    leaf type {
+      type identityref {
+        base ietf-if:interface-type;
+      }
+      mandatory true;
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        The type of the interface.
+
+        When an interface entry is created, a server MAY
+        initialize the type leaf with a valid value, e.g., if it
+        is possible to derive the type from the name of the
+        interface.
+
+        If a client tries to set the type of an interface to a
+        value that can never be used by the system, e.g., if the
+        type is not supported or if the type does not match the
+        name of the interface, the server MUST reject the request.
+        A NETCONF server MUST reply with an rpc-error with the
+        error-tag 'invalid-value' in this case.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifType";
+    }
+
+    leaf mtu {
+      type uint16;
+      description
+        "Set the max transmission unit size in octets
+        for the physical interface.  If this is not set, the mtu is
+        set to the operational default -- e.g., 1514 bytes on an
+        Ethernet interface.";
+    }
+
+    uses interface-common-config;
+  }
+
+  grouping interface-phys-holdtime-config {
+    description
+      "Configuration data for interface hold-time settings --
+      applies to physical interfaces.";
+
+    leaf up {
+      type uint32;
+      units milliseconds;
+      default 0;
+      description
+        "Dampens advertisement when the interface
+        transitions from down to up.  A zero value means dampening
+        is turned off, i.e., immediate notification.";
+    }
+
+    leaf down {
+      type uint32;
+      units milliseconds;
+      default 0;
+      description
+        "Dampens advertisement when the interface transitions from
+        up to down.  A zero value means dampening is turned off,
+        i.e., immediate notification.";
+    }
+  }
+
+  grouping interface-phys-holdtime-state {
+    description
+      "Operational state data for interface hold-time.";
+  }
+
+  grouping interface-phys-holdtime-top {
+    description
+      "Top-level grouping for setting link transition
+      dampening on physical and other types of interfaces.";
+
+    container hold-time {
+      description
+        "Top-level container for hold-time settings to enable
+        dampening advertisements of interface transitions.";
+
+      container config {
+        description
+          "Configuration data for interface hold-time settings.";
+
+        uses interface-phys-holdtime-config;
+      }
+
+      container state {
+
+        config false;
+
+        description
+          "Operational state data for interface hold-time.";
+
+        uses interface-phys-holdtime-config;
+        uses interface-phys-holdtime-state;
+      }
+    }
+  }
+
+  grouping interface-common-state {
+    description
+      "Operational state data (in addition to intended configuration)
+      at the global level for this interface";
+
+    leaf ifindex {
+      type uint32;
+      description
+        "System assigned number for each interface.  Corresponds to
+        ifIndex object in SNMP Interface MIB";
+      reference
+        "RFC 2863 - The Interfaces Group MIB";
+    }
+
+    leaf admin-status {
+      type enumeration {
+        enum UP {
+          description
+            "Ready to pass packets.";
+        }
+        enum DOWN {
+          description
+            "Not ready to pass packets and not in some test mode.";
+        }
+        enum TESTING {
+          //TODO: This is generally not supported as a configured
+          //admin state, though it's in the standard interfaces MIB.
+          //Consider removing it.
+          description
+            "In some test mode.";
+        }
+      }
+      //TODO:consider converting to an identity to have the
+      //flexibility to remove some values defined by RFC 7223 that
+      //are not used or not implemented consistently.
+      mandatory true;
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        The desired state of the interface.  In RFC 7223 this leaf
+        has the same read semantics as ifAdminStatus.  Here, it
+        reflects the administrative state as set by enabling or
+        disabling the interface.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
+    }
+
+    leaf oper-status {
+      type enumeration {
+        enum UP {
+          value 1;
+          description
+            "Ready to pass packets.";
+        }
+        enum DOWN {
+          value 2;
+          description
+            "The interface does not pass any packets.";
+        }
+        enum TESTING {
+          value 3;
+          description
+            "In some test mode.  No operational packets can
+             be passed.";
+        }
+        enum UNKNOWN {
+          value 4;
+          description
+            "Status cannot be determined for some reason.";
+        }
+        enum DORMANT {
+          value 5;
+          description
+            "Waiting for some external event.";
+        }
+        enum NOT_PRESENT {
+          value 6;
+          description
+            "Some component (typically hardware) is missing.";
+        }
+        enum LOWER_LAYER_DOWN {
+          value 7;
+          description
+            "Down due to state of lower-layer interface(s).";
+        }
+      }
+      //TODO:consider converting to an identity to have the
+      //flexibility to remove some values defined by RFC 7223 that
+      //are not used or not implemented consistently.
+      mandatory true;
+      description
+        "[adapted from IETF interfaces model (RFC 7223)]
+
+        The current operational state of the interface.
+
+         This leaf has the same semantics as ifOperStatus.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifOperStatus";
+    }
+
+    leaf last-change {
+      type yang:timeticks;
+      description
+        "Date and time of the last state change of the interface
+        (e.g., up-to-down transition).   This corresponds to the
+        ifLastChange object in the standard interface MIB.";
+      reference
+        "RFC 2863: The Interfaces Group MIB - ifLastChange";
+    }
+
+  }
+
+
+  grouping interface-counters-state {
+    description
+      "Operational state representing interface counters
+      and statistics.  Some of these are adapted from RFC 7223";
+
+      //TODO: we may need to break this list of counters into those
+      //that would appear for physical vs. subinterface or logical
+      //interfaces.  For now, just replicating the full stats
+      //grouping to both interface and subinterface.
+
+    container counters {
+      description
+        "A collection of interface-related statistics objects.";
+
+      reference
+        "RFC 7223 - A YANG Data Model for Interface
+        Management";
+
+      leaf in-octets {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+          The total number of octets received on the interface,
+          including framing characters.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
+      }
+
+      leaf in-unicast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+          The number of packets, delivered by this sub-layer to a
+          higher (sub-)layer, that were not addressed to a
+          multicast or broadcast address at this sub-layer.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
+      }
+
+      leaf in-broadcast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+          The number of packets, delivered by this sub-layer to a
+          higher (sub-)layer, that were addressed to a broadcast
+          address at this sub-layer.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifHCInBroadcastPkts";
+      }
+
+      leaf in-multicast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+
+          The number of packets, delivered by this sub-layer to a
+          higher (sub-)layer, that were addressed to a multicast
+          address at this sub-layer.  For a MAC-layer protocol,
+          this includes both Group and Functional addresses.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifHCInMulticastPkts";
+      }
+
+      leaf in-discards {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          The number of inbound packets that were chosen to be
+          discarded even though no errors had been detected to
+          prevent their being deliverable to a higher-layer
+          protocol.  One possible reason for discarding such a
+          packet could be to free up buffer space.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+
+
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifInDiscards";
+      }
+
+      leaf in-errors {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          For packet-oriented interfaces, the number of inbound
+          packets that contained errors preventing them from being
+          deliverable to a higher-layer protocol.  For character-
+          oriented or fixed-length interfaces, the number of
+          inbound transmission units that contained errors
+          preventing them from being deliverable to a higher-layer
+          protocol.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifInErrors";
+      }
+
+      leaf in-unknown-protos {
+        type yang:counter32;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          For packet-oriented interfaces, the number of packets
+          received via the interface that were discarded because
+          of an unknown or unsupported protocol.  For
+          character-oriented or fixed-length interfaces that
+          support protocol multiplexing, the number of
+          transmission units received via the interface that were
+          discarded because of an unknown or unsupported protocol.
+          For any interface that does not support protocol
+          multiplexing, this counter is not present.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
+      }
+
+      leaf out-octets {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          The total number of octets transmitted out of the
+          interface, including framing characters.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
+      }
+
+      leaf out-unicast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+          The total number of packets that higher-level protocols
+          requested be transmitted, and that were not addressed
+          to a multicast or broadcast address at this sub-layer,
+          including those that were discarded or not sent.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
+      }
+
+      leaf out-broadcast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+
+          The total number of packets that higher-level protocols
+          requested be transmitted, and that were addressed to a
+          broadcast address at this sub-layer, including those
+          that were discarded or not sent.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifHCOutBroadcastPkts";
+      }
+
+
+      leaf out-multicast-pkts {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          The total number of packets that higher-level protocols
+          requested be transmitted, and that were addressed to a
+          multicast address at this sub-layer, including those
+          that were discarded or not sent.  For a MAC-layer
+          protocol, this includes both Group and Functional
+          addresses.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifHCOutMulticastPkts";
+      }
+
+      leaf out-discards {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          The number of outbound packets that were chosen to be
+          discarded even though no errors had been detected to
+          prevent their being transmitted.  One possible reason
+          for discarding such a packet could be to free up buffer
+          space.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
+      }
+
+      leaf out-errors {
+        type yang:counter64;
+        description
+          "[adapted from IETF interfaces model (RFC 7223)]
+          Changed the counter type to counter64.
+
+          For packet-oriented interfaces, the number of outbound
+          packets that could not be transmitted because of errors.
+          For character-oriented or fixed-length interfaces, the
+          number of outbound transmission units that could not be
+          transmitted because of errors.
+
+          Discontinuities in the value of this counter can occur
+          at re-initialization of the management system, and at
+          other times as indicated by the value of
+          'discontinuity-time'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifOutErrors";
+      }
+
+      leaf last-clear {
+        type yang:date-and-time;
+        description
+          "Indicates the last time the interface counters were
+          cleared.";
+      }
+    }
+  }
+
+  // data definition statements
+
+  grouping sub-unnumbered-config {
+    description
+      "Configuration data for unnumbered subinterfaces";
+
+    leaf enabled {
+      type boolean;
+      default false;
+      description
+        "Indicates that the subinterface is unnumbered.  By default
+        the subinterface is numbered, i.e., expected to have an
+        IP address configuration.";
+    }
+  }
+
+  grouping sub-unnumbered-state {
+    description
+      "Operational state data unnumbered subinterfaces";
+  }
+
+  grouping sub-unnumbered-top {
+    description
+      "Top-level grouping unnumbered subinterfaces";
+
+    container unnumbered {
+      description
+        "Top-level container for setting unnumbered interfaces.
+        Includes reference the interface that provides the
+        address information";
+
+      container config {
+        description
+          "Configuration data for unnumbered interface";
+
+        uses sub-unnumbered-config;
+      }
+
+      container state {
+
+        config false;
+
+        description
+          "Operational state data for unnumbered interfaces";
+
+        uses sub-unnumbered-config;
+        uses sub-unnumbered-state;
+      }
+
+      uses oc-if:interface-ref;
+    }
+  }
+
+  grouping subinterfaces-config {
+    description
+      "Configuration data for subinterfaces";
+
+    leaf index {
+      type uint32;
+      default 0;
+      description
+        "The index of the subinterface, or logical interface number.
+        On systems with no support for subinterfaces, or not using
+        subinterfaces, this value should default to 0, i.e., the
+        default subinterface.";
+    }
+
+    uses interface-common-config;
+
+  }
+
+  grouping subinterfaces-state {
+    description
+      "Operational state data for subinterfaces";
+
+    uses interface-common-state;
+    uses interface-counters-state;
+  }
+
+  grouping subinterfaces-top {
+    description
+      "Subinterface data for logical interfaces associated with a
+      given interface";
+
+    container subinterfaces {
+      description
+        "Enclosing container for the list of subinterfaces associated
+        with a physical interface";
+
+      list subinterface {
+        key index;
+
+        description
+          "The list of subinterfaces (logical interfaces) associated
+          with a physical interface";
+
+        leaf index {
+          type leafref {
+            path "../oc-if:config/oc-if:index";
+          }
+          description
+            "The index number of the subinterface -- used to address
+            the logical interface";
+        }
+
+        container config {
+          description
+            "Configurable items at the subinterface level";
+
+          uses subinterfaces-config;
+        }
+
+        container state {
+
+          config false;
+          description
+            "Operational state data for logical interfaces";
+
+          uses subinterfaces-config;
+          uses subinterfaces-state;
+        }
+      }
+    }
+  }
+
+  grouping interfaces-top {
+    description
+      "Top-level grouping for interface configuration and
+      operational state data";
+
+    container interfaces {
+      description
+        "Top level container for interfaces, including configuration
+        and state data.";
+
+
+      list interface {
+        key name;
+
+        description
+          "The list of named interfaces on the device.";
+
+        leaf name {
+          type leafref {
+            path "../oc-if:config/oc-if:name";
+          }
+          description
+            "References the configured name of the interface";
+            //TODO: need to consider whether this should actually
+            //reference the name in the state subtree, which
+            //presumably would be the system-assigned name, or the
+            //configured name.  Points to the config/name now
+            //because of YANG 1.0 limitation that the list
+            //key must have the same "config" as the list, and
+            //also can't point to a non-config node.
+        }
+
+        container config {
+          description
+            "Configurable items at the global, physical interface
+            level";
+
+          uses interface-phys-config;
+        }
+
+        container state {
+
+          config false;
+          description
+            "Operational state data at the global interface level";
+
+          uses interface-phys-config;
+          uses interface-common-state;
+          uses interface-counters-state;
+        }
+
+        uses interface-phys-holdtime-top;
+        uses subinterfaces-top;
+      }
+    }
+  }
+
+  uses interfaces-top;
+
+
+}
diff --git a/bgp/openconfig-api/src/main/yang/openconfig-local-routing.yang b/bgp/openconfig-api/src/main/yang/openconfig-local-routing.yang
new file mode 100644 (file)
index 0000000..1c46661
--- /dev/null
@@ -0,0 +1,292 @@
+module openconfig-local-routing {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/local-routing";
+
+  prefix "loc-rt";
+
+  // import some basic types
+  import ietf-inet-types { prefix inet; }
+  import openconfig-policy-types { prefix pt; }
+  import openconfig-extensions { prefix oc-ext; }
+
+  // meta
+  organization "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "This module describes configuration and operational state data
+    for routes that are locally generated, i.e., not created by
+    dynamic routing protocols.  These include static routes, locally
+    created aggregate routes for reducing the number of constituent
+    routes that must be advertised, summary routes for IGPs, etc.
+
+    This model expresses locally generated routes as generically as
+    possible, avoiding configuration of protocol-specific attributes
+    at the time of route creation.  This is primarily to avoid
+    assumptions about how underlying router implementations handle
+    route attributes in various routing table data structures they
+    maintain.  Hence, the definition of locally generated routes
+    essentially creates 'bare' routes that do not have any protocol-
+    specific attributes.
+
+    When protocol-specific attributes must be attached to a route
+    (e.g., communities on a locally defined route meant to be
+    advertised via BGP), the attributes should be attached via a
+    protocol-specific policy after importing the route into the
+    protocol for distribution (again via routing policy).";
+
+  oc-ext:openconfig-version "0.1.3";
+
+  revision "2015-10-09" {
+    description
+      "Initial OpenConfig public release";
+    reference "0.1.3";
+  }
+
+  revision "2015-05-01" {
+    description
+      "Initial revision";
+    reference "Pre-release";
+  }
+
+  // extension statements
+
+  // feature statements
+
+  // identity statements
+
+  // typedef statements
+
+  typedef local-defined-next-hop {
+    type enumeration {
+      enum DROP {
+        description
+          "Discard or black-hole traffic for the corresponding
+          destination";
+      }
+    }
+    description
+      "Pre-defined next-hop designation for locally generated
+      routes";
+  }
+
+  // grouping statements
+
+  grouping local-generic-settings {
+    description
+      "Generic options that can be set on local routes When
+      they are defined";
+
+    leaf set-tag {
+      type pt:tag-type;
+      description
+        "Set a generic tag value on the route. This tag can be
+        used for filtering routes that are distributed to other
+        routing protocols.";
+    }
+  }
+
+  grouping local-static-config {
+    description
+      "Configuration data for static routes.";
+
+    leaf prefix {
+      type inet:ip-prefix;
+      description
+        "Destination prefix for the static route, either IPv4 or
+        IPv6.";
+    }
+
+    leaf-list next-hop {
+      type union {
+        type inet:ip-address;
+        type local-defined-next-hop;
+        type string;
+        //TODO: this should be a leafref pointing to a configured
+        //interface, but YANG 1.0 does not support leafrefs in a
+        //union type.  It should be updated when YANG 1.1 is
+        //released.
+      }
+      description
+        "Specify a set of next hops.  Each entry may be an IP
+        address, interface, or a single pre-defined next-hop can be
+        used, e.g., drop";
+    }
+
+    uses local-generic-settings;
+  }
+
+  grouping local-static-state {
+    description
+      "Operational state data for static routes";
+  }
+
+  grouping local-static-top {
+    description
+      "Top-level grouping for the list of static route definitions";
+
+    container static-routes {
+      description
+        "Enclosing container for the list of static routes";
+
+      list static {
+        key prefix;
+        description
+          "List of locally configured static routes";
+
+        leaf prefix {
+          type leafref {
+            path "../config/prefix";
+          }
+          description
+            "Reference to the destination prefix for the static
+            route";
+        }
+
+        container config {
+          description
+            "Configuration data for static routes";
+
+          uses local-static-config;
+        }
+
+        container state {
+
+          config false;
+
+          description
+            "Operational state data for static routes";
+
+          uses local-static-config;
+          uses local-static-state;
+        }
+      }
+    }
+  }
+
+  grouping local-aggregate-config {
+    description
+      "Configuration data for aggregate routes";
+
+    leaf prefix {
+      type inet:ip-prefix;
+      description
+        "Aggregate prefix to be advertised";
+    }
+
+    leaf discard {
+      type boolean;
+      default false;
+      description
+        "When true, install the aggregate route with a discard
+        next-hop -- traffic destined to the aggregate will be
+        discarded with no ICMP message generated.  When false,
+        traffic destined to an aggregate address when no
+        constituent routes are present will generate an ICMP
+        unreachable message.";
+    }
+
+    uses local-generic-settings;
+
+  }
+
+  grouping local-aggregate-state {
+    description
+      "Operational state data for local aggregate advertisement
+      definitions";
+  }
+
+  grouping local-aggregate-top {
+    description
+      "Top-level grouping for local aggregates";
+
+    container local-aggregates {
+      description
+        "Enclosing container for locally-defined aggregate
+        routes";
+
+      list aggregate {
+        key prefix;
+        description
+          "List of aggregates";
+
+        leaf prefix {
+          type leafref {
+            path "../config/prefix";
+          }
+          description
+            "Reference to the configured prefix for this aggregate";
+        }
+
+        container config {
+          description
+            "Configuration data for aggregate advertisements";
+
+          uses local-aggregate-config;
+        }
+
+        container state {
+
+          config false;
+
+          description
+            "Operational state data for aggregate
+            advertisements";
+
+          uses local-aggregate-config;
+          uses local-aggregate-state;
+        }
+      }
+    }
+  }
+
+  grouping local-routes-config {
+    description
+      "Configuration data for locally defined routes";
+  }
+
+  grouping local-routes-state {
+    description
+      "Operational state data for locally defined routes";
+  }
+
+  grouping local-routes-top {
+    description
+      "Top-level grouping for local routes";
+
+    container local-routes {
+      description
+        "Top-level container for local routes";
+
+      container config {
+        description
+          "Configuration data for locally defined routes";
+
+        uses local-routes-config;
+      }
+
+      container state {
+
+        config false;
+
+        description
+          "Operational state data for locally defined routes";
+
+        uses local-routes-config;
+        uses local-routes-state;
+      }
+
+      uses local-static-top;
+      uses local-aggregate-top;
+    }
+  }
+
+  uses local-routes-top;
+
+}
diff --git a/bgp/openconfig-api/src/main/yang/openconfig-network-instance-types.yang b/bgp/openconfig-api/src/main/yang/openconfig-network-instance-types.yang
new file mode 100644 (file)
index 0000000..06165f1
--- /dev/null
@@ -0,0 +1,98 @@
+module openconfig-network-instance-types {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/network-instance-types";
+
+  prefix "nit";
+
+  import openconfig-extensions { prefix "ocext"; }
+
+  // meta
+  organization "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "Types associated with a network instance";
+
+  ocext:openconfig-version "0.1.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";
+  }
+
+
+  // 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";
+  }
+
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/yang/openconfig-network-instance.yang b/bgp/openconfig-api/src/main/yang/openconfig-network-instance.yang
new file mode 100644 (file)
index 0000000..f87c573
--- /dev/null
@@ -0,0 +1,657 @@
+module openconfig-network-instance {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/network-instance";
+
+  prefix "netinst";
+
+  // import some basic types
+  //import ietf-inet-types { prefix inet; }
+  import ietf-yang-types { prefix "yang"; }
+  import ietf-inet-types { prefix "inet"; }
+  import openconfig-network-instance-types { prefix "nit"; }
+  import openconfig-policy-types { prefix "pt"; }
+  import openconfig-routing-policy { prefix "rpol"; }
+  import openconfig-local-routing { prefix "lroute"; }
+  import openconfig-interfaces { prefix "ocif"; }
+  import openconfig-extensions { prefix "ocext"; }
+
+  // meta
+  organization "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "An OpenConfig description of a network-instance. This may be
+    a Layer 3 forwarding construct such as a virtual routing and
+    forwarding (VRF) instance, or a Layer 2 instance such as a
+    virtual switch instance (VSI). Mixed Layer 2 and Layer 3
+    instances are also supported.";
+
+  ocext:openconfig-version "0.1.0";
+
+  revision "2015-10-18" {
+    description
+      "Initial revision";
+    reference "0.1.0";
+  }
+
+  grouping network-instance-top {
+    description
+      "Top-level grouping containing a list of network instances.";
+
+    container network-instances {
+      description
+        "The L2, L3, or L2+L3 forwarding instances that are
+        configured on the local system";
+
+      list network-instance {
+        key "name";
+
+        description
+          "Network instances configured on the local system";
+
+        leaf name {
+          type leafref {
+            path "../config/name";
+          }
+          description
+            "A unique name identifying the network instance";
+        }
+
+        container config {
+          description
+            "Configuration parameters relating to a network
+            instance";
+          uses network-instance-config;
+          uses network-instance-l3vrf-config {
+            when "../type = 'L3VRF'" {
+              description
+                "Layer 3 VRF configuration parameters included when a
+                network instance is of type L3VRF";
+            }
+          }
+        }
+        container state {
+          config false;
+          description
+            "Operational state parameters relating to a network
+            instance";
+          uses network-instance-config;
+          uses network-instance-l3vrf-config {
+            when "../type = 'L3VRF'" {
+              description
+                "Layer 3 VRF configuration parameters included when a
+                network instance is of type L3VRF";
+            }
+          }
+          uses network-instance-state;
+        }
+
+        container inter-instance-policies {
+          description
+            "Policies dictating how RIB or FIB entries are imported
+            to and exported from this instance";
+
+          uses rpol:apply-policy-group;
+        }
+
+        container table-connections {
+          description
+            "Policies dictating how RIB or FIB entries are propagated
+            between tables";
+
+          list table-connection {
+            key "src-table dst-table";
+
+            description
+              "A list of connections between pairs of routing or
+              forwarding tables, the leaking of entries between
+              which is specified by the import and export policy";
+
+            leaf src-table {
+              type leafref {
+                path "../config/src-table";
+              }
+              description
+                "The name of the table which should be utilised
+                as the source of forwarding or routing information";
+            }
+
+            leaf dst-table {
+              type leafref {
+                path "../config/dst-table";
+              }
+              description
+                "The table to which routing entries should be
+                exported";
+            }
+
+            container config {
+              description
+                "Configuration parameters relating to the connection
+                between tables";
+              uses inter-table-policies-config;
+            }
+            container state {
+              config false;
+              description
+                "State parameters relating to the connection between
+                tables";
+              uses inter-table-policies-config;
+            }
+
+            uses rpol:apply-policy-group;
+          }
+        }
+
+        container tables {
+          description
+            "The routing tables that are managed by this network
+            instance";
+
+          list table {
+            key "table-name";
+
+            description
+              "A network instance manages one or more forwarding or
+              routing tables. These may reflect the Layer 2
+              forwarding information base, the Layer 3 routing
+              information base of the MPLS LFIB. Protocols may be
+              explictly associated with a particular table into
+              which they populate entries. Multiple protocols may
+              install entries into a single table, or there may be a
+              1:1 relationship between a routing protocol and a
+              table .The import-policy and export-policy lists are
+              used to specify how routes leak between different
+              tables within the same forwarding instance.";
+
+            leaf table-name {
+              type leafref {
+                path "../config/table-name";
+              }
+              description
+                "A name for the table";
+            }
+
+            container config {
+              description
+                "Configuration parameters related to the table";
+              uses table-config;
+            }
+
+            container state {
+              config false;
+              description
+                "State parameters related to the table";
+              uses table-config;
+            }
+          }
+        }
+
+        container interfaces {
+          description
+            "Interfaces associated with this network intance";
+
+          container config {
+            description
+              "Configuration parameters relating to interfaces
+              associated with the instance";
+            uses instance-interfaces-config;
+          }
+          container state {
+            config false;
+            description
+              "State parameters relating to interfaces associated
+              with the instance";
+            uses instance-interfaces-config;
+            uses instance-interfaces-state;
+          }
+        }
+
+        container connection-points {
+          description
+            "The set of connection points within a forwarding
+            instance";
+
+          list connection-point {
+            key "connection-point-id";
+
+            description
+              "A connection point within a Layer 2 network instance.
+              Each connection-point consists of a set of interfaces
+              only one of which is active at any one time. Other than
+              the specification of whether an interface is local
+              (i.e., exists within this network-instance), or remote,
+              all configuration and state parameters are common";
+
+            leaf connection-point-id {
+              type leafref {
+                path "../config/connection-point-id";
+              }
+              description
+                "A locally significant reference for the
+                connection-point";
+            }
+
+            container config {
+              description
+                "Configuration parameters relating to a Layer 2
+                network instance connection point";
+              uses instance-connection-point-config;
+            }
+            container state {
+              config false;
+              description
+                "Operational state parameters relating to a Layer 2
+                network instance connection point";
+
+              uses instance-connection-point-config;
+              uses instance-connection-point-state;
+            }
+
+            container endpoints {
+              when "../config/type = 'L2P2P' " +
+                 "or ../config/type = 'L2VSI'" {
+                description
+                  "Configuration parameters to associate interfaces
+                   into a common group for use in Layer 2 network
+                   instances";
+              }
+
+              description
+                "The set of endpoints which are grouped within the
+                connection point";
+
+              list endpoint {
+                key "endpoint-id";
+
+                description
+                  "A list of the endpoints (interfaces or remote
+                  connection points that can be used for this
+                  connection point). The active endpoint is selected
+                  based on the precedence that it is configured
+                  with";
+
+                leaf endpoint-id {
+                  type leafref {
+                    path "../config/endpoint-id";
+                  }
+                  description
+                    "A pointer to the configured identifier for the
+                    endpoint";
+                }
+
+                container config {
+                  description
+                    "Configuration parameters relating to the
+                    endpoint";
+                  uses instance-endpoint-config;
+                }
+                container state {
+                  config false;
+                  description
+                    "Operational state parameters relating to the
+                    endpoint";
+                  uses instance-endpoint-config;
+                  uses instance-endpoint-state;
+                }
+              }
+            }
+          }
+        }
+
+        container protocols {
+          description
+            "The routing protocols that are enabled for this
+            network-instance.";
+
+          list protocol {
+            key "identifier name";
+
+            description
+              "A process (instance) of a routing protocol. Some
+              systems may not support more than one instance of
+              a particular routing protocol";
+
+            leaf identifier {
+              type leafref {
+                path "../config/identifier";
+              }
+              description
+                "The protocol name for the routing or forwarding
+                protocol to be instantiated";
+            }
+
+            leaf name {
+              type leafref {
+                path "../config/name";
+              }
+              description
+                "An operator-assigned identifier for the routing
+                or forwarding protocol. For some processes this
+                leaf may be system defined.";
+            }
+
+            container config {
+              description
+                "Configuration parameters relating to the routing
+                protocol instance";
+
+              uses protocols-config;
+            }
+
+            container state {
+              config false;
+              description
+                "State parameters relating to the routing protocol
+                instance";
+
+              uses protocols-config;
+              uses protocols-state;
+            }
+
+            container static {
+              when "../config/identifier = 'STATIC'" {
+                description
+                  "Include static route parameters only when the
+                  protocol is set to static";
+              }
+              description
+                "Configuration and state parameters relating to
+                static routes";
+              uses lroute:local-static-top;
+            }
+
+            container aggregate {
+              when "../config/identifier = 'LOCAL-AGGREGATE'" {
+                description
+                  "Include aggregate route parameters only when the
+                  protocol is set to aggregate";
+              }
+              description
+                "Configuration and state parameters relating to
+                locally generated aggregate routes";
+              uses lroute:local-aggregate-top;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  grouping instance-endpoint-config {
+    description
+      "Configuration data relating to an forwarding-instance
+      endpoint";
+
+    leaf endpoint-id {
+      type string;
+      description
+        "An identifier for the endpoint";
+    }
+
+    uses instance-endpoint-local-remote;
+
+    leaf precedence {
+      type uint16;
+      description
+        "The precedence of the endpoint - the lowest precendence
+        viable endpoint will be utilised as the active endpoint
+        within a connection";
+    }
+  }
+
+  grouping instance-endpoint-local-remote {
+    description
+      "A generic specification of a local or remote endpoint";
+
+    choice local-remote {
+      case local {
+        leaf interface {
+          type leafref {
+            path "/network-instances/network-instance" +
+                 "/interfaces/config/interface";
+          }
+          description
+            "Reference to the local interface that is a member of
+            the forwarding-instance";
+        }
+      }
+      case remote {
+        leaf neighbor {
+          type inet:ip-address;
+          description
+            "The IP address of the device which hosts the
+            remote end-point";
+        }
+
+        leaf virtual-circuit-identifier {
+          type uint32;
+          description
+            "The virtual-circuit identifier that identifies the
+            connection at the remote end-point";
+        }
+      }
+      description
+        "Configuration relating to an endpoint which can either be
+        local (an interface), or remote. In the case where it is
+        remote a neighbor IP address and virtual-circuit identifier
+        must be specified";
+    }
+  }
+
+  grouping instance-endpoint-state {
+    description
+      "Operational state data relating to a forwarding-instance
+      endpoint";
+    leaf active {
+      type boolean;
+      description
+        "When the backup endpoint is active, the value of this
+        parameter is set to true";
+    }
+  }
+
+  grouping instance-connection-point-config {
+    description
+      "Configuration data relating to a forwarding-instance
+      connection point";
+
+    leaf connection-point-id {
+      type string;
+      description
+        "An identifier for a connection point";
+    }
+  }
+
+  grouping instance-connection-point-state {
+    description
+      "Operational state data relating to a forwarding-instance
+      connection point";
+  }
+
+  grouping table-config {
+    description
+      "Configuration parameters relating to a L2/L2.5/L3 table that
+      exists within the network instance";
+
+    leaf table-name {
+      type string;
+      description
+        "A human-readable name for the table";
+    }
+
+  }
+
+  grouping table-state {
+    description
+      "State parameters relating to a table - this may be
+      utilised to store generic structure for retrieving the contents
+      of a RIB, FIB or LFIB";
+    // placeholder
+  }
+
+  grouping inter-table-policies-config {
+    description
+      "Configuration entries that relate to how RIB or FIB entries
+      are propagated between tables within the same network
+      instance";
+
+    leaf src-table {
+//      FIXME: BUG-4625: DTO generation cannot handle this case in Binding Spec v1
+//      type leafref {
+//        path "../../../../tables/table/table-name";
+//      }
+      type string;
+      description
+        "The source protocol for the table connection";
+    }
+
+    leaf dst-table {
+//      FIXME: BUG-4625: DTO generation cannot handle this case in Binding Spec v1
+//      type leafref {
+//        path "../../../../tables/table/table-name";
+//      }
+      type string;
+      description
+        "The destination protocol for the table connection";
+    }
+
+
+  }
+
+  grouping network-instance-config {
+    description
+      "Configuration parameters relating to a top-level network
+      instance";
+
+    leaf name {
+      type string;
+      description
+        "An operator-assigned unique name for the forwarding
+        instance";
+    }
+
+    leaf type {
+      type identityref {
+        base "nit:network-instance-type";
+      }
+      description
+        "The type of network instance. The value of this leaf
+        indicates the type of forwarding entries that should be
+        supported by this network instance";
+    }
+
+    leaf enabled {
+      type boolean;
+      description
+        "Whether the network instance should be configured to be
+        active on the network element";
+    }
+
+    leaf description {
+      type string;
+      description
+        "A free-form string to be used by the network operator to
+        describe the function of this network instance";
+    }
+
+    leaf router-id {
+      type yang:dotted-quad;
+      description
+        "A identifier for the local network instance - typically
+        used within associated routing protocols or signalling
+        routing information in another network instance";
+    }
+
+    leaf route-distinguisher {
+      type nit:route-distinguisher;
+      description
+        "The route distinguisher that should be used for the local
+        VRF or VSI instance when it is signalled via BGP.";
+    }
+  }
+
+  grouping network-instance-state {
+    description
+      "Operational state parameters relating to a network instance";
+  }
+
+  grouping network-instance-l3vrf-config {
+    description
+      "Configuration parameters for a network instance of type
+      l3vrf";
+
+  }
+
+  grouping protocols-config {
+    description
+      "Configuration parameters relating to a generic protocol
+      instance within a network instance";
+
+    leaf identifier {
+      type identityref {
+        base "pt:install-protocol-type";
+      }
+      description
+        "The protocol identifier for the instance";
+    }
+
+    leaf name {
+      type string;
+      description
+        "A unique name for the protocol instance";
+    }
+
+    leaf enabled {
+      type boolean;
+      description
+        "A boolean value indicating whether the local protocol
+        instance is enabled.";
+    }
+
+    leaf target-table {
+//      FIXME: BUG-4625: DTO generation cannot handle this case in Binding Spec v1
+//      type leafref {
+//        path "../../../../tables/table/table-name";
+//      }
+     type string;
+     description
+      "The table (RIB, FIB, or LFIB) that the protocol should
+      populate its entries in.";
+    }
+  }
+
+  grouping protocols-state {
+    description
+      "Operational state parameters relating to a protocol instance";
+  }
+
+  grouping instance-interfaces-config {
+    description
+      "Base configuration parameters relating to the interfaces
+      associated with a network instance";
+
+    leaf-list interface {
+      type leafref {
+        path "/ocif:interfaces/ocif:interface/ocif:name";
+      }
+      description
+        "Interfaces that are associated with the network instance";
+    }
+  }
+
+  grouping instance-interfaces-state {
+    description
+      "State parameters relating to the interfaces associated with a
+      network instance";
+  }
+
+  uses network-instance-top;
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/local/routing/rev151009/LocalStaticConfigNextHopBuilderTest.java
new file mode 100644 (file)
index 0000000..87ba388
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
+ */
+
+package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.local.routing.rev151009;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.local.routing.rev151009.LocalStaticConfig.NextHop;
+
+public class LocalStaticConfigNextHopBuilderTest {
+
+    private static final String IPV4_ADDRESS = "127.0.0.1";
+    private static final String STRING = "host";
+
+    @Test
+    public void testIpAddress() {
+        final NextHop nextHop = LocalStaticConfigNextHopBuilder.getDefaultInstance(IPV4_ADDRESS);
+        Assert.assertEquals(IPV4_ADDRESS, nextHop.getIpAddress().getIpv4Address().getValue());
+    }
+
+    @Test
+    public void testEnum() {
+        final NextHop nextHop = LocalStaticConfigNextHopBuilder.getDefaultInstance(LocalDefinedNextHop.DROP.toString());
+        Assert.assertEquals(LocalDefinedNextHop.DROP, nextHop.getLocalDefinedNextHop());
+    }
+
+    @Test
+    public void testString() {
+        final NextHop nextHop = LocalStaticConfigNextHopBuilder.getDefaultInstance(STRING);
+        Assert.assertEquals(STRING, nextHop.getString());
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/network/instance/types/rev151018/RouteDistinguisherBuilderTest.java
new file mode 100644 (file)
index 0000000..c2611c4
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
+ */
+
+package org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.types.rev151018;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class RouteDistinguisherBuilderTest {
+
+    private static final String RD = "127.0.0.1:123";
+
+    @Test
+    public void testRD() {
+        final RouteDistinguisher rd = RouteDistinguisherBuilder.getDefaultInstance(RD);
+        Assert.assertEquals(RD, rd.getString());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testFailure() {
+        RouteDistinguisherBuilder.getDefaultInstance("abc");
+    }
+
+}