f3143cd2880c9a8e04e8633f2d51f722f6385e8e
[groupbasedpolicy.git] / groupbasedpolicy / src / main / yang / model / endpoint.yang
1 /*
2  * Copyright (c) 2014 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 endpoint {
10     yang-version 1;
11
12     namespace "urn:opendaylight:groupbasedpolicy:endpoint";
13     prefix "gbp-endpoint";
14
15     import gbp-common {prefix gbp-common;}
16     import ietf-inet-types {prefix inet;}
17     import ietf-yang-types {
18         prefix yang;
19         revision-date 2010-09-24;
20     }
21
22     revision "2014-04-21" {
23         description
24             "Initial revision.";
25     }
26
27     grouping l2-key {
28         description
29             "The fields that identify an endpoint by a layer 2 address";
30         leaf l2-context {
31             type gbp-common:l2-bridge-domain-id;
32             description
33                 "The bridge domain for the layer 2 address for this endpoint";
34         }
35         leaf mac-address {
36             type yang:mac-address;
37             description
38                 "The MAC address for the endpoint";
39         }
40     }
41
42     grouping l3-key {
43         description
44             "The fields that identify an endpoint by a layer 3 address";
45         leaf l3-context {
46             type gbp-common:l3-context-id;
47             mandatory true;
48             description
49                 "The context for this layer 3 address";
50         }
51         leaf ip-address {
52             type inet:ip-address;
53             mandatory true;
54             description
55                 "The actual IP address for the endpoint";
56         }
57     }
58
59     grouping l3-prefix-key {
60         description
61             "The fields that identify an endpoint by a layer 3 prefix";
62         leaf l3-context {
63             type gbp-common:l3-context-id;
64             mandatory true;
65             description
66                 "The context for this layer 3 prefix";
67         }
68         leaf ip-prefix {
69             type inet:ip-prefix;
70             mandatory true;
71             description
72                 "The IP prefix for the endpoint";
73         }
74     }
75
76     // A base type for an end point
77     grouping endpoint-fields {
78         description "An endpoint and its associated metadata";
79         leaf tenant {
80             type gbp-common:tenant-id;
81             mandatory true;
82             description
83                 "The tenant with which this endpoint is associated";
84         }
85
86         uses l2-key;
87
88         leaf network-containment {
89             description
90                 "The network domain associated with this endpoint's fowarding
91                 context.";
92             type gbp-common:network-domain-id;
93         }
94         list l3-address {
95             description
96                 "All the layer 3 addresses associated with this endpoint";
97             key "l3-context ip-address";
98             uses l3-key;
99         }
100         leaf endpoint-group {
101             type gbp-common:endpoint-group-id;
102             description
103                 "The group associated with this endpoint";
104         }
105         leaf-list endpoint-groups {
106             type gbp-common:endpoint-group-id;
107             description
108                 "The groups associated with this endpoint";
109             ordered-by user;
110         }
111         leaf-list condition {
112             type gbp-common:condition-name;
113             description
114                 "The conditions associated with this endpoint";
115         }
116         leaf timestamp {
117             type int64;
118             description
119                 "The last timestamp associated with this endpoint record.
120                  This will be used for aging data in the registry.";
121         }
122     }
123
124     //  L3 Prefix EndPointFields
125     grouping endpoint-l3-prefix-fields {
126         description "An l3 prefix endpoint and its associated metadata";
127         uses l3-prefix-key;
128         leaf tenant {
129             type gbp-common:tenant-id;
130             mandatory true;
131             description
132                 "The tenant with which this endpoint is associated";
133         }
134         leaf endpoint-group {
135             type gbp-common:endpoint-group-id;
136             description
137                 "The group associated with this endpoint";
138         }
139         leaf-list endpoint-groups {
140             type gbp-common:endpoint-group-id;
141             description
142                 "The groups associated with this endpoint";
143             ordered-by user;
144         }
145         leaf-list condition {
146             type gbp-common:condition-name;
147             description
148                 "The conditions associated with this endpoint";
149         }
150         list endpoint-l2-gateways {
151             key "l2-context mac-address";
152             uses l2-key;
153         }
154         list endpoint-l3-gateways {
155             key "l3-context ip-address";
156             uses l3-key;
157         }
158         leaf timestamp {
159             type int64;
160             description
161                 "The last timestamp associated with this endpoint record.
162                  This will be used for aging data in the registry.";
163         }
164     }
165
166     grouping has-endpoint-group-conditions {
167         description
168             "Base type for object with endpoint group to condition
169              mappings.";
170
171         leaf endpoint-group {
172             description "The endpoint group conditions to assign";
173             type gbp-common:endpoint-group-id;
174         }
175         list endpoint-group-condition {
176             description
177                 "The conditions associated with this endpoint
178                  group";
179             key "condition";
180             leaf condition {
181                 description "A condition name to associate.";
182                 type gbp-common:condition-name;
183             }
184         }
185     }
186
187     container endpoints {
188         description
189             "Repository for operational state data about endpoints needed for
190              policy resolution.";
191         config false;
192
193         list endpoint {
194             description
195                 "Endpoints indexed by layer 2 addreses.  When modifying
196                  data here, you must also modify data in the
197                  endpoints-l3 list as well.";
198             key "l2-context mac-address";
199             uses endpoint-fields;
200         }
201
202         list endpoint-l3 {
203             description
204                 "Endpoints indexed by layer 3 addreses.  When modifying
205                  data here, you must also modify data in the endpoints
206                  list as well.";
207             key "l3-context ip-address";
208             uses l3-key;
209             uses endpoint-fields;
210         }
211
212         list endpoint-l3-prefix {
213             key "l3-context ip-prefix";
214             uses endpoint-l3-prefix-fields;
215         }
216
217         list condition-mapping {
218             description
219                 "A list mapping conditions to entire endpoint groups.
220                  This offers a quickly way to set a condition on many
221                  endpoints at once.";
222
223             key "endpoint-group";
224             uses has-endpoint-group-conditions;
225         }
226     }
227
228     rpc register-endpoint {
229         description
230             "Register a new endpoint into the registry.  If there
231              is already an existing endpoint with the same keys, they
232              will be overwritten with the new information.";
233
234         input {
235             uses endpoint-fields;
236         }
237     }
238
239     rpc register-l3-prefix-endpoint {
240         description
241             "Register an L3 Prefix Endpoint to the endpoint registery. If there
242             is already an existing endpoint with the same keys, they
243             will be overwritten with the new information.";
244
245         input {
246             uses endpoint-l3-prefix-fields;
247         }
248     }
249
250     rpc unregister-endpoint {
251         description "Unregister an endpoint or endpoints from the registry.";
252
253         input {
254             list l2 {
255                 key "l2-context mac-address";
256                 uses l2-key;
257             }
258             list l3 {
259                 key "l3-context ip-address";
260                 uses l3-key;
261             }
262             list l3-prefix {
263                 key "l3-context ip-prefix";
264                 uses l3-prefix-key;
265             }
266         }
267     }
268
269     rpc set-endpoint-group-conditions {
270         description
271             "Set a list of conditions for a particular endpoint group.
272              These conditions will apply to all endpoints in the
273              endpoint group.  These conditions will be added to the
274              existing list of conditions.";
275
276         input {
277             uses has-endpoint-group-conditions;
278         }
279     }
280
281     rpc unset-endpoint-group-conditions {
282         description
283             "Remove a list of conditions from an endpoint group.";
284
285         input {
286             uses has-endpoint-group-conditions;
287         }
288     }
289 }