BUG-4197: BGP OpenConfig API 08/27608/6
authorMilos Fabian <milfabia@cisco.com>
Wed, 23 Sep 2015 09:53:42 +0000 (11:53 +0200)
committerMilos Fabian <milfabia@cisco.com>
Mon, 12 Oct 2015 11:59:24 +0000 (13:59 +0200)
BGP OpenConfig yang models as defined in https://tools.ietf.org/html/draft-ietf-idr-bgp-model-00
Defines yang data model for configuration and managing BGP.
Added "odl-openconfig-extensions" Yang data model to support missing AFI/SAFI

Change-Id: I1a59a1c36f6f81b94058cc201115174e41fdfc8b
Signed-off-by: Milos Fabian <milfabia@cisco.com>
32 files changed:
artifacts/pom.xml
bgp/openconfig-api/.project [new file with mode: 0644]
bgp/openconfig-api/pom.xml [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilder.java [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-multiprotocol.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-openconfig-extensions.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-operational.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-policy.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp-types.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/bgp.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/policy-types.yang [new file with mode: 0644]
bgp/openconfig-api/src/main/yang/routing-policy.yang [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilderTest.java [new file with mode: 0644]
bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilderTest.java [new file with mode: 0644]
bgp/pom.xml

index d7381cc03d1bdbc031200be4d7c3170ab6413791..ae0fff6716d795cd660e389d94977bbfd95fb04e 100644 (file)
                 <artifactId>bgp-bmp-impl</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>bgp-openconfig-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>bgp-controller-config</artifactId>
diff --git a/bgp/openconfig-api/.project b/bgp/openconfig-api/.project
new file mode 100644 (file)
index 0000000..08032b3
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>bgp-openconfig-api</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/bgp/openconfig-api/pom.xml b/bgp/openconfig-api/pom.xml
new file mode 100644 (file)
index 0000000..53ad1e2
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2015 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
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
+        <tag>HEAD</tag>
+    </scm>
+    <parent>
+        <groupId>org.opendaylight.bgpcep</groupId>
+        <artifactId>bgp-parent</artifactId>
+        <version>0.5.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>bgp-openconfig-api</artifactId>
+    <description>BGP OPENCONFIG API</description>
+    <packaging>bundle</packaging>
+    <name>${project.artifactId}</name>
+    <prerequisites>
+        <maven>3.0.4</maven>
+    </prerequisites>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-inet-types</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-yang-types</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>concepts</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilder.java
new file mode 100644 (file)
index 0000000..6b65cf3
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.BgpNextHopType.Enumeration;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class BgpNextHopTypeBuilder {
+
+    public static BgpNextHopType getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final Enumeration nextHopEnum = BgpNextHopType.Enumeration.valueOf(defaultValue.toUpperCase());
+            return new BgpNextHopType(nextHopEnum);
+        } catch (final IllegalArgumentException e) {
+            try {
+                final IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(defaultValue);
+                return new BgpNextHopType(ipAddress);
+            } catch (final IllegalArgumentException e1) {
+                throw new IllegalArgumentException("Cannot create BgpNextHopType from " + defaultValue);
+            }
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilder.java
new file mode 100644 (file)
index 0000000..259e067
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515;
+
+import com.google.common.primitives.UnsignedInts;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.BgpSetMedType.Enumeration;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class BgpSetMedTypeBuilder {
+
+    private static final Pattern MED_TYPE_STRING_PATTERN = Pattern.compile("^^[+-][0-9]+$");
+
+    public static BgpSetMedType getDefaultInstance(final java.lang.String defaultValue) {
+        final Matcher ipv4Matcher = MED_TYPE_STRING_PATTERN.matcher(defaultValue);
+
+        if (ipv4Matcher.matches()) {
+            return new BgpSetMedType(defaultValue);
+        } else {
+            try {
+                final long parseUnsignedInt = UnsignedInts.parseUnsignedInt(defaultValue);
+                return new BgpSetMedType(parseUnsignedInt);
+            } catch (final NumberFormatException e) {
+                try {
+                    final Enumeration medTypeEnum = BgpSetMedType.Enumeration.valueOf(defaultValue.toUpperCase());
+                    return new BgpSetMedType(medTypeEnum);
+                } catch(final IllegalArgumentException e1) {
+                    throw new IllegalArgumentException("Cannot create BgpSetMedType from " + defaultValue);
+                }
+            }
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilder.java
new file mode 100644 (file)
index 0000000..8d00648
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.community.sets;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.community.sets.CommunitySet.CommunityMember;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpCommunityRegexpType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpStdCommunityType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpStdCommunityTypeBuilder;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class CommunitySetCommunityMemberBuilder {
+
+    public static CommunityMember getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final BgpStdCommunityType commType = BgpStdCommunityTypeBuilder.getDefaultInstance(defaultValue);
+            return new CommunityMember(commType);
+        } catch(final IllegalArgumentException e) {
+            return new CommunityMember(new BgpCommunityRegexpType(defaultValue));
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilder.java
new file mode 100644 (file)
index 0000000..f7e43ea
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets.ExtCommunitySet.ExtCommunityMember;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpCommunityRegexpType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpExtCommunityType;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class ExtCommunitySetExtCommunityMemberBuilder {
+
+    public static ExtCommunityMember getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final BgpExtCommunityType bgpExtCommunityType = new BgpExtCommunityType(defaultValue);
+            return new ExtCommunityMember(bgpExtCommunityType);
+        } catch(final IllegalArgumentException e) {
+            return new ExtCommunityMember(new BgpCommunityRegexpType(defaultValue));
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilder.java
new file mode 100644 (file)
index 0000000..d3bbe10
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline.Communities;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpStdCommunityType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpStdCommunityTypeBuilder;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class InlineCommunitiesBuilder {
+
+    public static Communities getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final BgpStdCommunityType commType = BgpStdCommunityTypeBuilder.getDefaultInstance(defaultValue);
+            return new Communities(commType);
+        } catch (final IllegalArgumentException e) {
+            throw new IllegalArgumentException("Cannot create Communities from " + defaultValue);
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilder.java
new file mode 100644 (file)
index 0000000..bbad50e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline.Communities;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev150515.BgpExtCommunityType;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class InlineCommunitiesBuilder {
+
+    public static Communities getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final BgpExtCommunityType commType = new BgpExtCommunityType(defaultValue);
+            return new Communities(commType);
+        } catch (final IllegalArgumentException e) {
+            throw new IllegalArgumentException("Cannot create Communities from " + defaultValue);
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilder.java
new file mode 100644 (file)
index 0000000..98093b1
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015 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.bgp.rev150515;
+
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev150515.BgpNeighborTransportConfig.LocalAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddressBuilder;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class BgpNeighborTransportConfigLocalAddressBuilder {
+
+    public static LocalAddress getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(defaultValue);
+            return new LocalAddress(ipAddress);
+        } catch (final IllegalArgumentException e) {
+            return new LocalAddress(defaultValue);
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilder.java
new file mode 100644 (file)
index 0000000..cee3c47
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015 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.bgp.types.rev150515;
+
+import com.google.common.primitives.UnsignedInts;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class BgpStdCommunityTypeBuilder {
+
+    private static final Pattern COMM_TYPE_PATTERN = Pattern.compile("^([0-9]+:[0-9]+)$");
+
+    public static BgpStdCommunityType getDefaultInstance(final java.lang.String defaultValue) {
+        final Matcher commMatcher = COMM_TYPE_PATTERN.matcher(defaultValue);
+
+        if (commMatcher.matches()) {
+            return new BgpStdCommunityType(defaultValue);
+        } else {
+            try {
+                final long parseUnsignedInt = UnsignedInts.parseUnsignedInt(defaultValue);
+                return new BgpStdCommunityType(parseUnsignedInt);
+            } catch (final NumberFormatException e) {
+                throw new IllegalArgumentException("Cannot create BgpStdCommunityType from " + defaultValue);
+            }
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilder.java
new file mode 100644 (file)
index 0000000..4d9af1f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015 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.bgp.types.rev150515;
+
+import com.google.common.primitives.UnsignedInts;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class RrClusterIdTypeBuilder {
+
+    private static final Pattern IPV4_PATTERN = Pattern.compile("^(([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])(%[\\p{N}\\p{L}]+)?$");
+
+    public static RrClusterIdType getDefaultInstance(final java.lang.String defaultValue) {
+        final Matcher ipv4Matcher = IPV4_PATTERN.matcher(defaultValue);
+        if (ipv4Matcher.matches()) {
+            return new RrClusterIdType(new Ipv4Address(defaultValue));
+        } else {
+            try {
+                final long parseUnsignedInt = UnsignedInts.parseUnsignedInt(defaultValue);
+                return new RrClusterIdType(parseUnsignedInt);
+            } catch (final NumberFormatException e) {
+                throw new IllegalArgumentException("Cannot create RrClusterIdType from " + defaultValue);
+            }
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilder.java b/bgp/openconfig-api/src/main/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilder.java
new file mode 100644 (file)
index 0000000..d893570
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 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.policy.types.rev150515;
+
+import com.google.common.primitives.UnsignedInts;
+
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+public class TagTypeBuilder {
+
+    public static TagType getDefaultInstance(final java.lang.String defaultValue) {
+        try {
+            final long parseUnsignedInt = UnsignedInts.parseUnsignedInt(defaultValue);
+            return new TagType(parseUnsignedInt);
+        } catch (final NumberFormatException e) {
+            return new TagType(defaultValue);
+        }
+    }
+
+}
diff --git a/bgp/openconfig-api/src/main/yang/bgp-multiprotocol.yang b/bgp/openconfig-api/src/main/yang/bgp-multiprotocol.yang
new file mode 100644 (file)
index 0000000..0cd0588
--- /dev/null
@@ -0,0 +1,721 @@
+module bgp-multiprotocol {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/bgp-multiprotocol";
+
+  prefix "bgp-mp";
+
+  // import some basic inet types
+  import routing-policy { prefix rpol; }
+  import bgp-types { prefix bgp-types; }
+  import bgp-operational { prefix bgp-op; }
+
+  // meta
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module is part of a YANG model for BGP protocol
+    configuration, focusing on configuration of multiprotocol
+    BGP, in particular various relevant address families (AFI) and
+    sub-address families (SAFI).
+
+    Identities (rather than enumerated types) are used to identify
+    each AFI / SAFI type to make it easier for users to extend to
+    pre-standard or custom AFI/SAFI types.  This module is only
+    intended to capture the most";
+
+
+  revision "2015-05-15" {
+    description
+      "Refactored multiprotocol module";
+    reference "TBD";
+  }
+
+  grouping ipv4-unicast-group {
+    description
+      "Group for IPv4 Unicast configuration options";
+
+    container ipv4-unicast {
+      when "../afi-safi-name = 'bgp-mp:ipv4-unicast'" {
+        description
+          "Include this container for IPv4 Unicast specific
+          configuration";
+      }
+
+      description "IPv4 unicast configuration options";
+
+      // include common IPv[46] unicast options
+      uses ipv4-ipv6-unicast-common;
+
+      // placeholder for IPv4 unicast  specific configuration
+    }
+  }
+
+  grouping ipv6-unicast-group {
+    description
+      "Group for IPv6 Unicast configuration options";
+
+    container ipv6-unicast {
+      when "../afi-safi-name = 'bgp-mp:ipv6-unicast'" {
+        description
+          "Include this container for IPv6 Unicast specific
+          configuration";
+      }
+
+      description "IPv6 unicast configuration options";
+
+      // include common IPv[46] unicast options
+      uses ipv4-ipv6-unicast-common;
+
+      // placeholder for IPv6 unicast specific configuration
+      // options
+    }
+  }
+
+  grouping ipv4-labelled-unicast-group {
+    description
+      "Group for IPv4 Labelled Unicast configuration options";
+
+    container ipv4-labelled-unicast {
+      when "../afi-safi-name = 'bgp-mp:ipv4-labelled-unicast'" {
+        description
+          "Include this container for IPv4 Labelled Unicast specific
+          configuration";
+      }
+
+      description "IPv4 Labelled Unicast configuration options";
+
+      uses all-afi-safi-common;
+
+      // placeholder for IPv4 Labelled Unicast specific config
+      // options
+    }
+  }
+
+  grouping ipv6-labelled-unicast-group {
+    description
+      "Group for IPv6 Labelled Unicast configuration options";
+
+    container ipv6-labelled-unicast {
+      when "../afi-safi-name = 'bgp-mp:ipv6-labelled-unicast'" {
+        description
+          "Include this container for IPv6 Labelled Unicast specific
+          configuration";
+      }
+
+      description "IPv6 Labelled Unicast configuration options";
+
+      uses all-afi-safi-common;
+
+      // placeholder for IPv6 Labelled Unicast specific config
+      // options.
+    }
+  }
+
+  grouping l3vpn-ipv4-unicast-group {
+    description
+      "Group for IPv4 Unicast L3VPN configuration options";
+
+    container l3vpn-ipv4-unicast {
+      when "../afi-safi-name = 'bgp-mp:l3vpn-ipv4-unicast'" {
+        description
+          "Include this container for IPv4 Unicast L3VPN specific
+          configuration";
+      }
+
+      description "Unicast IPv4 L3VPN configuration options";
+
+      // include common L3VPN configuration options
+      uses l3vpn-ipv4-ipv6-unicast-common;
+
+      // placeholder for IPv4 Unicast L3VPN specific config options.
+    }
+  }
+
+  grouping l3vpn-ipv6-unicast-group {
+    description
+      "Group for IPv6 Unicast L3VPN configuration options";
+
+    container l3vpn-ipv6-unicast {
+      when "../afi-safi-name = 'bgp-mp:l3vpn-ipv6-unicast'" {
+        description
+          "Include this container for unicast IPv6 L3VPN specific
+          configuration";
+      }
+
+      description "Unicast IPv6 L3VPN configuration options";
+
+      // include common L3VPN configuration options
+      uses l3vpn-ipv4-ipv6-unicast-common;
+
+      // placeholder for IPv6 Unicast L3VPN specific configuration
+      // options
+    }
+  }
+
+  grouping l3vpn-ipv4-multicast-group {
+    description
+      "Group for IPv4 L3VPN multicast configuration options";
+
+    container l3vpn-ipv4-multicast {
+      when "../afi-safi-name = 'bgp-mp:l3vpn-ipv4-multicast'" {
+        description
+          "Include this container for multicast IPv6 L3VPN specific
+          configuration";
+      }
+
+      description "Multicast IPv4 L3VPN configuration options";
+
+      // include common L3VPN multicast options
+      uses l3vpn-ipv4-ipv6-multicast-common;
+
+      // placeholder for IPv4 Multicast L3VPN specific configuration
+      // options
+    }
+  }
+
+  grouping l3vpn-ipv6-multicast-group {
+    description
+      "Group for IPv6 L3VPN multicast configuration options";
+
+    container l3vpn-ipv6-multicast {
+      when "../afi-safi-name = 'bgp-mp:l3vpn-ipv6-multicast'" {
+        description
+          "Include this container for multicast IPv6 L3VPN specific
+          configuration";
+      }
+
+      description "Multicast IPv6 L3VPN configuration options";
+
+      // include common L3VPN multicast options
+      uses l3vpn-ipv4-ipv6-multicast-common;
+
+      // placeholder for IPv6 Multicast L3VPN specific configuration
+      // options
+    }
+  }
+
+  grouping l2vpn-vpls-group {
+    description
+      "Group for BGP-signalled VPLS configuration options";
+
+    container l2vpn-vpls {
+      when "../afi-safi-name = 'bgp-mp:l2vpn-vpls'" {
+        description
+          "Include this container for BGP-signalled VPLS specific
+          configuration";
+      }
+
+      description "BGP-signalled VPLS configuration options";
+
+      // include common L2VPN options
+      uses l2vpn-common;
+
+      // placeholder for BGP-signalled VPLS specific configuration
+      // options
+    }
+  }
+
+  grouping l2vpn-evpn-group {
+    description
+      "Group for BGP EVPN configuration options";
+
+    container l2vpn-evpn {
+      when "../afi-safi-name = 'bgp-mp:l2vpn-evpn'" {
+        description
+          "Include this container for BGP EVPN specific
+          configuration";
+      }
+
+      description "BGP EVPN configuration options";
+
+      // include common L2VPN options
+      uses l2vpn-common;
+
+      // placeholder for BGP EVPN specific configuration options
+    }
+  }
+
+
+
+  grouping bgp-route-selection-options_config {
+    description
+      "Set of configuration options that govern best
+       path selection.";
+
+    leaf always-compare-med {
+      type boolean;
+      default "false";
+      description
+        "Compare multi-exit discriminator (MED) value from
+        different ASes when selecting the best route.  The
+        default behavior is to only compare MEDs for paths
+        received from the same AS.";
+    }
+
+    leaf ignore-as-path-length {
+      type boolean;
+      default "false";
+      description
+        "Ignore the AS path length when selecting the best path.
+        The default is to use the AS path length and prefer paths
+        with shorter length.";
+    }
+
+    leaf external-compare-router-id {
+      type boolean;
+      default "true";
+      description
+        "When comparing similar routes received from external
+        BGP peers, use the router-id as a criterion to select
+        the active path.";
+    }
+
+    leaf advertise-inactive-routes {
+      type boolean;
+      default "false";
+      description
+        "Advertise inactive routes to external peers.  The
+        default is to only advertise active routes.";
+    }
+
+    leaf enable-aigp {
+      type boolean;
+      default false;
+      description
+        "Flag to enable sending / receiving accumulated IGP
+        attribute in routing updates";
+    }
+
+    leaf ignore-next-hop-igp-metric {
+      type boolean;
+      default "false";
+      description
+        "Ignore the IGP metric to the next-hop when calculating
+        BGP best-path. The default is to select the route for
+        which the metric to the next-hop is lowest";
+    }
+  }
+
+  grouping bgp-use-multiple-paths-ebgp-as-options_config {
+    description
+      "Configuration parameters specific to eBGP multipath applicable
+      to all contexts";
+
+    leaf allow-multiple-as {
+     type boolean;
+     default "false";
+     description
+      "Allow multipath to use paths from different neighbouring
+      ASes.  The default is to only consider multiple paths from
+      the same neighbouring AS.";
+    }
+  }
+
+  grouping bgp-use-multiple-paths-ebgp_config {
+    description
+      "Configuration parameters relating to multipath for eBGP";
+
+    uses bgp-use-multiple-paths-ebgp-as-options_config;
+
+    leaf maximum-paths {
+     type uint32;
+     default 1;
+     description
+      "Maximum number of parallel paths to consider when using
+      BGP multipath. The default is use a single path.";
+    }
+  }
+
+  grouping bgp-use-multiple-paths-ibgp_config {
+    description
+      "Configuration parmaeters relating to multipath for iBGP";
+
+    leaf maximum-paths {
+      type uint32;
+      default 1;
+      description
+        "Maximum number of parallel paths to consider when using
+        iBGP multipath. The default is to use a single path";
+    }
+  }
+
+  grouping bgp-use-multiple-paths {
+    description
+      "Configuration parameters relating to multipath for BGP - both
+      iBGP and eBGP";
+
+    container use-multiple-paths {
+      description
+        "Parameters related to the use of multiple paths for the
+        same NLRI";
+
+      container config {
+        description
+          "Configuration parameters relating to multipath";
+        uses bgp-use-multiple-paths_config;
+      }
+      container state {
+        description
+          "State parameters relating to multipath";
+        uses bgp-use-multiple-paths_config;
+      }
+
+      container ebgp {
+        description
+          "Multipath parameters for eBGP";
+        container config {
+          description
+            "Configuration parameters relating to eBGP multipath";
+          uses bgp-use-multiple-paths-ebgp_config;
+        }
+        container state {
+          config false;
+          description
+            "State information relating to eBGP multipath";
+          uses bgp-use-multiple-paths-ebgp_config;
+        }
+      }
+
+      container ibgp {
+        description
+          "Multipath parameters for iBGP";
+        container config {
+          description
+            "Configuration parameters relating to iBGP multipath";
+          uses bgp-use-multiple-paths-ibgp_config;
+        }
+        container state {
+          config false;
+          description
+            "State information relating to iBGP multipath";
+          uses bgp-use-multiple-paths-ibgp_config;
+        }
+      }
+    }
+  }
+
+  grouping bgp-use-multiple-paths-neighbor {
+    description
+      "Per-neighbor configuration for multipath for BGP";
+
+    container use-multiple-paths {
+      description
+        "Parameters related to the use of multiple-paths for the same
+        NLRI when they are received only from this neighbor";
+
+      container config {
+        description
+          "Configuration parameters relating to multipath";
+        uses bgp-use-multiple-paths_config;
+      }
+      container state {
+        description
+          "State parameters relating to multipath";
+        uses bgp-use-multiple-paths_config;
+      }
+
+      container ebgp {
+        description
+          "Multipath configuration for eBGP";
+        container config {
+          description
+            "Configuration parameters relating to eBGP multipath";
+          uses bgp-use-multiple-paths-ebgp-as-options_config;
+        }
+        container state {
+          config false;
+          description
+            "State information relating to eBGP multipath";
+          uses bgp-use-multiple-paths-ebgp-as-options_config;
+        }
+      }
+    }
+  }
+
+  grouping bgp-use-multiple-paths_config {
+    description
+      "Generic configuration options relating to use of multiple
+      paths for a referenced AFI-SAFI, group or neighbor";
+
+    leaf enabled {
+      type boolean;
+      default false;
+      description
+        "Whether the use of multiple paths for the same NLRI is
+        enabled for the neighbor. This value is overridden by
+        any more specific configuration value.";
+    }
+  }
+
+  grouping bgp-afi-safi-graceful-restart_config {
+    description
+      "BGP graceful restart parameters that apply on a per-AFI-SAFI
+      basis";
+
+    leaf enabled {
+      type boolean;
+      default false;
+      description
+        "This leaf indicates whether graceful-restart is enabled for
+        this AFI-SAFI";
+    }
+  }
+
+  grouping bgp-afi-safi_config {
+    description
+      "Configuration parameters used for all BGP AFI-SAFIs";
+
+    leaf afi-safi-name {
+      type identityref {
+        base bgp-types:afi-safi-type;
+      }
+      description "AFI,SAFI";
+    }
+
+    leaf enabled {
+      type boolean;
+      default false;
+      description
+        "This leaf indicates whether the IPv4 Unicast AFI,SAFI is
+        enabled for the neighbour or group";
+    }
+  }
+
+  grouping all-afi-safi-common-prefix-limit_config {
+    description
+      "Configuration parameters relating to prefix-limits for an
+      AFI-SAFI";
+
+    leaf max-prefixes {
+      type uint32;
+      description
+        "Maximum number of prefixes that will be accepted
+        from the neighbour";
+    }
+
+    leaf shutdown-threshold-pct {
+      type bgp-types:percentage;
+      description
+        "Threshold on number of prefixes that can be received
+        from a neighbour before generation of warning messages
+        or log entries. Expressed as a percentage of
+        max-prefixes";
+    }
+
+    leaf restart-timer {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      units "seconds";
+      description
+        "Time interval in seconds after which the BGP session
+        is re-established after being torn down due to exceeding
+        the max-prefix limit.";
+    }
+  }
+
+  grouping ipv4-ipv6-unicast-common_config {
+    description
+      "Common configuration parameters for IPv4 and IPv6 Unicast
+      address families";
+
+    leaf send-default-route {
+      type boolean;
+      default "false";
+      description
+        "If set to true, send the default-route to the neighbour(s)";
+    }
+  }
+
+  grouping all-afi-safi-common {
+    description
+      "Grouping for configuration common to all AFI,SAFI";
+
+    container prefix-limit {
+      description
+        "Configure the maximum number of prefixes that will be
+        accepted from a peer";
+
+      container config {
+        description
+          "Configuration parameters relating to the prefix
+          limit for the AFI-SAFI";
+        uses all-afi-safi-common-prefix-limit_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the prefix-limit for the
+          AFI-SAFI";
+        uses all-afi-safi-common-prefix-limit_config;
+      }
+    }
+  }
+
+  grouping ipv4-ipv6-unicast-common {
+    description
+      "Common configuration that is applicable for IPv4 and IPv6
+      unicast";
+
+    // include common afi-safi options.
+    uses all-afi-safi-common;
+
+    // configuration options that are specific to IPv[46] unicast
+    container config {
+      description
+        "Configuration parameters for common IPv4 and IPv6 unicast
+        AFI-SAFI options";
+      uses ipv4-ipv6-unicast-common_config;
+    }
+    container state {
+      config false;
+      description
+        "State information for common IPv4 and IPv6 unicast
+        parameters";
+      uses ipv4-ipv6-unicast-common_config;
+    }
+  }
+
+  grouping l3vpn-ipv4-ipv6-unicast-common {
+    description
+      "Common configuration applied across L3VPN for IPv4
+       and IPv6";
+
+    // placeholder -- specific configuration options that are generic
+    // across IPv[46] unicast address families.
+    uses all-afi-safi-common;
+  }
+
+  grouping l3vpn-ipv4-ipv6-multicast-common {
+    description
+      "Common configuration applied across L3VPN for IPv4
+      and IPv6";
+
+    // placeholder -- specific configuration options that are
+    // generic across IPv[46] multicast address families.
+    uses all-afi-safi-common;
+  }
+
+  grouping l2vpn-common {
+    description
+      "Common configuration applied across L2VPN address
+      families";
+
+    // placeholder -- specific configuration options that are
+    // generic across L2VPN address families
+    uses all-afi-safi-common;
+  }
+
+  grouping bgp-route-selection-options {
+    description
+      "Parameters relating to the BGP route selection process";
+
+    container route-selection-options {
+      description
+        "Parameters relating to options for route selection";
+      container config {
+        description
+          "Configuration parameters relating to route selection
+          options";
+        uses bgp-route-selection-options_config;
+      }
+      container state {
+        config false;
+        description
+          "State information for the route selection options";
+        uses bgp-route-selection-options_config;
+      }
+    }
+  }
+
+  // *********** STRUCTURE GROUPINGS **********************
+
+  grouping bgp-global-afi-safi {
+    description
+      "Parameters and route selection options for MP-BGP
+      specific to the Global AFI-SAFI";
+    uses bgp-route-selection-options;
+  }
+
+  grouping bgp-group-afi-safi {
+    description
+      "Parameters and route selection options for MP-BGP
+      specific to peer groups";
+    uses bgp-route-selection-options;
+  }
+
+  grouping bgp-common-afi-safi-list {
+    description
+      "List of address-families associated with the BGP instance,
+      a peer-group or neighbor";
+
+    list afi-safi {
+      key "afi-safi-name";
+
+      description
+        "AFI,SAFI configuration available for the
+        neighbour or group";
+
+
+      leaf afi-safi-name {
+        type leafref {
+          path "../config/afi-safi-name";
+        }
+        description
+          "Reference to the AFI-SAFI name used as a key
+          for the AFI-SAFI list";
+      }
+
+      container graceful-restart {
+        description
+          "Parameters relating to BGP graceful-restart";
+        container config {
+          description
+            "Configuration options for BGP graceful-restart";
+          uses bgp-afi-safi-graceful-restart_config;
+        }
+        container state {
+          config false;
+          description
+            "State information for BGP graceful-restart";
+          uses bgp-afi-safi-graceful-restart_config;
+        }
+      }
+
+      container config {
+        description
+          "Configuration parameters for the AFI-SAFI";
+        uses bgp-afi-safi_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the AFI-SAFI";
+        uses bgp-afi-safi_config;
+        uses bgp-op:bgp-afi-safi_state;
+      }
+
+      // import and export policy included for the afi/safi
+      uses rpol:apply-policy-group;
+
+      uses ipv4-unicast-group;
+      uses ipv6-unicast-group;
+      uses ipv4-labelled-unicast-group;
+      uses ipv6-labelled-unicast-group;
+      uses l3vpn-ipv4-unicast-group;
+      uses l3vpn-ipv6-unicast-group;
+      uses l3vpn-ipv4-multicast-group;
+      uses l3vpn-ipv6-multicast-group;
+      uses l2vpn-vpls-group;
+      uses l2vpn-evpn-group;
+    }
+  }
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/yang/bgp-openconfig-extensions.yang b/bgp/openconfig-api/src/main/yang/bgp-openconfig-extensions.yang
new file mode 100644 (file)
index 0000000..cdf6085
--- /dev/null
@@ -0,0 +1,47 @@
+module bgp-openconfig-extensions {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions";
+    prefix "odl-oc-ext";
+
+    import bgp-types { prefix bgp-types; revision-date 2015-05-15; }
+
+    organization "Cisco Systems, Inc.";
+    contact "Milos Fabian <milfabia@cisco.com>";
+
+    description
+        "This module contains the custom extensions to the
+        draft-ietf-idr-bgp-model-00 Yang data models.
+
+        Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
+
+        This program and the accompanying materials are made available
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
+
+    revision 2015-09-30 {
+        description "Initial revision";
+    }
+
+    identity ipv4-flow {
+        base bgp-types:afi-safi-type;
+        description
+          "IPv4 Flow specification (AFI,SAFI = 1,133)";
+        reference "https://tools.ietf.org/html/rfc5575";
+    }
+
+    identity ipv6-flow {
+        base bgp-types:afi-safi-type;
+        description
+          "IPv6 Flow specification (AFI,SAFI = 2,133)";
+        reference "https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-06";
+    }
+
+    identity linkstate {
+        base bgp-types:afi-safi-type;
+        description
+          "Link-State (AFI,SAFI = 16388,71)";
+        reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03";
+    }
+
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/yang/bgp-operational.yang b/bgp/openconfig-api/src/main/yang/bgp-operational.yang
new file mode 100644 (file)
index 0000000..c6103c5
--- /dev/null
@@ -0,0 +1,392 @@
+module bgp-operational {
+
+  yang-version "1";
+
+  // namespace
+  // TODO: change to an ietf or other more generic namespace
+  namespace "http://openconfig.net/yang/bgp-operational";
+
+  prefix "bgp-op";
+
+  // import some basic inet types
+  import ietf-inet-types { prefix inet; }
+  import ietf-yang-types { prefix yang; }
+  import bgp-types { prefix bgp-types; }
+
+  // meta
+
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module is part of a YANG model for BGP protocol
+    configuration, focusing on operational data (i.e., state
+    variables) related to BGP operations";
+
+
+  revision "2015-05-15" {
+    description
+      "Initial revision";
+    reference "TBD";
+  }
+
+  // extension statements
+
+  // feature statements
+
+  // identity statements
+
+  // typedef statements
+
+  // grouping statements
+
+  grouping bgp-counters-message-types_common {
+    description
+      "Grouping of BGP message types, included for re-use
+      across counters";
+
+    leaf UPDATE {
+      type uint64;
+      description
+        "Number of BGP UPDATE messages announcing, withdrawing
+        or modifying paths exchanged.";
+    }
+
+    leaf NOTIFICATION {
+      type uint64;
+      description
+        "Number of BGP NOTIFICATION messages indicating an
+        error condition has occurred exchanged.";
+    }
+  }
+
+
+  grouping bgp-context-pfx-path-counters_common {
+    description
+      "Grouping containing common counters relating to prefixes and
+      paths";
+
+    leaf total-paths {
+      type uint32;
+      description
+        "Total number of BGP paths within the context";
+    }
+
+    leaf total-prefixes {
+      type uint32;
+      description
+        "";
+    }
+  }
+
+  grouping bgp-global_state {
+    description
+      "Grouping containing operational parameters relating to the
+      global BGP instance";
+    uses bgp-context-pfx-path-counters_common;
+  }
+
+  grouping bgp-global-afi-safi_state {
+    description
+      "Grouping containing operational parameters relating to each
+      AFI-SAFI within the BGP global instance";
+    uses bgp-context-pfx-path-counters_common;
+  }
+
+  grouping bgp-peer-group_state {
+    description
+      "Grouping containing operational parameters relating to a BGP
+      peer group";
+    uses bgp-context-pfx-path-counters_common;
+  }
+
+  grouping bgp-neighbor_state {
+    description
+      "Grouping containing operational state variables relating to a
+      BGP neighbor";
+
+    leaf session-state {
+      type enumeration {
+          enum IDLE {
+            description
+              "neighbor is down, and in the Idle state of the
+              FSM";
+          }
+          enum CONNECT {
+            description
+              "neighbor is down, and the session is waiting for
+              the underlying transport session to be established";
+          }
+          enum ACTIVE {
+            description
+              "neighbor is down, and the local system is awaiting
+              a conncetion from the remote peer";
+          }
+          enum OPENSENT {
+            description
+              "neighbor is in the process of being established.
+              The local system has sent an OPEN message";
+          }
+          enum OPENCONFIRM {
+            description
+              "neighbor is in the process of being established.
+              The local system is awaiting a NOTIFICATION or
+              KEEPALIVE message";
+          }
+          enum ESTABLISHED {
+            description
+              "neighbor is up - the BGP session with the peer is
+              established";
+          }
+        }
+      description
+        "Operational state of the BGP peer";
+    }
+
+    leaf-list supported-capabilities {
+      type identityref {
+        base bgp-types:bgp-capability;
+      }
+      description
+        "BGP capabilities negotiated as supported with the peer";
+    }
+  }
+
+  grouping bgp-neighbor-afi-safi_state {
+    description
+      "Operational state on a per-AFI-SAFI basis for a BGP
+      neighbor";
+
+    leaf active {
+      type boolean;
+      description
+        "This value indicates whether a particular AFI-SAFI has
+        been succesfully negotiated with the peer. An AFI-SAFI
+        may be enabled in the current running configuration, but a
+        session restart may be required in order to negotiate the new
+        capability.";
+    }
+
+    uses bgp-neighbor-prefix-counters_state;
+  }
+
+  grouping bgp-neighbor-prefix-counters_state {
+    description
+      "Counters for BGP neighbor sessions";
+
+    container prefixes {
+      description "Prefix counters for the BGP session";
+      leaf received {
+        type uint32;
+        description
+          "The number of prefixes received from the neighbor";
+      }
+
+      leaf sent {
+        type uint32;
+        description
+          "The number of prefixes advertised to the neighbor";
+      }
+
+      leaf installed {
+        type uint32;
+        description
+          "The number of advertised prefixes installed in the
+          Loc-RIB";
+      }
+    }
+  }
+
+  grouping bgp-neighbor-message-counters-sent_state {
+    description
+      "Counters relating to messages sent to a BGP neighbor";
+    uses bgp-counters-message-types_common;
+  }
+
+  grouping bgp-neighbor-message-counters-received_state {
+    description
+      "Counters relating to the mesages received from a BGP
+      neighbor";
+    uses bgp-counters-message-types_common;
+  }
+
+  grouping bgp-neighbor-queue-counters_state {
+    description
+      "Counters relating to the message queues associated with the
+      BGP peer";
+    leaf input {
+      type uint32;
+      description
+        "The number of messages received from the peer currently
+        queued";
+    }
+
+    leaf output {
+      type uint32;
+      description
+        "The number of messages queued to be sent to the peer";
+    }
+  }
+
+  grouping bgp-neighbor-transport_state {
+    description
+      "Operational state parameters relating to the transport session
+      used for the BGP session";
+
+    leaf local-port {
+      type inet:port-number;
+      description
+        "Local TCP port being used for the TCP session supporting
+        the BGP session";
+    }
+
+    leaf remote-address {
+      type inet:ip-address;
+      description
+        "Remote address to which the BGP session has been
+        established";
+    }
+
+    leaf remote-port {
+      type inet:port-number;
+      description
+        "Remote port being used by the peer for the TCP session
+        supporting the BGP session";
+    }
+  }
+
+  grouping bgp-neighbor-error-handling_state {
+    description
+      "Operational state parameters relating to enhanced error
+      error handling for BGP";
+
+    leaf erroneous-update-messages {
+      type uint32;
+      description
+        "The number of BGP UPDATE messages for which the
+        treat-as-withdraw mechanism has been applied based
+        on erroneous message contents";
+    }
+  }
+
+  grouping bgp-neighbor-timers_state {
+    description
+      "Operational state parameters relating to BGP timers associated
+      with the BGP session";
+
+    leaf uptime {
+      type yang:timeticks;
+      description
+        "This timer determines the amount of time since the
+        BGP last transitioned in or out of the Established
+        state";
+    }
+
+    leaf negotiated-hold-time {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      description
+        "The negotiated hold-time for the BGP session";
+    }
+  }
+
+  grouping bgp-afi-safi_state {
+    description
+      "Operational state information relevant to all address
+      families that may be carried by the BGP session";
+
+    // placeholder - options in this container are
+    // valid in both the global and per-neighbor
+    // paths
+
+  }
+
+  grouping bgp-afi-safi-graceful-restart_state {
+    description
+      "Operational state information relevant to graceful restart
+      for BGP";
+
+    leaf peer-restart-time {
+      type uint16 {
+        range 0..4096;
+      }
+      description
+        "The period of time (advertised by the peer) that
+        the peer expects a restart of a BGP session to
+        take";
+    }
+
+    leaf peer-restarting {
+      type boolean;
+      description
+        "This flag indicates whether the remote neighbor is currently
+        in the process of restarting, and hence received routes are
+        currently stale";
+    }
+
+    leaf local-restarting {
+      type boolean;
+      description
+        "This flag indicates whether the local neighbor is currently
+        restarting. The flag is unset after all NLRI have been
+        advertised to the peer, and the End-of-RIB (EOR) marker has
+        been unset";
+    }
+
+    leaf mode {
+      type enumeration {
+        enum HELPER-ONLY {
+          description
+            "The local router is operating in helper-only mode, and
+            hence will not retain forwarding state during a local
+            session restart, but will do so during a restart of the
+            remote peer";
+        }
+        enum BILATERAL {
+          description
+            "The local router is operating in both helper mode, and
+            hence retains forwarding state during a remote restart,
+            and also maintains forwarding state during local session
+            restart";
+        }
+        enum REMOTE-HELPER {
+          description
+            "The local system is able to retain routes during restart
+            but the remote system is only able to act as a helper";
+        }
+      }
+      description
+        "Ths leaf indicates the mode of operation of BGP graceful
+        restart with the peer";
+    }
+  }
+
+  grouping bgp-neighbor-afi-safi-graceful-restart_state {
+    description
+      "Operational state variables relating to the graceful-restart
+      mechanism on a per-AFI-SAFI basis";
+
+    leaf received {
+      type boolean;
+      description
+        "This leaf indicates whether the neighbor advertised the
+        ability to support graceful-restart for this AFI-SAFI";
+    }
+
+    leaf advertised {
+      type boolean;
+      description
+        "This leaf indicates whether the ability to support
+        graceful-restart has been advertised to the peer";
+    }
+  }
+
+
+}
+
+
diff --git a/bgp/openconfig-api/src/main/yang/bgp-policy.yang b/bgp/openconfig-api/src/main/yang/bgp-policy.yang
new file mode 100644 (file)
index 0000000..d217a29
--- /dev/null
@@ -0,0 +1,521 @@
+module bgp-policy {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/bgp-policy";
+
+  prefix "bgp-pol";
+
+  // import some basic types
+  import ietf-inet-types { prefix inet; }
+  import routing-policy {prefix rpol; }
+  import policy-types { prefix pt; }
+  import bgp-types { prefix bgp-types; }
+
+
+
+  // meta
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module contains data definitions for BGP routing policy.
+    It augments the base routing-policy module with BGP-specific
+    options for conditions and actions.";
+
+  revision "2015-05-15" {
+    description
+      "Updated model to augment base routing-policy module";
+    reference "TBD";
+  }
+
+  // extension statements
+
+  // feature statements
+
+  // identity statements
+
+  // typedef statements
+
+  typedef bgp-as-path-prepend-repeat {
+    type uint8;
+    description
+      "Option for the BGP as-prepend policy action.  Prepends the
+      local AS number repeated n times";
+  }
+
+  typedef bgp-set-community-option-type {
+    type enumeration {
+      enum ADD {
+        description
+          "add the specified communities to the existing
+          community attribute";
+      }
+      enum REMOVE {
+        description
+          "remove the specified communities from the
+          existing community attribute";
+      }
+      enum REPLACE {
+        description
+          "replace the existing community attribute with
+          the specified communities. If an empty set is
+          specified, this removes the community attribute
+          from the route.";
+      }
+    }
+    description
+      "Type definition for options when setting the community
+      attribute in a policy action";
+  }
+
+  typedef bgp-next-hop-type {
+    type union {
+      type inet:ip-address;
+      type enumeration {
+        enum SELF {
+          description "special designation for local router's own
+          address, i.e., next-hop-self";
+        }
+      }
+    }
+    description
+      "type definition for specifying next-hop in policy actions";
+  }
+
+  typedef bgp-set-med-type {
+    type union {
+      type uint32;
+      type string {
+        pattern "^[+-][0-9]+";
+      }
+      type enumeration {
+        enum IGP {
+          description "set the MED value to the IGP cost toward the
+          next hop for the route";
+        }
+      }
+    }
+    description
+      "Type definition for specifying how the BGP MED can
+      be set in BGP policy actions. The three choices are to set
+      the MED directly, increment/decrement using +/- notation,
+      and setting it to the IGP cost (predefined value).";
+  }
+
+  // grouping statements
+
+  grouping bgp-match-conditions {
+    description
+      "Condition statement definitions for checking membership in a
+      defined set";
+
+    container match-community-set {
+      presence
+        "The presence of this container indicates that the routes
+        should match the referenced community-set";
+
+      description
+        "Match a referenced community-set according to the logic
+        defined in the match-set-options leaf";
+
+      leaf community-set {
+        type leafref {
+          path "/rpol:routing-policy/rpol:defined-sets/" +
+            "bgp-pol:bgp-defined-sets/bgp-pol:community-sets/" +
+            "bgp-pol:community-set/bgp-pol:community-set-name";
+          //require-instance true;
+        }
+        description
+          "References a defined community set";
+      }
+      uses rpol:match-set-options-group;
+    }
+
+    container match-ext-community-set {
+      presence
+        "The presence of this container indicates that the routes
+        should match the referenced extended community set";
+
+      description
+        "Match a referenced extended community-set according to the
+        logic defined in the match-set-options leaf";
+
+      leaf ext-community-set {
+        type leafref {
+          path "/rpol:routing-policy/rpol:defined-sets/" +
+            "bgp-pol:bgp-defined-sets/bgp-pol:ext-community-sets/" +
+            "bgp-pol:ext-community-set/" +
+            "bgp-pol:ext-community-set-name";
+          //require-instance true;
+        }
+        description "References a defined extended community set";
+      }
+      uses rpol:match-set-options-group;
+    }
+
+    container match-as-path-set {
+      presence
+        "The presence of this container indicates that the route
+        should match the referenced as-path set";
+
+      description
+        "Match a referenced as-path set according to the logic
+        defined in the match-set-options leaf";
+
+      leaf as-path-set {
+        type leafref {
+          path "/rpol:routing-policy/rpol:defined-sets/" +
+            "bgp-pol:bgp-defined-sets/bgp-pol:as-path-sets/" +
+            "bgp-pol:as-path-set/bgp-pol:as-path-set-name";
+          //require-instance true;
+        }
+        description "References a defined AS path set";
+      }
+      uses rpol:match-set-options-group;
+    }
+  }
+
+  grouping bgp-attribute-conditions {
+    description
+      "Condition statement definitions for comparing a BGP route
+      attribute to a specified value";
+
+    leaf med-eq {
+      type uint32;
+      description
+        "Condition to check if the received MED value is equal to
+        the specified value";
+    }
+
+    leaf origin-eq {
+      type bgp-types:bgp-origin-attr-type;
+      description
+        "Condition to check if the route origin is equal to the
+        specified value";
+    }
+
+    leaf-list next-hop-in {
+      type inet:ip-address;
+      description
+        "List of next hop addresses to check for in the route
+        update";
+    }
+
+    leaf local-pref-eq {
+      type uint32;
+      // TODO: add support for other comparisons if needed
+      description
+        "Condition to check if the local pref attribute is equal to
+        the specified value";
+    }
+
+    container community-count {
+
+      presence "node is present in the config data to indicate a
+      community-count condition";
+
+      description
+        "Value and comparison operations for conditions based on the
+        number of communities in the route update";
+
+      uses pt:attribute-compare-operators;
+
+    }
+
+    container as-path-length {
+
+      presence "node is present in the config data to indicate a
+      as-path-length condition";
+
+      description
+        "Value and comparison operations for conditions based on the
+        length of the AS path in the route update";
+
+      uses pt:attribute-compare-operators;
+    }
+
+    leaf route-type {
+      // TODO: verify extent of vendor support for this comparison
+      type enumeration {
+        enum INTERNAL {
+          description "route type is internal";
+        }
+        enum EXTERNAL {
+          description "route type is external";
+        }
+      }
+      description
+        "Condition to check the route type in the route update";
+    }
+  }
+
+
+  // augment statements
+
+  augment "/rpol:routing-policy/rpol:defined-sets" {
+    description "adds BGP defined sets container to routing policy
+    model";
+
+    container bgp-defined-sets {
+      description
+        "BGP-related set definitions for policy match conditions";
+
+      container community-sets {
+        description
+          "Enclosing container for community sets";
+
+        list community-set {
+          key community-set-name;
+          description
+              "Definitions for community sets";
+
+          leaf community-set-name {
+            type string;
+            mandatory true;
+            description
+              "name / label of the community set -- this is used to
+              reference the set in match conditions";
+          }
+
+          leaf-list community-member {
+            type union {
+              type bgp-types:bgp-std-community-type;
+              type bgp-types:bgp-community-regexp-type;
+              type bgp-types:bgp-well-known-community-type;
+            }
+            description
+              "members of the community set";
+          }
+        }
+      }
+
+      container ext-community-sets {
+        description
+          "Enclosing container for extended community sets";
+
+        list ext-community-set {
+          key ext-community-set-name;
+          description
+              "Definitions for extended community sets";
+
+          leaf ext-community-set-name {
+            type string;
+            description
+              "name / label of the extended community set -- this is
+              used to reference the set in match conditions";
+          }
+
+          leaf-list ext-community-member {
+            type union {
+              type bgp-types:bgp-ext-community-type;
+              // TODO: is regexp support needed for extended
+              // communities?
+              type bgp-types:bgp-community-regexp-type;
+            }
+            description
+                "members of the extended community set";
+          }
+        }
+      }
+
+      container as-path-sets {
+        description
+          "Enclosing container for AS path sets";
+
+        list as-path-set {
+          key as-path-set-name;
+          description
+              "Definitions for AS path sets";
+
+          leaf as-path-set-name {
+            type string;
+            description
+              "name of the AS path set -- this is used to reference
+              the set in match conditions";
+          }
+
+          leaf-list as-path-set-member {
+            // TODO: need to refine typedef for AS path expressions
+            type string;
+            description
+                "AS path expression -- list of ASes in the set";
+          }
+        }
+      }
+    }
+  }
+
+  augment "/rpol:routing-policy/rpol:policy-definitions/" +
+    "rpol:policy-definition/rpol:statements/rpol:statement/" +
+    "rpol:conditions" {
+    description "BGP policy conditions added to routing policy
+    module";
+
+    container bgp-conditions {
+      description "Policy conditions for matching
+      BGP-specific defined sets or comparing BGP-specific
+      attributes";
+
+      uses bgp-match-conditions;
+      uses bgp-attribute-conditions;
+    }
+  }
+
+  augment "/rpol:routing-policy/rpol:policy-definitions/" +
+    "rpol:policy-definition/rpol:statements/rpol:statement/" +
+    "rpol:actions" {
+    description "BGP policy actions added to routing policy
+    module";
+
+    container bgp-actions {
+      description
+        "Definitions for policy action statements that
+        change BGP-specific attributes of the route";
+
+      container set-as-path-prepend {
+
+        presence "node is present in the config data to use the AS
+      prepend action";
+        description
+            "action to prepend local AS number to the AS-path a
+        specified number of times";
+
+        leaf repeat-n {
+          type uint8;
+          description "number of times to prepend the local AS
+          number";
+        }
+      }
+
+      container set-community {
+        presence "node is present in the config data when
+        set-community action is used";
+        description
+          "action to set the community attributes of the route, along
+          with options to modify how the community is modified";
+
+        choice set-community-method {
+          description
+            "Option to set communities using an inline list or
+            reference to an existing defined set.";
+
+          case inline {
+            leaf-list communities {
+              type union {
+                type bgp-types:bgp-std-community-type;
+                type bgp-types:bgp-well-known-community-type;
+              }
+              description
+                "Set the community values for the update inline with
+                a list.";
+            }
+          }
+          case reference {
+            leaf community-set-ref {
+              type leafref {
+                path "/rpol:routing-policy/rpol:defined-sets/" +
+                  "bgp-pol:bgp-defined-sets/" +
+                  "bgp-pol:community-sets/bgp-pol:community-set/" +
+                  "bgp-pol:community-set-name";
+                //require-instance true;
+              }
+              description
+                "References a defined community set by name";
+            }
+          }
+        }
+        leaf options {
+          type bgp-set-community-option-type;
+          description
+            "Options for modifying the community attribute with
+            the specified values.  These options apply to both
+            methods of setting the community attribute.";
+        }
+      }
+
+      container set-ext-community {
+
+        presence "node is present in the config data when
+        set-community action is used";
+        description
+          "Action to set the extended community attributes of the
+          route, along with options to modify how the community is
+          modified";
+
+        choice set-ext-community-method {
+          description
+            "Option to set communities using an inline list or
+            reference to an existing defined set.";
+
+          case inline {
+            leaf-list communities {
+              type union {
+                type bgp-types:bgp-ext-community-type;
+                type bgp-types:bgp-well-known-community-type;
+              }
+              description
+                "Set the community values for the update inline with
+                a list.";
+            }
+          }
+          case reference {
+            leaf ext-community-set-ref {
+              type leafref {
+                path "/rpol:routing-policy/rpol:defined-sets/" +
+                  "bgp-pol:bgp-defined-sets/" +
+                  "bgp-pol:ext-community-sets/" +
+                  "bgp-pol:ext-community-set/" +
+                  "bgp-pol:ext-community-set-name";
+                //require-instance true;
+              }
+              description
+                "References a defined extended community set by
+                name";
+            }
+          }
+        }
+        leaf options {
+          type bgp-set-community-option-type;
+          description
+            "options for modifying the extended community
+            attribute with the specified values. These options
+            apply to both methods of setting the community
+            attribute.";
+        }
+      }
+
+      leaf set-route-origin {
+        type bgp-types:bgp-origin-attr-type;
+        description "set the origin attribute to the specified
+        value";
+      }
+
+      leaf set-local-pref {
+        type uint32;
+        description "set the local pref attribute on the route
+        update";
+      }
+
+      leaf set-next-hop {
+        type bgp-next-hop-type;
+        description "set the next-hop attribute in the route update";
+      }
+
+      leaf set-med {
+        type bgp-set-med-type;
+        description "set the med metric attribute in the route
+        update";
+      }
+    }
+  }
+
+  // rpc statements
+
+  // notification statements
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/yang/bgp-types.yang b/bgp/openconfig-api/src/main/yang/bgp-types.yang
new file mode 100644 (file)
index 0000000..d609058
--- /dev/null
@@ -0,0 +1,356 @@
+module bgp-types {
+    yang-version "1";
+
+    namespace "http://openconfig.net/yang/bgp-types";
+
+    prefix "bgp-types";
+
+    import ietf-inet-types { prefix inet; }
+
+    // meta
+    organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module contains general data definitions for use in BGP
+    policy. It can be imported by modules that make use of BGP
+    attributes";
+
+  revision "2015-05-15" {
+    description "Initial revision";
+    reference "TBD";
+  }
+
+
+  identity bgp-capability {
+    description "Base identity for a BGP capability";
+  }
+
+  identity MPBGP {
+    base "bgp-capability";
+    description
+      "Multi-protocol extensions to BGP";
+    reference "RFC2858";
+  }
+
+  identity ROUTE-REFRESH {
+    base "bgp-capability";
+    description
+      "The BGP route-refresh functionality";
+    reference "RFC2918";
+  }
+
+  identity ASN32 {
+    base "bgp-capability";
+    description
+      "4-byte (32-bit) AS number functionality";
+    reference "RFC6793";
+  }
+
+  identity GRACEFUL-RESTART {
+    base "bgp-capability";
+    description
+      "Graceful restart functionality";
+    reference "RFC4724";
+  }
+
+  identity ADD-PATHS {
+    base "bgp-capability";
+    description
+      "BGP add-paths";
+    reference "draft-ietf-idr-add-paths";
+  }
+
+  identity afi-safi-type {
+    description
+      "Base identity type for AFI,SAFI tuples for BGP-4";
+    reference "RFC4760 - multiprotocol extensions for BGP-4";
+  }
+
+  identity ipv4-unicast {
+    base afi-safi-type;
+    description
+      "IPv4 unicast (AFI,SAFI = 1,1)";
+    reference "RFC4760";
+  }
+
+  identity ipv6-unicast {
+    base afi-safi-type;
+    description
+      "IPv6 unicast (AFI,SAFI = 2,1)";
+    reference "RFC4760";
+  }
+
+  identity ipv4-labelled-unicast {
+    base afi-safi-type;
+    description
+      "Labelled IPv4 unicast (AFI,SAFI = 1,4)";
+    reference "RFC3107";
+  }
+
+  identity ipv6-labelled-unicast {
+    base afi-safi-type;
+    description
+      "Labelled IPv6 unicast (AFI,SAFI = 2,4)";
+    reference "RFC3107";
+  }
+
+  identity l3vpn-ipv4-unicast {
+    base afi-safi-type;
+    description
+      "Unicast IPv4 MPLS L3VPN (AFI,SAFI = 1,128)";
+    reference "RFC4364";
+  }
+
+  identity l3vpn-ipv6-unicast {
+    base afi-safi-type;
+    description
+      "Unicast IPv6 MPLS L3VPN (AFI,SAFI = 2,128)";
+    reference "RFC4659";
+  }
+
+  identity l3vpn-ipv4-multicast {
+    base afi-safi-type;
+    description
+      "Multicast IPv4 MPLS L3VPN (AFI,SAFI = 1,129)";
+    reference "RFC6514";
+  }
+
+  identity l3vpn-ipv6-multicast {
+    base afi-safi-type;
+    description
+      "Multicast IPv6 MPLS L3VPN (AFI,SAFI = 2,129)";
+    reference "RFC6514";
+  }
+
+  identity l2vpn-vpls {
+    base afi-safi-type;
+    description
+      "BGP-signalled VPLS (AFI,SAFI = 25,65)";
+    reference "RFC4761";
+  }
+
+  identity l2vpn-evpn {
+    base afi-safi-type;
+    description
+      "BGP MPLS Based Ethernet VPN (AFI,SAFI = 25,70)";
+  }
+
+  identity bgp-well-known-std-community {
+    description
+      "Reserved communities within the standard community space
+      defined by RFC1997. These communities must fall within the
+      range 0x00000000 to 0xFFFFFFFF";
+    reference "RFC1997";
+  }
+
+  identity NO_EXPORT {
+    base bgp-well-known-std-community;
+    description
+      "Do not export NLRI received carrying this community outside
+      the bounds of this autonomous system, or this confederation if
+      the local autonomous system is a confederation member AS. This
+      community has a value of 0xFFFFFF01.";
+    reference "RFC1997";
+  }
+
+  identity NO_ADVERTISE {
+    base bgp-well-known-std-community;
+    description
+      "All NLRI received carrying this community must not be
+      advertised to other BGP peers. This community has a value of
+      0xFFFFFF02.";
+    reference "RFC1997";
+  }
+
+  identity NO_EXPORT_SUBCONFED {
+    base bgp-well-known-std-community;
+    description
+      "All NLRI received carrying this community must not be
+      advertised to external BGP peers - including over confederation
+      sub-AS boundaries. This community has a value of 0xFFFFFF03.";
+    reference "RFC1997";
+  }
+
+  identity NOPEER {
+    base bgp-well-known-std-community;
+    description
+      "An autonomous system receiving NLRI tagged with this community
+      is advised not to readvertise the NLRI to external bi-lateral
+      peer autonomous systems. An AS may also filter received NLRI
+      from bilateral peer sessions when they are tagged with this
+      community value";
+    reference "RFC3765";
+  }
+
+  identity INTERNET {
+    base bgp-well-known-std-community;
+    description
+      "A community used by some implementations with the value 0:0
+      which represents all possible community values.";
+  }
+
+  typedef bgp-session-direction {
+    type enumeration {
+      enum INBOUND {
+        description
+          "Refers to all NLRI received from the BGP peer";
+      }
+      enum OUTBOUND {
+        description
+          "Refers to all NLRI advertised to the BGP peer";
+      }
+    }
+    description
+      "Type to describe the direction of NLRI transmission";
+  }
+
+  typedef bgp-well-known-community-type {
+    type identityref {
+      base bgp-well-known-std-community;
+    }
+    description
+      "Type definition for well-known IETF community attribute
+      values";
+    reference
+      "IANA Border Gateway Protocol (BGP) Well Known Communities";
+  }
+
+
+  typedef bgp-std-community-type {
+    // TODO: further refine restrictions and allowed patterns
+    // 4-octet value:
+    //  <as number> 2 octets
+    //  <community value> 2 octets
+    type union {
+      type uint32 {
+      // per RFC 1997, 0x00000000 - 0x0000FFFF and 0xFFFF0000 -
+      // 0xFFFFFFFF are reserved
+        range "65536..4294901759"; // 0x00010000..0xFFFEFFFF
+      }
+      type string {
+        pattern '([0-9]+:[0-9]+)';
+      }
+    }
+    description
+      "Type definition for standard commmunity attributes";
+    reference "RFC 1997 - BGP Communities Attribute";
+  }
+
+  typedef bgp-ext-community-type {
+    // TODO: needs more work to make this more precise given the
+    // variability of extended community attribute specifications
+    // 8-octet value:
+    //  <type> 2 octects
+    //  <value> 6 octets
+    type string {
+      pattern '([0-9\.]+(:[0-9]+)?:[0-9]+)';
+    }
+    description
+      "Type definition for extended community attributes";
+    reference "RFC 4360 - BGP Extended Communities Attribute";
+  }
+
+  typedef bgp-community-regexp-type {
+    // TODO: needs more work to decide what format these regexps can
+    // take.
+    type string;
+    description
+      "Type definition for communities specified as regular
+      expression patterns";
+  }
+
+  typedef bgp-origin-attr-type {
+    type enumeration {
+      enum IGP {
+        description "Origin of the NLRI is internal";
+      }
+      enum EGP {
+        description "Origin of the NLRI is EGP";
+      }
+      enum INCOMPLETE {
+        description "Origin of the NLRI is neither IGP or EGP";
+      }
+    }
+    description
+      "Type definition for standard BGP origin attribute";
+    reference "RFC 4271 - A Border Gateway Protocol 4 (BGP-4),
+      Sec 4.3";
+  }
+
+  typedef peer-type {
+    type enumeration {
+      enum INTERNAL {
+        description "internal (iBGP) peer";
+      }
+      enum EXTERNAL {
+        description "external (eBGP) peer";
+      }
+    }
+    description
+      "labels a peer or peer group as explicitly internal or
+      external";
+  }
+
+
+  typedef remove-private-as-option {
+    type enumeration {
+      enum ALL {
+        description "remove all private ASes in the path";
+      }
+      enum REPLACE {
+        description "replace private ASes with local AS";
+      }
+    }
+    description
+      "set of options for configuring how private AS path numbers
+      are removed from advertisements";
+  }
+
+  typedef percentage {
+    type uint8 {
+      range "0..100";
+    }
+    description
+      "Integer indicating a percentage value";
+  }
+
+  typedef rr-cluster-id-type {
+    type union {
+      type uint32;
+      type inet:ipv4-address;
+    }
+    description
+      "union type for route reflector cluster ids:
+      option 1: 4-byte number
+      option 2: IP address";
+  }
+
+  typedef community-type {
+    type enumeration {
+      enum STANDARD {
+        description "send only standard communities";
+      }
+      enum EXTENDED {
+        description "send only extended communities";
+      }
+      enum BOTH {
+        description "send both standard and extended communities";
+      }
+      enum NONE {
+        description "do not send any community attribute";
+      }
+    }
+    description
+      "type describing variations of community attributes:
+      STANDARD: standard BGP community [rfc1997]
+      EXTENDED: extended BGP community [rfc4360]
+      BOTH: both standard and extended community";
+  }
+
+
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/main/yang/bgp.yang b/bgp/openconfig-api/src/main/yang/bgp.yang
new file mode 100644 (file)
index 0000000..de8d26f
--- /dev/null
@@ -0,0 +1,1019 @@
+module bgp {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/bgp";
+
+  prefix "bgp";
+
+  // import some basic inet types
+  import ietf-inet-types { prefix inet; }
+  import bgp-multiprotocol { prefix bgp-mp; }
+  import routing-policy { prefix rpol; }
+  import bgp-types { prefix bgp-types; }
+  import bgp-operational { prefix bgp-op; }
+
+  // meta
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module describes a YANG model for BGP protocol
+    configuration.It is a limited subset of all of the configuration
+    parameters available in the variety of vendor implementations,
+    hence it is expected that it would be augmented with vendor-
+    specific configuration data as needed. Additional modules or
+    submodules to handle other aspects of BGP configuration,
+    including policy, VRFs, VPNs, and additional address families
+    are also expected.
+
+    This model supports the following BGP configuration level
+    hierarchy:
+
+      BGP
+        |
+        +-> [ global BGP configuration ]
+          +-> AFI / SAFI global
+        +-> peer group
+          +-> [ peer group config ]
+          +-> AFI / SAFI [ per-AFI overrides ]
+        +-> neighbor
+          +-> [ neighbor config ]
+          +-> [ optional pointer to peer-group ]
+          +-> AFI / SAFI [ per-AFI overrides ]";
+
+  revision "2015-05-15" {
+      description
+        "";
+      reference "TBD";
+  }
+
+  grouping bgp-global_config {
+    description
+      "Global configuration options for the BGP router.";
+
+    leaf as {
+      type inet:as-number;
+      mandatory "true";
+      description
+        "Local autonomous system number of the router.  Uses
+        the 32-bit as-number type from the model in RFC 6991.";
+    }
+    leaf router-id {
+      type inet:ipv4-address;
+      description
+        "Router id of the router, expressed as an
+        32-bit value, IPv4 address.";
+    }
+  }
+
+  grouping bgp-default-route-distance_config {
+    description
+      "Configuration options relating to the administrative distance
+      (or preference) assigned to routes received from different
+      sources (external, internal, and local).";
+
+    leaf external-route-distance {
+      type uint8 {
+        range "1..255";
+      }
+      description
+        "Administrative distance for routes learned from external
+        BGP (eBGP).";
+    }
+    leaf internal-route-distance {
+      type uint8 {
+        range "1..255";
+      }
+      description
+        "Administrative distance for routes learned from internal
+        BGP (iBGP).";
+    }
+  }
+
+  grouping bgp-confederation_config {
+    description
+      "Configuration options specifying parameters when the local
+      router is within an autonomous system which is part of a BGP
+      confederation.";
+
+    leaf enabled {
+      type boolean;
+      description
+        "When this leaf is set to true it indicates that
+        the local-AS is part of a BGP confederation";
+    }
+
+    leaf identifier {
+      type inet:as-number;
+      description
+        "Confederation identifier for the autonomous system.";
+    }
+
+    leaf-list member-as {
+      type inet:as-number;
+      description
+        "Remote autonomous systems that are to be treated
+        as part of the local confederation.";
+    }
+  }
+
+  grouping bgp-neighbor_config {
+    description
+      "Neighbor level configuration items.";
+
+    leaf peer-as {
+      type inet:as-number;
+      description
+        "AS number of the peer.";
+    }
+
+    leaf local-as {
+      type inet:as-number;
+      description
+        "The local autonomous system number that is to be used
+        when establishing sessions with the remote peer or peer
+        group, if this differs from the global BGP router
+        autonomous system number.";
+    }
+
+    leaf peer-type {
+        type bgp-types:peer-type;
+        description
+          "Explicitly designate the peer or peer group as internal
+          (iBGP) or external (eBGP).";
+    }
+
+    leaf auth-password {
+      type string;
+      description
+        "Configures an MD5 authentication password for use with
+        neighboring devices.";
+    }
+
+    leaf remove-private-as {
+      // could also make this a container with a flag to enable
+      // remove-private and separate option.  here, option implies
+      // remove-private is enabled.
+      type bgp-types:remove-private-as-option;
+      description
+        "Remove private AS numbers from updates sent to peers.";
+    }
+
+    leaf route-flap-damping {
+      type boolean;
+      default false;
+      description
+        "Enable route flap damping.";
+    }
+
+    leaf send-community {
+      type bgp-types:community-type;
+      default "NONE";
+      description
+        "Specify which types of community should be sent to the
+        neighbor or group. The default is to not send the
+        community attribute";
+    }
+
+    leaf description {
+      type string;
+      description
+        "An optional textual description (intended primarily for use
+        with a peer or group";
+    }
+  }
+
+  grouping bgp-neighbor-timers_config {
+    description
+      "Config parameters related to timers associated with the BGP
+      peer";
+
+    leaf connect-retry {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      default 30;
+      description
+        "Time interval in seconds between attempts to establish a
+        session with the peer.";
+    }
+
+    leaf hold-time {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      default 90;
+      description
+        "Time interval in seconds that a BGP session will be
+        considered active in the absence of keepalive or other
+        messages from the peer.  The hold-time is typically
+        set to 3x the keepalive-interval.";
+      reference
+        "RFC 4271 - A Border Gateway Protocol 4, Sec. 10";
+    }
+
+    leaf keepalive-interval {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      default 30;
+      description
+        "Time interval in seconds between transmission of keepalive
+        messages to the neighbor.  Typically set to 1/3 the
+        hold-time.";
+    }
+
+    leaf minimum-advertisement-interval {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      default 30;
+      description
+        "Minimum time which must elapse between subsequent UPDATE
+        messages relating to a common set of NLRI being transmitted
+        to a peer. This timer is referred to as
+        MinRouteAdvertisementIntervalTimer by RFC 4721 and serves to
+        reduce the number of UPDATE messages transmitted when a
+        particular set of NLRI exhibit instability.";
+      reference
+        "RFC 4271 - A Border Gateway Protocol 4, Sec 9.2.1.1";
+    }
+  }
+
+  grouping bgp-neighbor-transport_config {
+    description
+      "Configuration parameters relating to the transport protocol
+      used by the BGP session to the peer";
+
+    leaf tcp-mss {
+      type uint16;
+      description
+        "Sets the max segment size for BGP TCP sessions.";
+    }
+
+    leaf mtu-discovery {
+      type boolean;
+      default false;
+      description
+        "Turns path mtu discovery for BGP TCP sessions on (true)
+        or off (false)";
+    }
+
+    leaf passive-mode {
+      type boolean;
+      default false;
+      description
+        "Wait for peers to issue requests to open a BGP session,
+        rather than initiating sessions from the local router.";
+    }
+
+    leaf local-address {
+      type union {
+        type inet:ip-address;
+        type string;
+      }
+      //TODO:  the string should be converted to a leafref type
+      //to point to an interface when YANG 1.1 is available with
+      //leafrefs in union types.
+      description
+        "Set the local IP (either IPv4 or IPv6) address to use
+        for the session when sending BGP update messages.  This
+        may be expressed as either an IP address or reference
+        to the name of an interface.";
+    }
+  }
+
+  grouping bgp-neighbor-error-handling_config {
+    description
+      "Configuration parameters relating to enhanced error handling
+      behaviours for BGP";
+
+    leaf treat-as-withdraw {
+      type boolean;
+      default "false";
+      description
+        "Specify whether erroneous UPDATE messages for which the
+        NLRI can be extracted are reated as though the NLRI is
+        withdrawn - avoiding session reset";
+      reference "draft-ietf-idr-error-handling-16";
+    }
+  }
+
+  grouping bgp-neighbor-logging-options_config {
+    description
+      "Configuration parameters specifying the logging behaviour for
+      BGP sessions to the peer";
+
+    leaf log-neighbor-state-changes {
+      type boolean;
+      default "true";
+      description
+        "Configure logging of peer state changes.  Default is
+        to enable logging of peer state changes.";
+    }
+  }
+
+  grouping bgp-neighbor-multihop_config {
+    description
+      "Configuration parameters specifying the multihop behaviour for
+      BGP sessions to the peer";
+
+    leaf enabled {
+      type boolean;
+      default "false";
+      description
+        "When enabled the referenced group or neighbors are permitted
+        to be indirectly connected - including cases where the TTL
+        can be decremented between the BGP peers";
+    }
+
+    leaf multihop-ttl {
+      type uint8;
+      description
+        "Time-to-live value to use when packets are sent to the
+        referenced group or neighbors and ebgp-multihop is enabled";
+    }
+  }
+
+  grouping bgp-neighbor-route-reflector_config {
+    description
+      "Configuration parameters determining whether the behaviour of
+      the local system when acting as a route-reflector";
+
+    leaf route-reflector-cluster-id {
+      type bgp-types:rr-cluster-id-type;
+      description
+        "route-reflector cluster id to use when local router is
+        configured as a route reflector.  Commonly set at the group
+        level, but allows a different cluster
+        id to be set for each neighbor.";
+    }
+
+    leaf route-reflector-client {
+      type boolean;
+      default "false";
+      description
+        "Configure the neighbor as a route reflector client.";
+    }
+  }
+
+  grouping bgp-neighbor-as-path-options_config {
+    description
+      "Configuration parameters allowing manipulation of the AS_PATH
+      attribute";
+
+    leaf allow-own-as {
+      type uint8;
+      default 0;
+      description
+        "Specify the number of occurrences of the local BGP speaker's
+        AS that can occur within the AS_PATH before it is rejected.";
+    }
+
+    leaf replace-peer-as {
+      type boolean;
+      default "false";
+      description
+        "Replace occurrences of the peer's AS in the AS_PATH
+        with the local autonomous system number";
+    }
+  }
+
+  grouping bgp-neighbor-add-paths_config {
+    description
+      "Configuration parameters specfying whether the local system
+      will send or receive multiple paths using ADD_PATHS";
+
+    leaf receive {
+      type boolean;
+      default false;
+      description
+        "Enable ability to receive multiple path advertisements
+        for an NLRI from the neighbor or group";
+    }
+
+    leaf send-max {
+      type uint8;
+      description
+        "The maximum number of paths to advertise to neighbors
+        for a single NLRI";
+    }
+  }
+
+  grouping bgp-neighbor-peer-group_config {
+    description
+      "Configuration parameters indicating whether the specified peer
+      is to be considered as part of a peer-group - and therefore
+      inherit its configuration";
+
+    leaf peer-group {
+      type leafref {
+        // we are at /bgp/neighbors/neighbor/
+        path "/bgp/peer-groups/peer-group/peer-group-name";
+        //require-instance true;
+      }
+      description
+        "The peer-group with which this neighbor is associated";
+    }
+  }
+
+  grouping bgp-graceful-restart {
+    description
+      "Configures BGP graceful restart, which is a negotiated
+      option that indicates that a BGP speaker is able to retain
+      forwarding state when a BGP session restarts";
+
+    reference "RFC 4724: Graceful Restart Mechanism for BGP";
+    container graceful-restart {
+      description
+        "Parameters relating the graceful restart mechanism for BGP";
+      container config {
+        description
+          "Configuration parameters relating to graceful-restart";
+        uses bgp-neighbor-graceful-restart_config;
+      }
+      container state {
+        config false;
+        description
+          "State information associated with graceful-restart";
+        uses bgp-neighbor-graceful-restart_config;
+      }
+    }
+  }
+
+  grouping bgp-neighbor-graceful-restart_config {
+    description
+      "Configuration parameters relating to BGP graceful restart.";
+
+    leaf enabled {
+      type boolean;
+      description
+        "Enable or disable the graceful-restart capability.";
+    }
+
+    leaf restart-time {
+      type uint16 {
+        range 0..4096;
+      }
+      description
+        "Estimated time (in seconds) for the local BGP speaker to
+        restart a session. This value is advertise in the graceful
+        restart BGP capability.  This is a 12-bit value, referred to
+        as Restart Time in RFC4724.  Per RFC4724, the suggested
+        default value is <= the hold-time value.";
+    }
+
+    leaf stale-routes-time {
+      type decimal64 {
+        fraction-digits 2;
+      }
+      description
+        "An upper-bound on the time thate stale routes will be
+        retained by a router after a session is restarted. If an
+        End-of-RIB (EOR) marker is received prior to this timer
+        expiring stale-routes will be flushed upon its receipt - if
+        no EOR is received, then when this timer expires stale paths
+        will be purged. This timer is referred to as the
+        Selection_Deferral_Timer in RFC4724";
+    }
+
+    leaf helper-only {
+      type boolean;
+      description
+        "Enable graceful-restart in helper mode only. When this
+        leaf is set, the local system does not retain forwarding
+        its own state during a restart, but supports procedures
+        for the receiving speaker, as defined in RFC4724.";
+    }
+  }
+
+  // ************************************************************
+  // *              configuration context containers            *
+  // ************************************************************
+
+  grouping bgp-global-base {
+    description
+      "Global configuration parameters for the BGP router";
+
+    container config {
+      description
+        "Configuration parameters relating to the global BGP router";
+      uses bgp-global_config;
+    }
+    container state {
+      config false;
+      description
+        "State information relating to the global BGP router";
+      uses bgp-global_config;
+      uses bgp-op:bgp-global_state;
+    }
+
+    uses bgp-mp:bgp-route-selection-options;
+
+    container default-route-distance {
+      description
+        "Administrative distance (or preference) assigned to
+        routes received from different sources
+        (external, internal, and local).";
+
+      container config {
+        description
+          "Configuration parameters relating to the default route
+          distance";
+        uses bgp-default-route-distance_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the default route distance";
+        uses bgp-default-route-distance_config;
+      }
+    }
+
+    container confederation {
+      description
+        "Parameters indicating whether the local system acts as part
+        of a BGP confederation";
+
+      container config {
+        description
+          "Configuration parameters relating to BGP confederations";
+        uses bgp-confederation_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the BGP confederations";
+        uses bgp-confederation_config;
+      }
+    }
+
+    uses bgp-mp:bgp-use-multiple-paths;
+
+    uses bgp-graceful-restart;
+
+    container afi-safis {
+      description
+        "Address family specific configuration";
+      uses bgp-mp:bgp-common-afi-safi-list;
+    }
+  }
+
+  grouping bgp-neighbors {
+    description
+      "BGP neighbors configured on the local system";
+    list neighbor {
+      key "neighbor-address";
+      description
+        "List of BGP neighbors configured on the local system,
+        uniquely identified by peer IPv[46] address";
+
+      leaf neighbor-address {
+        type inet:ip-address;
+        description
+          "Reference to the address of the BGP neighbor used as
+          a key in the neighbor list";
+      }
+
+      uses bgp-neighbor-group;
+    }
+  }
+
+  grouping bgp-peer-group {
+    description
+      "BGP peer-groups configured on the local system";
+    list peer-group {
+      key "peer-group-name";
+      description
+        "List of BGP peer-groups configured on the local system -
+        uniquely identified by peer-group name";
+
+    leaf peer-group-name {
+        type string;
+      description
+        "Reference to the name of the BGP peer-group used as a
+        key in the peer-group list";
+      }
+
+      uses bgp-neighbor-group;
+    }
+  }
+
+  grouping bgp-neighbor-group {
+    description
+      "Parameters related to a BGP neighbor or group";
+
+    container config {
+      description
+        "Configuration parameters relating to the BGP neighbor or
+        group";
+      uses bgp-neighbor_config;
+    }
+    container state {
+      config false;
+      description
+        "State information relating to the BGP neighbor or group";
+      uses bgp-neighbor_config;
+    }
+
+    container timers {
+      description
+        "Timers related to a BGP neighbor or group";
+      container config {
+        description
+          "Configuration parameters relating to timers used for the
+          BGP neighbor or group";
+        uses bgp-neighbor-timers_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the timers used for the BGP
+          neighbor or group";
+        uses bgp-neighbor-timers_config;
+      }
+    }
+
+    container transport {
+      description
+        "Transport session parameters for the BGP neighbor or group";
+      container config {
+        description
+          "Configuration parameters relating to the transport
+          session(s) used for the BGP neighbor or group";
+        uses bgp-neighbor-transport_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the transport session(s)
+          used for the BGP neighbor or group";
+        uses bgp-neighbor-transport_config;
+      }
+    }
+
+    container error-handling {
+      description
+        "Error handling parameters used for the BGP neighbor or
+        group";
+      container config {
+        description
+          "Configuration parameters enabling or modifying the
+          behavior or enhanced error handling mechanisms for the BGP
+          neighbor or group";
+        uses bgp-neighbor-error-handling_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to enhanced error handling
+          mechanisms for the BGP neighbor or group";
+        uses bgp-neighbor-error-handling_config;
+      }
+    }
+
+    container logging-options {
+      description
+        "Logging options for events related to the BGP neighbor or
+        group";
+      container config {
+        description
+          "Configuration parameters enabling or modifying logging
+          for events relating to the BGP neighbor or group";
+        uses bgp-neighbor-logging-options_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to logging for the BGP neighbor
+          or group";
+        uses bgp-neighbor-logging-options_config;
+      }
+    }
+
+    container ebgp-multihop {
+      description
+        "eBGP multi-hop parameters for the BGP neighbor or group";
+      container config {
+        description
+          "Configuration parameters relating to eBGP multihop for the
+          BGP neighbor or group";
+        uses bgp-neighbor-multihop_config;
+      }
+      container state {
+        config false;
+        description
+          "State information for eBGP multihop, for the BGP neighbor
+          or group";
+        uses bgp-neighbor-multihop_config;
+      }
+    }
+
+    container route-reflector {
+      description
+        "Route reflector parameters for the BGP neighbor or group";
+      container config {
+        description
+          "Configuraton parameters relating to route reflection
+          for the BGP neighbor or group";
+        uses bgp-neighbor-route-reflector_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to route reflection for the
+          BGP neighbor or group";
+        uses bgp-neighbor-route-reflector_config;
+      }
+    }
+
+    container as-path-options {
+      description
+        "AS_PATH manipulation parameters for the BGP neighbor or
+        group";
+      container config {
+        description
+          "Configuration parameters relating to AS_PATH manipulation
+          for the BGP peer or group";
+        uses bgp-neighbor-as-path-options_config;
+      }
+      container state {
+        config false;
+        description
+          "State information relating to the AS_PATH manipulation
+          mechanisms for the BGP peer or group";
+        uses bgp-neighbor-as-path-options_config;
+      }
+    }
+
+    container add-paths {
+      description
+        "Parameters relating to the advertisement and receipt of
+        multiple paths for a single NLRI (add-paths)";
+      container config {
+        description
+          "Configuration parameters relating to ADD_PATHS";
+        uses bgp-neighbor-add-paths_config;
+      }
+      container state {
+        config false;
+        description
+          "State information associated with ADD_PATHS";
+        uses bgp-neighbor-add-paths_config;
+      }
+    }
+
+    container afi-safis {
+      description
+        "Per-address-family configuration parameters associated with
+        the neighbor or group";
+      uses bgp-mp:bgp-common-afi-safi-list;
+    }
+
+    uses bgp-graceful-restart;
+
+    uses rpol:apply-policy-group;
+  }
+
+  grouping bgp-neighbor-neighbor-address_config {
+    description
+      "Configuration options relating to the BGP neighbor address";
+
+    leaf neighbor-address {
+        type inet:ip-address;
+        description
+          "Address of the BGP peer, either in IPv4 or IPv6";
+    }
+  }
+
+  grouping bgp-peer-group-peer-group-name_config {
+    description
+      "Configuration options relating to the BGP peer-group name";
+
+    leaf peer-group-name {
+      type string;
+      description
+        "Name of the BGP peer-group";
+    }
+  }
+
+  // add peer-group pointer only for the neighbor list
+  augment /bgp/neighbors/neighbor/config {
+    description
+      "Augmentation to allow association of a neighbor with a
+      peer-group";
+    uses bgp-neighbor-peer-group_config;
+  }
+
+  augment /bgp/neighbors/neighbor/state {
+    description
+      "Augmentation to reflect the association of a neighbor with a
+      peer-group";
+    uses bgp-neighbor-peer-group_config;
+  }
+
+  augment /bgp/peer-groups/peer-group {
+    description
+      "Augmentation to add multipath configuration to a peer-group";
+    uses bgp-mp:bgp-use-multiple-paths;
+  }
+
+  augment /bgp/neighbors/neighbor {
+    description
+      "Augmentation to add the multipath configuration to a
+      neighbor";
+    uses bgp-mp:bgp-use-multiple-paths-neighbor;
+  }
+
+  augment /bgp/peer-groups/peer-group/afi-safis/afi-safi {
+    description
+      "Augmentation to add multipath configuration to a peer-group
+      on a per-AFI-SAFI basis";
+    uses bgp-mp:bgp-use-multiple-paths;
+  }
+
+  augment /bgp/neighbors/neighbor/afi-safis/afi-safi {
+    description
+      "Augmentation to add multipath configuration to a neighbor
+      on a per-AFI-SAFI basis";
+    uses bgp-mp:bgp-use-multiple-paths-neighbor;
+  }
+
+  augment /bgp/global/afi-safis/afi-safi {
+    description
+      "Augmentation to add global instance specific AFI-SAFI
+      configuration information";
+    uses bgp-mp:bgp-global-afi-safi;
+    uses bgp-mp:bgp-use-multiple-paths;
+  }
+
+  augment /bgp/peer-groups/peer-group/afi-safis/afi-safi {
+    description
+      "Augmentation that adds peer-group instance specific
+      AFI-SAFI configuration information";
+    uses bgp-mp:bgp-group-afi-safi;
+  }
+
+  augment /bgp/neighbors/neighbor/config {
+    description
+      "Augmentation adding the neighbor address to the
+      neighbor configuration container";
+    uses bgp-neighbor-neighbor-address_config;
+  }
+
+  augment /bgp/neighbors/neighbor/state {
+    description
+      "Augmentation adding the neighbor address to the
+      neighbor state container";
+    uses bgp-neighbor-neighbor-address_config;
+  }
+
+  augment /bgp/peer-groups/peer-group/config {
+    description
+      "Augmentation adding the peer-group name to the
+      peer-group configuration container";
+    uses bgp-peer-group-peer-group-name_config;
+  }
+
+  augment /bgp/peer-groups/peer-group/state {
+    description
+      "Augmentation adding the peer-group name to the
+      peer-group state container";
+    uses bgp-peer-group-peer-group-name_config;
+  }
+
+  // ************************************************************
+  // *              Augmentations to add state                  *
+  // *  (rjs: cleaner to have these in the base module to avoid *
+  //     needing to specify which module - e.g. augment of      *
+  //     /bgp:bgp/bgp:neighbors/bgp:neighbor...)                *
+  // ************************************************************
+  augment /bgp/neighbors/neighbor/state {
+    description
+      "Augmentation to add operational state related to a particular
+      BGP neighbor";
+    uses bgp-op:bgp-neighbor_state;
+  }
+
+  augment /bgp/neighbors/bgp:neighbor/state {
+    description
+      "Augmentation to add operational state related to a particular
+      BGP neighbor";
+
+    container messages {
+      description
+        "Counters for BGP messages sent and received from the
+        neighbor";
+      container sent {
+        description
+          "Counters relating to BGP messages sent to the neighbor";
+        uses bgp-op:bgp-neighbor-message-counters-sent_state;
+        }
+
+      container received {
+        description
+          "Counters for BGP messages received from the neighbor";
+        uses bgp-op:bgp-neighbor-message-counters-received_state;
+      }
+    }
+
+    container queues {
+      description
+        "Counters related to queued messages associated with the
+        BGP neighbor";
+      uses bgp-op:bgp-neighbor-queue-counters_state;
+    }
+  }
+
+  augment /bgp:bgp/bgp:neighbors/neighbor/timers/state {
+    description
+      "Augmentation to add the operational state of timers associated
+      with the BGP neighbor";
+    uses bgp-op:bgp-neighbor-timers_state;
+  }
+
+  augment /bgp/neighbors/neighbor/transport/state {
+    description
+      "Augmentation to add the operational state of the transport
+      session associated with the BGP neighbor";
+    uses bgp-op:bgp-neighbor-transport_state;
+  }
+
+  augment /bgp/neighbors/neighbor/error-handling/state {
+    description
+      "Augmentation to add the operational state of the error
+      handling associated with the BGP neighbor";
+    uses bgp-op:bgp-neighbor-error-handling_state;
+  }
+
+  augment /bgp/neighbors/neighbor/graceful-restart/state {
+    description
+      "Augmentation to add the operational state of graceful-restart
+      associated with a BGP neighbor";
+    uses bgp-op:bgp-afi-safi-graceful-restart_state;
+  }
+
+  augment /bgp/peer-groups/peer-group/state {
+    description
+      "Augmentation to add the operational state and counters
+      relating to a BGP peer-group";
+    uses bgp-op:bgp-peer-group_state;
+  }
+
+  augment /bgp/global/afi-safis/afi-safi/state {
+    description
+      "Augmentation to add operational state and counters
+      on a per-AFI-SAFI basis to the global BGP router";
+    uses bgp-op:bgp-global-afi-safi_state;
+  }
+
+  augment /bgp/neighbors/neighbor/afi-safis/afi-safi/state {
+    description
+      "Augmentation to add per-AFI-SAFI operational state
+      and counters to the BGP neighbor";
+    uses bgp-op:bgp-neighbor-afi-safi_state;
+  }
+
+  augment "/bgp/neighbors/neighbor/afi-safis/afi-safi/" +
+    "graceful-restart/state" {
+    description
+      "Augmentation to add per-AFI-SAFI operational state for BGP
+      graceful-restart";
+    uses bgp-op:bgp-neighbor-afi-safi-graceful-restart_state;
+  }
+
+  // ************************************************************
+  // *              module structure containers                 *
+  // ************************************************************
+
+  container bgp {
+    presence "Container for BGP protocol hierarchy";
+    description
+      "Top-level configuration and state for the BGP router";
+
+    container global {
+      description
+        "Global configuration for the BGP router";
+        uses bgp-global-base;
+        uses rpol:apply-policy-group;
+    }
+
+    container neighbors {
+      description
+        "Configuration for BGP neighbors";
+      uses bgp-neighbors;
+    }
+
+    container peer-groups {
+      description
+        "Configuration for BGP peer-groups";
+      uses bgp-peer-group;
+    }
+  }
+}
diff --git a/bgp/openconfig-api/src/main/yang/policy-types.yang b/bgp/openconfig-api/src/main/yang/policy-types.yang
new file mode 100644 (file)
index 0000000..5db18f3
--- /dev/null
@@ -0,0 +1,176 @@
+module policy-types {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/policy-types";
+
+  prefix "ptypes";
+
+  // import some basic types
+  import ietf-yang-types { prefix yang; }
+
+
+  // meta
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module contains general data definitions for use in routing
+    policy.  It can be imported by modules that contain protocol-
+    specific policy conditions and actions.";
+
+  revision "2015-05-15" {
+    description
+      "Initial revision";
+    reference "TBD";
+  }
+
+  // identity statements
+
+  identity attribute-comparison {
+    description
+      "base type for supported comparison operators on route
+      attributes";
+  }
+
+  identity attribute-eq {
+    base attribute-comparison;
+    description "== comparison";
+  }
+
+  identity attribute-ge {
+    base attribute-comparison;
+    description ">= comparison";
+  }
+
+  identity attribute-le {
+    base attribute-comparison;
+    description "<= comparison";
+  }
+
+  typedef match-set-options-type {
+    type enumeration {
+      enum ANY {
+        description "match is true if given value matches any member
+        of the defined set";
+      }
+      enum ALL {
+        description "match is true if given value matches all
+        members of the defined set";
+      }
+      enum INVERT {
+        description "match is true if given value does not match any
+        member of the defined set";
+      }
+    }
+    default ANY;
+    description
+      "Options that govern the behavior of a match statement.  The
+      default behavior is ANY, i.e., the given value matches any
+      of the members of the defined set";
+  }
+
+  typedef match-set-options-restricted-type {
+    type enumeration {
+      enum ANY {
+        description "match is true if given value matches any member
+        of the defined set";
+      }
+      enum INVERT {
+        description "match is true if given value does not match any
+        member of the defined set";
+      }
+    }
+    default ANY;
+    description
+      "Options that govern the behavior of a match statement.  The
+      default behavior is ANY, i.e., the given value matches any
+      of the members of the defined set.  Note this type is a
+      restricted version of the match-set-options-type.";
+      //TODO: restriction on enumerated types is only allowed in
+      //YANG 1.1.  Until then, we will require this additional type
+  }
+
+  grouping attribute-compare-operators {
+    description "common definitions for comparison operations in
+    condition statements";
+
+    leaf operator {
+        type identityref {
+          base attribute-comparison;
+        }
+        description
+          "type of comparison to be performed";
+      }
+
+    leaf value {
+      type uint32;
+      description
+        "value to compare with the community count";
+    }
+  }
+
+  typedef tag-type {
+    type union {
+      type uint32;
+      type string;
+    }
+    description "type for expressing route tags on a local system,
+    including IS-IS and OSPF; may be expressed as either decimal or
+    hexidecimal integer";
+    reference
+      "RFC 2178 OSPF Version 2
+      RFC 5130 A Policy Control Mechanism in IS-IS Using
+      Administrative Tags";
+  }
+
+  identity install-protocol-type {
+    description
+      "Base type for protocols which can install prefixes into the
+      RIB";
+  }
+
+  identity BGP {
+    base install-protocol-type;
+    description "BGP";
+    reference "RFC 4271";
+  }
+
+  identity ISIS {
+    base install-protocol-type;
+    description "IS-IS";
+    reference "ISO/IEC 10589";
+  }
+
+  identity OSPF {
+    base install-protocol-type;
+    description "OSPFv2";
+    reference "RFC 2328";
+  }
+
+  identity OSPF3 {
+    base install-protocol-type;
+    description "OSPFv3";
+    reference "RFC 5340";
+  }
+
+  identity STATIC {
+    base install-protocol-type;
+    description "Locally-installed static route";
+  }
+
+  identity DIRECTLY-CONNECTED {
+    base install-protocol-type;
+    description "A directly connected route";
+  }
+
+  identity LOCAL-AGGREGATE {
+    base install-protocol-type;
+    description "Locally defined aggregate route";
+  }
+}
diff --git a/bgp/openconfig-api/src/main/yang/routing-policy.yang b/bgp/openconfig-api/src/main/yang/routing-policy.yang
new file mode 100644 (file)
index 0000000..32cb578
--- /dev/null
@@ -0,0 +1,589 @@
+module routing-policy {
+
+  yang-version "1";
+
+  // namespace
+  namespace "http://openconfig.net/yang/routing-policy";
+
+  prefix "rpol";
+
+  // import some basic types
+  import ietf-inet-types { prefix inet; }
+  import policy-types {prefix pt; }
+
+
+  // meta
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    netopenconfig@googlegroups.com";
+
+  description
+    "This module describes a YANG model for routing policy
+    configuration. It is a limited subset of all of the policy
+    configuration parameters available in the variety of vendor
+    implementations, but supports widely used constructs for managing
+    how routes are imported, exported, and modified across different
+    routing protocols.  This module is intended to be used in
+    conjunction with routing protocol configuration models (e.g.,
+    BGP) defined in other modules.
+
+    Route policy expression:
+
+    Policies are expressed as a set of top-level policy definitions,
+    each of which consists of a sequence of policy statements. Policy
+    statements consist of simple condition-action tuples. Conditions
+    may include mutiple match or comparison operations, and similarly
+    actions may be multitude of changes to route attributes or a
+    final disposition of accepting or rejecting the route.
+
+    Route policy evaluation:
+
+    Policy definitions are referenced in routing protocol
+    configurations using import and export configuration statements.
+    The arguments are members of an ordered list of named policy
+    definitions which comprise a policy chain, and optionally, an
+    explicit default policy action (i.e., reject or accept).
+
+    Evaluation of each policy definition proceeds by evaluating its
+    corresponding individual policy statements in order.  When a
+    condition statement in a policy statement is satisfied, the
+    corresponding action statement is executed.  If the action
+    statement has either accept-route or reject-route actions, policy
+    evaluation of the current policy definition stops, and no further
+    policy definitions in the chain are evaluated.
+
+    If the condition is not satisfied, then evaluation proceeds to
+    the next policy statement.  If none of the policy statement
+    conditions are satisfied, then evaluation of the current policy
+    definition stops, and the next policy definition in the chain is
+    evaluated.  When the end of the policy chain is reached, the
+    default route disposition action is performed (i.e., reject-route
+    unless an an alternate default action is specified for the
+    chain).
+
+    Policy 'subroutines' (or nested policies) are supported by
+    allowing policy statement conditions to reference another policy
+    definition which applies conditions and actions from the
+    referenced policy before returning to the calling policy
+    statement and resuming evaluation.  If the called policy
+    results in an accept-route (either explicit or by default), then
+    the subroutine returns an effective true value to the calling
+    policy.  Similarly, a reject-route action returns false.  If the
+    subroutine returns true, the calling policy continues to evaluate
+    the remaining conditions (using a modified route if the
+    subroutine performed any changes to the route).";
+
+  revision "2015-05-15" {
+    description
+      "Initial revision";
+    reference "TBD";
+  }
+
+
+  // typedef statements
+
+  typedef default-policy-type {
+    type enumeration {
+      enum ACCEPT-ROUTE {
+        description "default policy to accept the route";
+      }
+      enum REJECT-ROUTE {
+        description "default policy to reject the route";
+      }
+    }
+    description "type used to specify default route disposition in
+    a policy chain";
+  }
+
+
+  // grouping statements
+
+  grouping generic-defined-sets {
+    description
+      "Data definitions for pre-defined sets of attributes used in
+      policy match conditions.  These sets are generic and can
+      be used in matching conditions in different routing
+      protocols.";
+
+    container prefix-sets {
+      description
+        "Enclosing container for defined prefix sets for matching";
+
+      list prefix-set {
+        key prefix-set-name;
+        description
+          "List of the defined prefix sets";
+
+        leaf prefix-set-name {
+          type string;
+          description
+            "name / label of the prefix set -- this is used to
+            reference the set in match conditions";
+        }
+
+        list prefix {
+          key "ip-prefix masklength-range";
+          description
+            "List of prefix expressions that are part of the set";
+
+          leaf ip-prefix {
+            type inet:ip-prefix;
+            mandatory true;
+            description
+              "The prefix member in CIDR notation -- while the
+              prefix may be either IPv4 or IPv6, most
+              implementations require all members of the prefix set
+              to be the same address family.  Mixing address types in
+              the same prefix set is likely to cause an error.";
+          }
+
+          leaf masklength-range {
+            type string {
+              pattern '^([0-9]+\.\.[0-9]+)|exact$';
+            }
+            description
+              "Defines a range for the masklength, or 'exact' if
+              the prefix has an exact length.
+
+              Example: 10.3.192.0/21 through 10.3.192.0/24 would be
+              expressed as prefix: 10.3.192.0/21,
+              masklength-range: 21..24.
+
+              Example: 10.3.192.0/21 would be expressed as
+              prefix: 10.3.192.0/21,
+              masklength-range: exact";
+          }
+        }
+      }
+    }
+
+    container neighbor-sets {
+      description
+        "Enclosing container for defined neighbor sets for matching";
+
+      list neighbor-set {
+        key neighbor-set-name;
+        description
+            "Definitions for neighbor sets";
+
+        leaf neighbor-set-name {
+          type string;
+          description
+              "name / label of the neighbor set -- this is used to
+              reference the set in match conditions";
+        }
+
+        list neighbor {
+          key "address";
+          description
+              "list of addresses that are part of the neighbor set";
+
+          leaf address {
+            type inet:ip-address;
+            description
+                "IP address of the neighbor set member";
+          }
+        }
+      }
+    }
+
+    container tag-sets {
+      description
+        "Enclosing container for defined tag sets for matching";
+
+      list tag-set {
+        key tag-set-name;
+        description
+          "Definitions for tag sets";
+
+        leaf tag-set-name {
+          type string;
+          description
+            "name / label of the tag set -- this is used to reference
+            the set in match conditions";
+        }
+
+        list tag {
+          key "value";
+          description
+            "list of tags that are part of the tag set";
+
+          leaf value {
+            type pt:tag-type;
+            description
+              "Value of the tag set member";
+          }
+        }
+      }
+    }
+  }
+
+  grouping local-generic-conditions {
+    description
+        "Condition statement definitions for consideration of a local
+        characteristic of a route";
+
+    leaf install-protocol-eq {
+      type identityref {
+        base pt:install-protocol-type;
+      }
+      description
+        "Condition to check the protocol / method used to install
+        which installed the route into the local routing table";
+    }
+  }
+
+  grouping match-set-options-group {
+    description
+      "Grouping containing options relating to how a particular set
+      should be matched";
+
+    leaf match-set-options {
+      type pt:match-set-options-type;
+      description
+        "Optional parameter that governs the behaviour of the
+        match operation";
+    }
+  }
+
+  grouping match-set-options-restricted-group {
+    description
+      "Grouping for a restricted set of match operation modifiers";
+
+    leaf match-set-options {
+      type pt:match-set-options-restricted-type;
+      description
+        "Optional parameter that governs the behaviour of the
+        match operation.  This leaf only supports matching on ANY
+        member of the set or inverting the match.  Matching on ALL is
+        not supported)";
+    }
+  }
+
+  grouping generic-conditions {
+    description "Condition statement definitions for checking
+    membership in a generic defined set";
+
+    container match-prefix-set {
+      presence
+        "The presence of this container indicates that the routes
+        should match the prefix-set referenced.";
+
+      description
+        "Match a referenced prefix-set according to the logic
+        defined in the match-set-options leaf";
+
+      leaf prefix-set {
+        type leafref {
+          path "/routing-policy/defined-sets/prefix-sets/" +
+          "prefix-set/prefix-set-name";
+          //TODO: require-instance should be added when it's
+          //supported in YANG 1.1
+          //require-instance true;
+        }
+        description "References a defined prefix set";
+      }
+      uses match-set-options-restricted-group;
+    }
+
+    container match-neighbor-set {
+      presence
+        "The presence of this container indicates that the routes
+        should match the neighbour set referenced";
+
+      description
+        "Match a referenced neighbor set according to the logic
+        defined in the match-set-options-leaf";
+
+      leaf neighbor-set {
+        type leafref {
+          path "/routing-policy/defined-sets/neighbor-sets/" +
+          "neighbor-set/neighbor-set-name";
+          //TODO: require-instance should be added when it's
+          //supported in YANG 1.1
+          //require-instance true;
+        }
+        description "References a defined neighbor set";
+      }
+      uses match-set-options-restricted-group;
+    }
+
+    container match-tag-set {
+      presence
+        "The presence of this container indicates that the routes
+        should match the tag-set referenced";
+
+      description
+        "Match a referenced tag set according to the logic defined
+        in the match-options-set leaf";
+
+      leaf tag-set {
+        type leafref {
+          path "/routing-policy/defined-sets/tag-sets/tag-set" +
+          "/tag-set-name";
+          //TODO: require-instance should be added when it's
+          //supported in YANG 1.1
+          //require-instance true;
+        }
+        description "References a defined tag set";
+      }
+      uses match-set-options-restricted-group;
+    }
+
+    uses local-generic-conditions;
+  }
+
+  grouping igp-generic-conditions {
+    description "grouping for IGP policy conditions";
+
+  }
+
+
+  grouping igp-conditions {
+    description "grouping for IGP-specific policy conditions";
+
+    container igp-conditions {
+      description "Policy conditions for IGP attributes";
+
+      uses igp-generic-conditions;
+
+    }
+  }
+
+  grouping generic-actions {
+    description
+      "Definitions for common set of policy action statements that
+      manage the disposition or control flow of the policy";
+
+    choice route-disposition {
+      description
+        "Select the final disposition for the route, either
+        accept or reject.";
+      leaf accept-route {
+        type empty;
+        description "accepts the route into the routing table";
+      }
+
+      leaf reject-route {
+        type empty;
+        description "rejects the route";
+      }
+    }
+  }
+
+
+  grouping igp-actions {
+    description "grouping for IGP-specific policy actions";
+
+    container igp-actions {
+      description "Actions to set IGP route attributes; these actions
+      apply to multiple IGPs";
+
+      leaf set-tag {
+        type pt:tag-type;
+        description
+          "Set the tag value for OSPF or IS-IS routes.";
+      }
+    }
+  }
+
+  container routing-policy {
+    description
+      "top-level container for all routing policy configuration";
+
+    container defined-sets {
+      description
+          "Predefined sets of attributes used in policy match
+          statements";
+
+      uses generic-defined-sets;
+      // uses bgp-defined-sets;
+      // don't see a need for IGP-specific defined sets at this point
+      // e.g., for OSPF, IS-IS, etc.
+    }
+
+    container policy-definitions {
+      description
+        "Enclosing container for the list of top-level policy
+        definitions";
+
+      list policy-definition {
+
+        key name;
+        description
+          "List of top-level policy definitions, keyed by unique
+          name.  These policy definitions are expected to be
+          referenced (by name) in policy chains specified in import/
+          export configuration statements.";
+
+
+        leaf name {
+          type string;
+          description
+              "Name of the top-level policy definition -- this name
+                is used in references to the current policy";
+        }
+
+        container statements {
+          description
+            "Enclosing container for policy statements";
+
+          list statement {
+            key name;
+            // TODO: names of policy statements within a policy defn
+            // should be optional, however, YANG requires a unique id
+            // for lists; not sure that a compound key works either;
+            // need to investigate further.
+            ordered-by user;
+            description
+              "Policy statements group conditions and actions within
+              a policy definition.  They are evaluated in the order
+              specified (see the description of policy evaluation
+              at the top of this module.";
+
+            leaf name {
+              type string;
+              description "name of the policy statement";
+            }
+
+            container conditions {
+
+              description "Condition statements for this
+                policy statement";
+
+              leaf call-policy {
+                type leafref {
+                  path "/rpol:routing-policy/" +
+                    "rpol:policy-definitions/" +
+                    "rpol:policy-definition/rpol:name";
+                  //TODO: require-instance should be added when it's
+                  //supported in YANG 1.1
+                  //require-instance true;
+                }
+                description
+                  "Applies the statements from the specified policy
+                  definition and then returns control the current
+                  policy statement. Note that the called policy may
+                  itself call other policies (subject to
+                  implementation limitations). This is intended to
+                  provide a policy 'subroutine' capability.  The
+                  called policy should contain an explicit or a
+                  default route disposition that returns an effective
+                  true (accept-route) or false (reject-route),
+                  otherwise the behavior may be ambiguous and
+                  implementation dependent";
+              }
+              uses generic-conditions;
+              uses igp-conditions;
+            }
+
+            container actions {
+
+              description "Action statements for this policy
+                    statement";
+
+              uses generic-actions;
+              uses igp-actions;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  grouping apply-policy-config {
+    description
+      "Configuration data for routing policies";
+
+    leaf-list import-policy {
+      type leafref {
+        path "/rpol:routing-policy/rpol:policy-definitions/" +
+          "rpol:policy-definition/rpol:name";
+        //TODO: require-instance should be added when it's
+        //supported in YANG 1.1
+        //require-instance true;
+      }
+      ordered-by user;
+      description
+        "list of policy names in sequence to be applied on
+        receiving a routing update in the current context, e.g.,
+        for the current peer group, neighbor, address family,
+        etc.";
+    }
+
+    leaf default-import-policy {
+      type default-policy-type;
+      default REJECT-ROUTE;
+      description
+        "explicitly set a default policy if no policy definition
+        in the import policy chain is satisfied.";
+    }
+
+    leaf-list export-policy {
+      type leafref {
+        path "/rpol:routing-policy/rpol:policy-definitions/" +
+          "rpol:policy-definition/rpol:name";
+        //TODO: require-instance should be added when it's
+        //supported in YANG 1.1
+        //require-instance true;
+      }
+      ordered-by user;
+      description
+        "list of policy names in sequence to be applied on
+        sending a routing update in the current context, e.g.,
+        for the current peer group, neighbor, address family,
+        etc.";
+    }
+
+    leaf default-export-policy {
+      type default-policy-type;
+      default REJECT-ROUTE;
+      description
+        "explicitly set a default policy if no policy definition
+        in the export policy chain is satisfied.";
+    }
+  }
+
+  grouping apply-policy-state {
+    description
+      "Operational state associated with routing policy";
+
+    //TODO: identify additional state data beyond the intended
+    //policy configuration.
+  }
+
+  grouping apply-policy-group {
+    description
+      "Top level container for routing policy applications. This
+      grouping is intended to be used in routing models where
+      needed.";
+
+    container apply-policy {
+      description
+        "Anchor point for routing policies in the model.
+        Import and export policies are with respect to the local
+        routing table, i.e., export (send) and import (receive),
+        depending on the context.";
+
+      container config {
+        description
+          "Policy configuration data.";
+
+        uses apply-policy-config;
+      }
+
+      container state {
+
+        config false;
+        description
+          "Operational state for routing policy";
+
+        uses apply-policy-config;
+        uses apply-policy-state;
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpNextHopTypeBuilderTest.java
new file mode 100644 (file)
index 0000000..b8f715d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.BgpNextHopType.Enumeration;
+
+public class BgpNextHopTypeBuilderTest {
+
+    private static final String IPV4_ADDRESS = "127.0.0.1";
+    private static final String IPV6_ADDRESS = "2001:db8:85a3::8a2e:370:7334";
+
+    @Test
+    public void testIpv4() {
+        final BgpNextHopType bgpNextHopType = BgpNextHopTypeBuilder.getDefaultInstance(IPV4_ADDRESS);
+        Assert.assertEquals(IPV4_ADDRESS, bgpNextHopType.getIpAddress().getIpv4Address().getValue());
+    }
+
+    @Test
+    public void testIpv6() {
+        final BgpNextHopType bgpNextHopType = BgpNextHopTypeBuilder.getDefaultInstance(IPV6_ADDRESS);
+        Assert.assertEquals(IPV6_ADDRESS, bgpNextHopType.getIpAddress().getIpv6Address().getValue());
+    }
+
+    @Test
+    public void testEnumLowerCase() {
+        final BgpNextHopType bgpNextHopType = BgpNextHopTypeBuilder.getDefaultInstance("self");
+        Assert.assertEquals(Enumeration.SELF, bgpNextHopType.getEnumeration());
+    }
+
+    @Test
+    public void testEnumFirstUpperCase() {
+        final BgpNextHopType bgpNextHopType = BgpNextHopTypeBuilder.getDefaultInstance("Self");
+        Assert.assertEquals(Enumeration.SELF, bgpNextHopType.getEnumeration());
+    }
+
+    @Test
+    public void testEnumUpperCase() {
+        final BgpNextHopType bgpNextHopType = BgpNextHopTypeBuilder.getDefaultInstance("SELF");
+        Assert.assertEquals(Enumeration.SELF, bgpNextHopType.getEnumeration());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalid() {
+        BgpNextHopTypeBuilder.getDefaultInstance("error");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/BgpSetMedTypeBuilderTest.java
new file mode 100644 (file)
index 0000000..93d78cf
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.BgpSetMedType.Enumeration;
+
+public class BgpSetMedTypeBuilderTest {
+
+    @Test
+    public void testString() {
+        final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("+1");
+        Assert.assertEquals("+1", medType.getString());
+    }
+
+    @Test
+    public void testUint32() {
+        final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("1");
+        Assert.assertEquals(Long.valueOf(1L), medType.getUint32());
+    }
+
+    @Test
+    public void testEnumLowerCase() {
+        final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("igp");
+        Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+    }
+
+    @Test
+    public void testEnumFirstUpperCase() {
+        final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("Igp");
+        Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+    }
+
+    @Test
+    public void testEnumUpperCase() {
+        final BgpSetMedType medType = BgpSetMedTypeBuilder.getDefaultInstance("IGP");
+        Assert.assertEquals(Enumeration.IGP, medType.getEnumeration());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalidBigNumber() {
+        BgpSetMedTypeBuilder.getDefaultInstance("4294967297");
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalidString() {
+        BgpSetMedTypeBuilder.getDefaultInstance("abcd");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/community/sets/CommunitySetCommunityMemberBuilderTest.java
new file mode 100644 (file)
index 0000000..24d1ee2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.community.sets;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.community.sets.CommunitySet.CommunityMember;
+
+public class CommunitySetCommunityMemberBuilderTest {
+
+    @Test
+    public void testStdComType() {
+        final CommunityMember communityMemeber = CommunitySetCommunityMemberBuilder.getDefaultInstance("123");
+        Assert.assertEquals(123L, communityMemeber.getBgpStdCommunityType().getUint32().longValue());
+    }
+
+    @Test
+    public void testRegxpComType() {
+        final CommunityMember communityMemeber = CommunitySetCommunityMemberBuilder.getDefaultInstance("[0-9]");
+        Assert.assertEquals("[0-9]", communityMemeber.getBgpCommunityRegexpType().getValue());
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/defined/sets/bgp/defined/sets/ext/community/sets/ExtCommunitySetExtCommunityMemberBuilderTest.java
new file mode 100644 (file)
index 0000000..97f3533
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets.ExtCommunitySet.ExtCommunityMember;
+
+public class ExtCommunitySetExtCommunityMemberBuilderTest {
+
+    @Test
+    public void testExtCommunity() {
+        final ExtCommunityMember extCommMemeber = ExtCommunitySetExtCommunityMemberBuilder.getDefaultInstance("123:123");
+        Assert.assertEquals("123:123", extCommMemeber.getBgpExtCommunityType().getValue());
+    }
+
+    @Test
+    public void testString() {
+        final ExtCommunityMember extCommMemeber = ExtCommunitySetExtCommunityMemberBuilder.getDefaultInstance("[0-9]");
+        Assert.assertEquals("[0-9]", extCommMemeber.getBgpCommunityRegexpType().getValue());
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/community/set/community/method/InlineCommunitiesBuilderTest.java
new file mode 100644 (file)
index 0000000..2ed0f8a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Inline.Communities;
+
+public class InlineCommunitiesBuilderTest {
+
+    @Test
+    public void testValid() {
+        final Communities communities = InlineCommunitiesBuilder.getDefaultInstance("123");
+        Assert.assertEquals(123L, communities.getBgpStdCommunityType().getUint32().longValue());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalid() {
+        InlineCommunitiesBuilder.getDefaultInstance("abc");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/policy/rev150515/routing/policy/policy/definitions/policy/definition/statements/statement/actions/bgp/actions/set/ext/community/set/ext/community/method/InlineCommunitiesBuilderTest.java
new file mode 100644 (file)
index 0000000..af9edb2
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015 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.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev150515.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.ext.community.set.ext.community.method.Inline.Communities;
+
+public class InlineCommunitiesBuilderTest {
+
+    @Test
+    public void testValid() {
+        final Communities communities = InlineCommunitiesBuilder.getDefaultInstance("123:123");
+        Assert.assertEquals("123:123", communities.getBgpExtCommunityType().getValue());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalid() {
+        InlineCommunitiesBuilder.getDefaultInstance("abc");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/rev150515/BgpNeighborTransportConfigLocalAddressBuilderTest.java
new file mode 100644 (file)
index 0000000..4ccc6ed
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 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.bgp.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev150515.BgpNeighborTransportConfig.LocalAddress;
+
+public class BgpNeighborTransportConfigLocalAddressBuilderTest {
+
+    private static final String IPV4_ADDRESS = "127.0.0.1";
+
+    @Test
+    public void testIpv4() {
+        final LocalAddress localAddress = BgpNeighborTransportConfigLocalAddressBuilder.getDefaultInstance(IPV4_ADDRESS);
+        Assert.assertEquals(IPV4_ADDRESS, localAddress.getIpAddress().getIpv4Address().getValue());
+    }
+
+    @Test
+    public void testString() {
+        final LocalAddress localAddress = BgpNeighborTransportConfigLocalAddressBuilder.getDefaultInstance("abcd");
+        Assert.assertEquals("abcd", localAddress.getString());
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/BgpStdCommunityTypeBuilderTest.java
new file mode 100644 (file)
index 0000000..aa5e32e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 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.bgp.types.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BgpStdCommunityTypeBuilderTest {
+
+    @Test
+    public void testString() {
+        final BgpStdCommunityType commType = BgpStdCommunityTypeBuilder.getDefaultInstance("72:123");
+        Assert.assertEquals("72:123", commType.getString());
+    }
+
+    @Test
+    public void testUint32() {
+        final BgpStdCommunityType commType = BgpStdCommunityTypeBuilder.getDefaultInstance("123");
+        Assert.assertEquals(123L, commType.getUint32().longValue());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalid() {
+        BgpStdCommunityTypeBuilder.getDefaultInstance("-1");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/bgp/types/rev150515/RrClusterIdTypeBuilderTest.java
new file mode 100644 (file)
index 0000000..b4101a5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 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.bgp.types.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class RrClusterIdTypeBuilderTest {
+
+    @Test
+    public void testIpv4() {
+        final RrClusterIdType rrClusterType = RrClusterIdTypeBuilder.getDefaultInstance("127.0.0.1");
+        Assert.assertEquals("127.0.0.1", rrClusterType.getIpv4Address().getValue());
+    }
+
+    @Test
+    public void testUint32() {
+        final RrClusterIdType rrClusterType = RrClusterIdTypeBuilder.getDefaultInstance("12345");
+        Assert.assertEquals(12345L, rrClusterType.getUint32().longValue());
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void testInvalid() {
+        RrClusterIdTypeBuilder.getDefaultInstance("abcd");
+    }
+
+}
diff --git a/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilderTest.java b/bgp/openconfig-api/src/test/java/org/opendaylight/yang/gen/v1/http/openconfig/net/yang/policy/types/rev150515/TagTypeBuilderTest.java
new file mode 100644 (file)
index 0000000..58d3bea
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2015 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.policy.types.rev150515;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TagTypeBuilderTest {
+
+    @Test
+    public void testUint32() {
+        final TagType tagType = TagTypeBuilder.getDefaultInstance("12345");
+        Assert.assertEquals(12345L, tagType.getUint32().longValue());
+    }
+
+    @Test
+    public void testString() {
+        final TagType tagType = TagTypeBuilder.getDefaultInstance("abcd");
+        Assert.assertEquals("abcd", tagType.getString());
+    }
+
+}
index 788b510912590da77ea011563ce323744a1b9d3d..8a5346f194497b838b15981b9b81dac2c90a675d 100644 (file)
@@ -50,5 +50,6 @@
         <module>bmp-spi</module>
         <module>bmp-impl</module>
         <module>controller-config</module>
+        <module>openconfig-api</module>
     </modules>
 </project>