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