Merge "gbp-old ui folders structure changed, new ui components"
[groupbasedpolicy.git] / groupbasedpolicy / src / main / yang / model / base-endpoint.yang
1 /*
2  * Copyright (c) 2016 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 base-endpoint {
10     yang-version 1;
11
12     namespace "urn:opendaylight:groupbasedpolicy:endpoints";
13     prefix "base-endpoint";
14
15     import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
16     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
17     import ietf-yang-types { prefix yang; revision-date 2010-09-24; }
18
19     revision "2016-04-27" {
20         description
21                 "Initial revision.";
22     }
23
24     typedef address {
25         type string;
26     }
27
28     typedef mac-address {
29         // TODO should be moved to separate yang
30         type address {
31             pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
32         }
33     }
34
35     typedef ipv4-prefix {
36         // TODO should be moved to separate yang
37         type address {
38             pattern
39                 '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
40               +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
41               + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
42         }
43         description
44             "The ipv4-prefix type represents an IPv4 address prefix.
45              The prefix length is given by the number following the
46              slash character and must be less than or equal to 32.
47              A prefix length value of n corresponds to an IP address
48              mask that has n contiguous 1-bits from the most
49              significant bit (MSB) and all other bits set to 0.
50              The canonical format of an IPv4 prefix has all bits of
51              the IPv4 address set to zero that are not part of the
52              IPv4 prefix.";
53     }
54
55     typedef ipv6-prefix {
56         // TODO should be moved to separate yang
57         type address {
58             pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
59                 + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
60                 + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
61                 + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
62                 + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
63             pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
64                 + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
65                 + '(/.+)';
66         }
67         description
68             "The ipv6-prefix type represents an IPv6 address prefix.
69              The prefix length is given by the number following the
70              slash character and must be less than or equal 128.
71              A prefix length value of n corresponds to an IP address
72              mask that has n contiguous 1-bits from the most
73              significant bit (MSB) and all other bits set to 0.
74              The IPv6 address should have all bits that do not belong
75              to the prefix set to zero.
76              The canonical format of an IPv6 prefix has all bits of
77              the IPv6 address set to zero that are not part of the
78              IPv6 prefix.  Furthermore, IPv6 address is represented
79              in the compressed format described in RFC 4291, Section
80              2.2, item 2 with the following additional rules: the ::
81              substitution must be applied to the longest sequence of
82              all-zero 16-bit chunks in an IPv6 address.  If there is
83              a tie, the first sequence of all-zero 16-bit chunks is
84              replaced by ::.  Single all-zero 16-bit chunks are not
85              compressed.  The canonical format uses lowercase
86              characters and leading zeros are not allowed.";
87         reference
88             "RFC 4291: IP Version 6 Addressing Architecture";
89     }
90
91     grouping containment-endpoint-key {
92         leaf containment {
93             type gbp-common:context-id;
94             mandatory true;
95         }
96     }
97
98     grouping address-endpoint-key {
99         leaf address {
100             type address;
101             mandatory true;
102         }
103     }
104
105     grouping endpoint-key {
106         uses containment-endpoint-key;
107         uses address-endpoint-key;
108     }
109
110     grouping has-child-endpoints {
111         list child-endpoint {
112             key "containment address";
113             uses endpoint-key;
114         }
115     }
116
117     grouping parent-child-endpoints {
118         choice parent-endpoint-choice {
119             case parent-containment-endpoint-case {
120                 list parent-containment-endpoint {
121                     key "containment";
122                     uses containment-endpoint-key;
123                 }
124             }
125             case parent-endpoint-case {
126                 list parent-endpoint {
127                     key "containment address";
128                     uses endpoint-key;
129                 }
130             }
131         }
132         uses has-child-endpoints;
133     }
134
135     grouping common-endpoint-fields {
136         leaf tenant {
137             type gbp-common:tenant-id;
138             mandatory true;
139             description
140                         "The tenant with which this endpoint is associated";
141         }
142         leaf network-containment {
143             description
144                         "The network domain associated with this endpoint's fowarding
145                         context.";
146             mandatory true;
147             type gbp-common:network-domain-id;
148         }
149         leaf-list endpoint-group {
150             type gbp-common:endpoint-group-id;
151             description
152                         "The groups associated with this endpoint";
153             ordered-by user;
154             min-elements 1;
155         }
156         leaf-list condition {
157             type gbp-common:condition-name;
158             description
159                         "The conditions associated with this endpoint";
160         }
161         leaf timestamp {
162             type int64;
163             description
164                         "The last timestamp associated with this endpoint record. This
165                         will be used for aging data in the registry.";
166         }
167     }
168
169     grouping has-endpoint-group-conditions {
170         description
171                 "Base type for object with endpoint group to condition mappings.";
172
173         leaf endpoint-group {
174             description "The endpoint group conditions to assign";
175             type gbp-common:endpoint-group-id;
176         }
177         list endpoint-group-condition {
178             description
179                         "The conditions associated with this endpoint group";
180             key "condition";
181             leaf condition {
182                 description "A condition name to associate.";
183                 type gbp-common:condition-name;
184             }
185         }
186     }
187
188     grouping has-regular-location {
189         leaf node {
190             mandatory true;
191             type instance-identifier;
192         }
193         leaf node-connector {
194             type instance-identifier;
195         }
196     }
197
198     grouping has-external-location {
199         leaf external-node-mount-point {
200             mandatory true;
201             type instance-identifier;
202         }
203         leaf external-node-location {
204             type string; // TODO switch to external-reference
205         }
206         leaf external-node-connector {
207             type string; // TODO switch to external-reference
208         }
209     }
210
211     grouping has-location {
212         container real-location {
213             choice location-type {
214                 case regular-location {
215                     uses has-regular-location;
216                 }
217                 case external-location {
218                     uses has-external-location;
219                 }
220             }
221         }
222         container relative-location {
223             list location {
224                 key "node node-connector";
225                 uses has-regular-location;
226             }
227             list external-location {
228                 key "external-node-mount-point external-node-connector";
229                 uses has-external-location;
230             }
231         }
232     }
233
234     container endpoints {
235         description
236                 "Repository for operational state data about endpoints needed
237                 for policy resolution.";
238         config false;
239
240         list address-endpoints-by-containment {
241             key containment;
242             uses containment-endpoint-key;
243
244             list address-endpoint {
245                 key address;
246                 uses address-endpoint-key;
247
248                 uses parent-child-endpoints;
249                 uses common-endpoint-fields;
250                 min-elements 1;
251             }
252         }
253
254         list containment-endpoint {
255             key "containment";
256             uses containment-endpoint-key;
257
258             uses has-child-endpoints;
259             uses common-endpoint-fields;
260         }
261     }
262
263     container endpoint-locations {
264         list address-endpoint-location {
265             key "containment address";
266             uses endpoint-key;
267             uses has-location;
268         }
269
270         list containment-endpoint-location {
271             key "containment";
272             uses containment-endpoint-key;
273             uses has-location;
274         }
275     }
276
277     rpc register-endpoint {
278         description
279                 "Register a new endpoint into the registry. If there is already
280                 an existing endpoint with the same keys, they will be overwritten
281                 with the new information.";
282
283         input {
284             list address-endpoint {
285                 key "containment address";
286                 uses endpoint-key;
287
288                 uses parent-child-endpoints;
289                 uses common-endpoint-fields;
290                 uses has-location;
291             }
292             list containment-endpoint {
293                 key "containment";
294                 uses containment-endpoint-key;
295
296                 uses has-child-endpoints;
297                 uses common-endpoint-fields;
298                 uses has-location;
299             }
300         }
301     }
302
303     rpc unregister-endpoint {
304         description "Unregister an endpoint or endpoints from the registry.";
305
306         input {
307             list address-endpoint {
308                 key "containment address";
309                 uses endpoint-key;
310             }
311             list containment-endpoint {
312                 key "containment";
313                 uses containment-endpoint-key;
314             }
315         }
316     }
317
318 }