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