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