20990c044060088ece2393f7fbe83aefb37b9199
[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-renderer-name {
104         leaf renderer-name {
105             type renderer-name;
106             mandatory true;
107         }
108     }
109
110     grouping has-rule-group-with-renderer-endpoint-participation {
111         list rule-group-with-renderer-endpoint-participation {
112             description "A specific policy rule group that apply to pair of endpoints.
113                 Entire rule-group is located on /renderers/renderer/renderer-policy/configuration/rule-groups/rule-group";
114             key "tenant-id contract-id subject-name renderer-endpoint-participation";
115             uses resolved-policy:has-subject-key;
116             leaf renderer-endpoint-participation {
117                 type endpoint-policy-participation;
118             }
119         }
120     }
121
122     grouping has-unconfigured-rule-groups {
123         list unconfigured-rule-group {
124             key "tenant-id contract-id subject-name renderer-endpoint-participation";
125             uses resolved-policy:has-subject-key;
126             leaf renderer-endpoint-participation {
127                 type endpoint-policy-participation;
128             }
129             list unconfigured-resolved-rule {
130                 key "rule-name";
131                 leaf rule-name {
132                     type gbp-common:rule-name;
133                 }
134             }
135         }
136     }
137
138     container renderers {
139         list renderer {
140             description
141                 "A renderer provides a list of capabilities and status about configured policy.
142                 The renderer must store data only to OPER!";
143
144             key name;
145             leaf name {
146                 description
147                     "A user-visible name for the renderer.";
148                 type renderer-name;
149             }
150
151             container renderer-nodes {
152                 description "Contains location of nodes (network elements) which are configured by the renderer.";
153
154                 config false;
155
156                 list renderer-node {
157                     key "node-path";
158                     leaf node-path {
159                         description "Path to the node where policy needs to be enforced.
160                             This field is matched against internal-node and external-node-mount-point
161                             from base-endoint:endpoint-locations.";
162                         type instance-identifier;
163                     }
164                 }
165             }
166
167             container renderer-policy {
168                 description "Policy is named by version and describes desired vs real state.
169                     Desired state of policy described by /renderers/renderer/renderer-policy/configuration and version are stored in CONF.
170                     The real state of policy described by /renderers/renderer/renderer-policy/status and version are stored in OPER.";
171
172                 leaf version {
173                     description
174                         "Version in CONF represents desired state of policy while version in OPER means real state.";
175                     type uint32;
176                     mandatory true;
177                 }
178
179                 container configuration {
180                     description "Renderer tries to apply given policy on devices.";
181                     container renderer-endpoints {
182                         list renderer-endpoint {
183                             min-elements 1;
184                             description "Policy between renderer-endpoint and peer-endpoints (peers).
185                                 Renderer configures policy for renderer endpoints.";
186                             key "context-type context-id address-type address";
187                             uses base-endpoint:address-endpoint-key;
188
189                             list peer-endpoint {
190                                 description "peer endpoint with-policy - keys";
191                                 key "context-type context-id address-type address";
192                                 uses base-endpoint:address-endpoint-key;
193                                 uses has-rule-group-with-renderer-endpoint-participation;
194                             }
195
196                             list peer-external-endpoint {
197                                 description "peer external endpoint with-policy - keys";
198                                 key "context-type context-id address-type address";
199                                 uses base-endpoint:address-endpoint-key;
200                                 uses has-rule-group-with-renderer-endpoint-participation;
201                             }
202
203                             list peer-external-containment-endpoint {
204                                 description "peer external endpoint with containment and policy - keys";
205                                 key "context-type context-id";
206                                 uses forwarding:context-key;
207                                 uses has-rule-group-with-renderer-endpoint-participation;
208                             }
209                         }
210                     }
211
212                     container rule-groups {
213                         list rule-group {
214                             min-elements 1;
215                             description "A specific policy rule group that apply to pair of endpoints.
216                                 The policy rule group represents the subject with resolved rules.";
217                             key "tenant-id contract-id subject-name";
218                             uses resolved-policy:has-subject-key;
219
220                             uses policy:has-order;
221                             uses resolved-policy:has-resolved-rules;
222                         }
223                     }
224
225                     container endpoints {
226                         list address-endpoint-with-location {
227                             min-elements 1;
228                             key "context-type context-id address-type address";
229                             uses base-endpoint:address-endpoint-fields;
230                             uses base-endpoint:has-location;
231                             uses has-renderer-name;
232                         }
233
234                         list containment-endpoint-with-location {
235                             key "context-type context-id";
236                             uses base-endpoint:containment-endpoint-fields;
237                             uses base-endpoint:has-relative-location;
238                         }
239                     }
240
241                     container renderer-forwarding {
242                         list renderer-forwarding-by-tenant {
243                             min-elements 1;
244                             key tenant-id;
245                             leaf tenant-id {
246                                 type gbp-common:tenant-id;
247                                 description
248                                             "The tenant with which forwarding is associated";
249                             }
250
251                             list renderer-forwarding-context {
252                                 key "context-type context-id";
253                                 uses forwarding:context-key;
254
255                                 uses forwarding:forwarding-fields;
256                             }
257
258                             list renderer-network-domain {
259                                 key "network-domain-type network-domain-id";
260                                 uses forwarding:network-domain-key;
261
262                                 uses forwarding:forwarding-fields;
263                                 description "Renderer network domain can be augmented with further information.";
264                             }
265                         }
266                     }
267                 }
268
269                 container status {
270                     description "The renderer exposes status of policy here.";
271                     config false;
272
273                     container unconfigured-endpoints {
274                         list unconfigured-renderer-endpoint {
275                             description "Renderer-endpoint with unconfigured rules.";
276                             key "context-type context-id address-type address";
277                             uses base-endpoint:address-endpoint-key;
278
279                             list unconfigured-peer-endpoint {
280                                 key "context-type context-id address-type address";
281                                 uses base-endpoint:address-endpoint-key;
282                                 uses has-unconfigured-rule-groups;
283                             }
284
285                             list unconfigured-peer-external-endpoint {
286                                 key "context-type context-id address-type address";
287                                 uses base-endpoint:address-endpoint-key;
288                                 uses has-unconfigured-rule-groups;
289                             }
290
291                             list unconfigured-peer-external-containment-endpoint {
292                                 key "context-type context-id";
293                                 uses forwarding:context-key;
294                                 uses has-unconfigured-rule-groups;
295                             }
296
297                             leaf info {
298                                 description "More details on reason for configuration failure.";
299                                 type string;
300                             }
301                         }
302                     }
303                 }
304             }
305
306             // TODO remove - does not make sense anymore
307             container interests {
308
309                 status deprecated;
310
311                 config false;
312
313                 description "Represents interests of the renderer.";
314
315                 container followed-tenants {
316                     description "Interesting tenants for the renderer.";
317
318                     list followed-tenant {
319                         description "Tenant which is followed by the renderer.";
320
321                         key id;
322
323                         leaf id {
324                             type gbp-common:tenant-id;
325                         }
326
327                         list followed-endpoint-group {
328                             description "Endpoint-group which is followed by the renderer.";
329
330                             key id;
331
332                             leaf id {
333                                 type gbp-common:endpoint-group-id;
334                             }
335                         }
336                     }
337                 }
338             }
339
340             container capabilities {
341
342                 config false;
343
344                 description "Capabilities this renderer provides.";
345
346                 list supported-classifier-definition {
347                     description
348                         "Classifier definitions this renderer can use.";
349
350                     key classifier-definition-id;
351
352                     leaf classifier-definition-id {
353                         description "Reference to a classifier definition in config datastore.";
354                         type leafref {
355                             path "/policy:subject-feature-definitions/policy:classifier-definition/policy:id";
356                         }
357                     }
358
359                     leaf parent-classifier-definition-id {
360                         description
361                             "Optional reference to a parent classifier definition,
362                             to provide a hierarchical structure.";
363                         type leafref {
364                             path "/policy:subject-feature-definitions/policy:classifier-definition/policy:id";
365                         }
366                     }
367
368                     list supported-parameter-values {
369                         description "Represents supported paramters and its values by renderer.
370                             If it contains only parameter-name without paramater-type, it means that any value is supported.";
371                         key parameter-name;
372
373                         leaf parameter-name {
374                             description "TODO";
375                             type leafref {
376                                 path "/policy:subject-feature-definitions/policy:classifier-definition/policy:parameter/policy:name";
377                             }
378                         }
379
380                         uses has-parameters-type;
381                     }
382                 }
383
384                 list supported-action-definition {
385                     description
386                         "Action definitions this renderer can use.";
387
388                     key action-definition-id;
389
390                     leaf action-definition-id {
391                         description "Reference to an action definition in config datastore.";
392                         type leafref {
393                             path "/policy:subject-feature-definitions/policy:action-definition/policy:id";
394                         }
395                     }
396
397                     leaf parent-action-definition-id {
398                         description
399                             "Optional reference to a parent action definition,
400                             to provide a hierarchical structure.";
401                         type leafref {
402                             path "/policy:subject-feature-definitions/policy:action-definition/policy:id";
403                         }
404                     }
405
406                     list supported-parameter-values {
407                         description "Represents supported paramters and its values by renderer.
408                             If it contains only parameter-name without paramater-type, it means that any value is supported.";
409                         key parameter-name;
410
411                         leaf parameter-name {
412                             description "TODO";
413                             type leafref {
414                                 path "/policy:subject-feature-definitions/policy:action-definition/policy:parameter/policy:name";
415                             }
416                         }
417
418                         uses has-parameters-type;
419                     }
420                 }
421             }
422         }
423     }
424 }