ea43d2fd29d157996a52d09c4ccd60465cccd13f
[bgpcep.git] / bgp / openconfig-api / src / main / yang / odl-bgp-policy.yang
1 module odl-bgp-policy {
2     yang-version 1.1;
3     namespace "urn:opendaylight:params:xml:ns:yang:odl:bgp:default:policy";
4     prefix "odl-bgp-policy";
5
6     import yang-ext { prefix ext; revision-date 2013-07-09; }
7     import openconfig-bgp-types { prefix oc-bgp-t; }
8     import bgp-rib { prefix rib; revision-date 2018-03-29; }
9     import openconfig-routing-policy { prefix rpol; }
10     import openconfig-bgp-policy { prefix bgppol; }
11     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
12     import bgp-types { prefix bgp-t; revision-date 2018-03-29; }
13
14     organization "AT&T Services, Inc.";
15     contact "Claudio D. Gasparini <claudio.gasparini@pantheon.tech>";
16
17     description
18         "This module contains odl bgp policy model
19         to be used under openconfig policy model definitions.
20
21         Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
22
23         This program and the accompanying materials are made available
24         under the terms of the Eclipse Public License v1.0 which
25         accompanies this distribution, and is available at
26         http://www.eclipse.org/legal/epl-v10.html";
27
28     revision "2018-03-29" {
29         description "Add support for add-path for all afi/safi.";
30     }
31
32     revision "2018-01-09" {
33         description
34             "ODL BGP policy models";
35     }
36
37     grouping match-role-condition-grouping {
38         leaf role-set {
39             type leafref {
40               path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/role-sets/role-set/role-set-name";
41               require-instance true;
42             }
43             description "References a defined neighbor roles set";
44         }
45         uses rpol:match-set-options-restricted-group;
46     }
47
48     grouping match-role-set-condition-grouping {
49         container match-role-set {
50             description
51                 "Match a list of referenced role-set according to the logic
52                 defined in the match-set-options leaf";
53
54             container from-role {
55                 uses match-role-condition-grouping;
56             }
57
58             container to-role {
59                 uses match-role-condition-grouping;
60             }
61         }
62     }
63
64     grouping bgp-neighbor {
65         leaf neighbor-set {
66           type leafref {
67             path "/rpol:routing-policy/rpol:defined-sets/rpol:neighbor-sets/rpol:neighbor-set/rpol:neighbor-set-name";
68             require-instance true;
69           }
70           description "References a defined neighbor set";
71         }
72         uses rpol:match-set-options-restricted-group;
73     }
74
75     grouping match-bgp-neighbor-grouping {
76         container match-bgp-neighbor-set {
77             presence
78                 "The presence of this container indicates that the routes
79                 should match the neighbour address of set referenced";
80
81             description
82                 "Match a referenced neighbor set according to the logic
83                 defined in the match-set-options-leaf";
84
85             container from-neighbor {
86                 uses bgp-neighbor;
87             }
88
89             container to-neighbor {
90                 uses bgp-neighbor;
91             }
92         }
93     }
94
95     grouping match-originator-id-set-condition-grouping {
96         description
97             "Match a list of referenced originator-id-set according to the logic
98             defined in the match-set-options leaf";
99
100         container match-originator-id-set-condition {
101             leaf originator-id-set {
102                 type leafref {
103                   path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/originator-id-sets/originator-id-set/originator-id-set-name";
104                   require-instance true;
105                 }
106                 description "References a defined Originator Id set";
107             }
108             uses rpol:match-set-options-restricted-group;
109         }
110     }
111
112     grouping match-cluster-id-set-condition-grouping {
113         description
114             "Match a list of referenced cluster-id-set according to the logic
115             defined in the match-set-options leaf";
116         container match-cluster-id-set-condition {
117             leaf cluster-id-set {
118                 type leafref {
119                   path "/rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets/cluster-id-sets/cluster-id-set/cluster-id-set-name";
120                   require-instance true;
121                 }
122                 description "References a defined cluster Id set";
123             }
124             uses rpol:match-set-options-group;
125         }
126     }
127
128     grouping role-set {
129         description "Data definition for a list of Odl Bgp roles which
130             are matched as part of a policy";
131
132         list role-set {
133             key role-set-name;
134             description "List of the defined role sets";
135
136             leaf role-set-name {
137               type string;
138               description
139                 "name / label of the role set -- this is used to
140                 reference the set in match conditions";
141             }
142
143             leaf-list role {
144                 type rib:peer-role;
145                 description
146                 "List of role expressions that are part of the set";
147             }
148       }
149     }
150
151     grouping originator-id-set {
152         description "Data definition for a list of Originators Ids which
153             are matched as part of a policy";
154
155         list originator-id-set {
156             key originator-id-set-name;
157             description "List of the defined Originators Ids sets";
158
159             leaf originator-id-set-name {
160               type string;
161               description
162                 "name / label of the set -- this is used to
163                 reference the set in match conditions";
164             }
165
166             leaf-list originator-id {
167                 type inet:ipv4-address;
168                 description
169                 "List of role expressions that are part of the set";
170             }
171
172             container local {
173                  presence "Local originator Id";
174                  description "Validates also Local Originator Id";
175             }
176       }
177     }
178
179     grouping cluster-id-set {
180         description "Data definition for a list of Cluster Ids which
181             are matched as part of a policy";
182
183         list cluster-id-set {
184             key cluster-id-set-name;
185             description "List of the defined cluster Ids sets";
186
187             leaf cluster-id-set-name {
188               type string;
189               description
190                 "name / label of the set -- this is used to
191                 reference the set in match conditions";
192             }
193
194             leaf-list cluster-id {
195                 type bgp-t:cluster-identifier;
196                 description
197                 "List of role expressions that are part of the set";
198             }
199
200             container local {
201                  presence "Local cluster Id";
202                  description "Validates also cluster Originator Id";
203             }
204       }
205     }
206
207     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
208         ext:augment-identifier bgp-cluster-id-sets;
209         container cluster-id-sets {
210             description "Enclosing container for defined cluster-id sets for matching";
211             uses cluster-id-set;
212         }
213     }
214
215     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
216         ext:augment-identifier bgp-role-sets;
217         container role-sets {
218             description "Enclosing container for defined role sets for matching";
219             uses role-set;
220         }
221     }
222
223     augment /rpol:routing-policy/rpol:defined-sets/bgppol:bgp-defined-sets {
224         ext:augment-identifier bgp-originator-id-sets;
225         container originator-id-sets {
226             description "Enclosing container for defined role sets for matching";
227             uses originator-id-set;
228         }
229     }
230
231     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
232         ext:augment-identifier match-afi-safi-not-in-condition;
233         leaf-list afi-safi-not-in {
234             type identityref {
235               base "oc-bgp-t:afi-safi-type";
236             }
237             description
238               "List of address families which the NLRI must not be within";
239         }
240     }
241
242     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
243         ext:augment-identifier match-bgp-neighbor-condition;
244         uses match-bgp-neighbor-grouping;
245     }
246
247     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
248         ext:augment-identifier match-role-set-condition;
249         uses match-role-set-condition-grouping;
250     }
251
252     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
253         ext:augment-identifier match-originator-id-set-condition;
254         uses match-originator-id-set-condition-grouping;
255     }
256
257     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
258         ext:augment-identifier match-cluster-id-set-condition;
259         uses match-cluster-id-set-condition-grouping;
260     }
261
262     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:conditions/bgppol:bgp-conditions {
263         ext:augment-identifier vpn-non-member-condition;
264         container vpn-non-member {
265             presence "Match Route Target Attribute with Route Target memberships of destiny peer. Asserts peers is a non member.";
266         }
267     }
268
269     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
270         ext:augment-identifier reflect-attributes-actions;
271         container reflect-attributes-actions {
272             presence "Modify attributes so they are updated as per RFC4456 route reflection";
273         }
274     }
275
276     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
277         ext:augment-identifier non-transitive-attributes-filter;
278         container non-transitive-attributes-filter {
279             presence "Filters attributes, removing non transitive attributes";
280         }
281     }
282
283     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
284         ext:augment-identifier local-as-path-prepend;
285         container local-as-path-prepend {
286             presence "Prepends local AS Path";
287         }
288     }
289
290     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
291         ext:augment-identifier set-cluster-id-prepend;
292         container set-cluster-id-prepend {
293
294         presence "node is present in the config data to use the Cluster Id prepend action";
295         description "action to prepend local Cluster Id to the Cluster Id List";
296         }
297     }
298
299     augment /rpol:routing-policy/rpol:policy-definitions/rpol:policy-definition/rpol:statements/rpol:statement/rpol:actions/bgppol:bgp-actions {
300         ext:augment-identifier set-originator-id-prepend;
301         container set-originator-id-prepend {
302             presence "node is present in the config data to use the Originator Id prepend action";
303             description "action to prepend Originator Id if non Originator Id is present. If no Originator Id"
304             + "is defined, local Originator Id is used.";
305             leaf originator-id {
306                 type inet:ipv4-address;
307                 description "Originator Id";
308             }
309         }
310     }
311 }