8d052d433eb823a707511809c849e96e24e34962
[groupbasedpolicy.git] / groupbasedpolicy / src / main / yang / model / renderer.yang
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 module renderer {
10     yang-version 1;
11
12     namespace "urn:opendaylight:groupbasedpolicy:renderer";
13     prefix "gbp-renderer";
14
15     import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
16     import policy { prefix policy; revision-date 2014-04-21; }
17     import resolved-policy { prefix resolved-policy; revision-date 2015-08-28; }
18     import base-endpoint { prefix base-endpoint; revision-date 2016-04-27; }
19     import forwarding { prefix forwarding; revision-date 2016-04-27; }
20     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
21
22     description
23         "This module defines renderer capabilities.";
24
25     revision "2015-11-03" {
26         description
27             "Initial revision.";
28     }
29
30     typedef renderer-name {
31         type gbp-common:name;
32         description "A name for a renderer";
33     }
34
35     typedef policy-name {
36         type string;
37     }
38
39     typedef endpoint-policy-participation {
40         type enumeration {
41             enum PROVIDER;
42             enum CONSUMER;
43         }
44     }
45
46     grouping supported-string-value-fields {
47         list supported-string-value {
48             description "String value has to be identical.";
49             key value;
50             leaf value {
51                 type string;
52             }
53         }
54     }
55
56     grouping supported-int-value-fields {
57         list supported-int-value {
58             description "Int value has to be identical.";
59             key value;
60             leaf value {
61                 type int64;
62             }
63         }
64         list supported-int-value-in-range {
65             description "Int value has to be inside the range include boundaries.";
66             key "min max";
67             leaf min {
68                 type int64;
69             }
70             leaf max {
71                 type int64;
72             }
73         }
74     }
75
76     grouping supported-range-value-fields {
77         list supported-range-value {
78             description "Min and max values have to be inside the range include boundaries.";
79             key "min max";
80             leaf min {
81                 type int64;
82             }
83             leaf max {
84                 type int64;
85             }
86         }
87     }
88
89     grouping has-parameters-type {
90         choice parameter-type {
91             case string {
92                 uses supported-string-value-fields;
93             }
94             case int {
95                 uses supported-int-value-fields;
96             }
97             case range {
98                 uses supported-range-value-fields;
99             }
100         }
101     }
102
103     grouping has-peer-endpoints {
104         list peer-endpoint {
105             key "context-type context-id address-type address";
106             uses base-endpoint:address-endpoint-key;
107         }
108     }
109
110     grouping has-peer-external-endpoints {
111         list peer-external-endpoint {
112             key "context-type context-id address-type address";
113             uses base-endpoint:address-endpoint-key;
114         }
115     }
116
117     grouping has-peer-external-containment-endpoints {
118         list peer-external-containment-endpoint {
119             key "context-type context-id";
120             uses forwarding:context-key;
121         }
122     }
123
124     grouping has-renderer-name {
125         leaf renderer-name {
126             type renderer-name;
127             mandatory true;
128         }
129     }
130
131     grouping has-rule-group-with-renderer-endpoint-participation {
132         list rule-group-with-renderer-endpoint-participation {
133             description "A specific policy rule group that apply to pair of endpoints.
134                 Entire rule-group is located on /renderers/renderer/renderer-policy/configuration/rule-groups/rule-group";
135             key "tenant-id contract-id subject-name renderer-endpoint-participation";
136             uses resolved-policy:has-subject-key;
137             leaf renderer-endpoint-participation {
138                 type endpoint-policy-participation;
139             }
140         }
141     }
142
143     container renderers {
144         list renderer {
145             description
146                 "A renderer provides a list of capabilities and status about configured policy.
147                 The renderer must store data only to OPER!";
148
149             key name;
150             leaf name {
151                 description
152                     "A user-visible name for the renderer.";
153                 type renderer-name;
154             }
155
156             container renderer-nodes {
157                 description "Contains location of nodes (network elements) which are configured by the renderer.";
158
159                 config false;
160
161                 list renderer-node {
162                     key "node-path";
163                     leaf node-path {
164                         description "Path to the node where policy needs to be enforced.
165                             This field is matched against internal-node and external-node-mount-point
166                             from base-endoint:endpoint-locations.";
167                         type instance-identifier;
168                     }
169                 }
170             }
171
172             container renderer-policy {
173                 description "Policy is named by version and describes desired vs real state.
174                     Desired state of policy described by /renderers/renderer/renderer-policy/configuration and version are stored in CONF.
175                     The real state of policy described by /renderers/renderer/renderer-policy/status and version are stored in OPER.";
176
177                 leaf version {
178                     description
179                         "Version in CONF represents desired state of policy while version in OPER means real state.";
180                     type uint32;
181                     mandatory true;
182                 }
183
184                 container configuration {
185                     description "Renderer tries to apply given policy on devices.";
186                     container renderer-endpoints {
187                         list renderer-endpoint {
188                             min-elements 1;
189                             description "Policy between renderer-endpoint and peer-endpoints (peers).
190                                 Renderer configures policy for renderer endpoints.";
191                             key "context-type context-id address-type address";
192                             uses base-endpoint:address-endpoint-key;
193
194                             list peer-endpoint-with-policy {
195                                 key "context-type context-id address-type address";
196                                 uses base-endpoint:address-endpoint-key;
197                                 uses has-rule-group-with-renderer-endpoint-participation;
198                             }
199
200                             list peer-external-endpoint-with-policy {
201                                 key "context-type context-id address-type address";
202                                 uses base-endpoint:address-endpoint-key;
203                                 uses has-rule-group-with-renderer-endpoint-participation;
204                             }
205
206                             list peer-external-containment-endpoint-with-policy {
207                                 key "context-type context-id";
208                                 uses forwarding:context-key;
209                                 uses has-rule-group-with-renderer-endpoint-participation;
210                             }
211                         }
212                     }
213
214                     container rule-groups {
215                         list rule-group {
216                             min-elements 1;
217                             description "A specific policy rule group that apply to pair of endpoints.
218                                 The policy rule group represents the subject with resolved rules.";
219                             key "tenant-id contract-id subject-name";
220                             uses resolved-policy:has-subject-key;
221
222                             uses policy:has-order;
223                             uses resolved-policy:has-resolved-rules;
224                         }
225                     }
226
227                     container endpoints {
228                         list address-endpoint-with-location {
229                             min-elements 1;
230                             key "context-type context-id address-type address";
231                             uses base-endpoint:address-endpoint-fields;
232                             uses base-endpoint:has-location;
233                             uses has-renderer-name;
234                         }
235
236                         list containment-endpoint-with-location {
237                             key "context-type context-id";
238                             uses base-endpoint:containment-endpoint-fields;
239                             uses base-endpoint:has-relative-location;
240                         }
241                     }
242
243                     container forwarding-contexts {
244                         list forwarding-context-by-tenant {
245                             min-elements 1;
246                             key tenant-id;
247                             uses forwarding:forwarding-with-tenant-fields;
248                         }
249                     }
250                 }
251
252                 container status {
253                     description "The renderer exposes status of policy here.";
254                     config false;
255
256                     list unconfigured-rule {
257                         key "tenant-id contract-id subject-name renderer-endpoint-participation rule-name";
258                         uses resolved-policy:has-subject-key;
259                         leaf renderer-endpoint-participation {
260                             type endpoint-policy-participation;
261                         }
262                         leaf rule-name {
263                             type gbp-common:rule-name;
264                         }
265
266                         container renderer-endpoints-with-peers {
267                             list renderer-endpoint-with-peers {
268                                 key "context-type context-id address-type address";
269                                 uses base-endpoint:address-endpoint-key;
270
271                                 uses has-peer-endpoints;
272                                 uses has-peer-external-endpoints;
273                                 uses has-peer-external-containment-endpoints;
274                             }
275                         }
276                     }
277                 }
278             }
279
280             // TODO remove - does not make sense anymore
281             container interests {
282
283                 status deprecated;
284
285                 config false;
286
287                 description "Represents interests of the renderer.";
288
289                 container followed-tenants {
290                     description "Interesting tenants for the renderer.";
291
292                     list followed-tenant {
293                         description "Tenant which is followed by the renderer.";
294
295                         key id;
296
297                         leaf id {
298                             type gbp-common:tenant-id;
299                         }
300
301                         list followed-endpoint-group {
302                             description "Endpoint-group which is followed by the renderer.";
303
304                             key id;
305
306                             leaf id {
307                                 type gbp-common:endpoint-group-id;
308                             }
309                         }
310                     }
311                 }
312             }
313
314             container capabilities {
315
316                 config false;
317
318                 description "Capabilities this renderer provides.";
319
320                 list supported-classifier-definition {
321                     description
322                         "Classifier definitions this renderer can use.";
323
324                     key classifier-definition-id;
325
326                     leaf classifier-definition-id {
327                         description "Reference to a classifier definition in config datastore.";
328                         type leafref {
329                             path "/policy:subject-feature-definitions/policy:classifier-definition/policy:id";
330                         }
331                     }
332
333                     leaf parent-classifier-definition-id {
334                         description
335                             "Optional reference to a parent classifier definition,
336                             to provide a hierarchical structure.";
337                         type leafref {
338                             path "/policy:subject-feature-definitions/policy:classifier-definition/policy:id";
339                         }
340                     }
341
342                     list supported-parameter-values {
343                         description "Represents supported paramters and its values by renderer.
344                             If it contains only parameter-name without paramater-type, it means that any value is supported.";
345                         key parameter-name;
346
347                         leaf parameter-name {
348                             description "TODO";
349                             type leafref {
350                                 path "/policy:subject-feature-definitions/policy:classifier-definition/policy:parameter/policy:name";
351                             }
352                         }
353
354                         uses has-parameters-type;
355                     }
356                 }
357
358                 list supported-action-definition {
359                     description
360                         "Action definitions this renderer can use.";
361
362                     key action-definition-id;
363
364                     leaf action-definition-id {
365                         description "Reference to an action definition in config datastore.";
366                         type leafref {
367                             path "/policy:subject-feature-definitions/policy:action-definition/policy:id";
368                         }
369                     }
370
371                     leaf parent-action-definition-id {
372                         description
373                             "Optional reference to a parent action definition,
374                             to provide a hierarchical structure.";
375                         type leafref {
376                             path "/policy:subject-feature-definitions/policy:action-definition/policy:id";
377                         }
378                     }
379
380                     list supported-parameter-values {
381                         description "Represents supported paramters and its values by renderer.
382                             If it contains only parameter-name without paramater-type, it means that any value is supported.";
383                         key parameter-name;
384
385                         leaf parameter-name {
386                             description "TODO";
387                             type leafref {
388                                 path "/policy:subject-feature-definitions/policy:action-definition/policy:parameter/policy:name";
389                             }
390                         }
391
392                         uses has-parameters-type;
393                     }
394                 }
395             }
396         }
397     }
398 }