NeLocationProvider
[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:base_endpoint";
13     prefix "base-endpoint";
14
15     import gbp-common { prefix gbp-common; revision-date 2014-04-21; }
16     import forwarding { prefix forwarding; revision-date 2016-04-27; }
17
18     revision "2016-04-27" {
19         description
20                 "Initial revision.";
21     }
22
23     grouping address-endpoint-key {
24         uses forwarding:context-key;
25         uses forwarding:has-address-type;
26         leaf address {
27             type string;
28             mandatory true;
29         }
30     }
31
32     grouping has-child-endpoints {
33         list child-endpoint {
34             key "context-type context-id address-type address";
35             uses address-endpoint-key;
36         }
37     }
38
39     grouping parent-child-endpoints {
40         choice parent-endpoint-choice {
41             case parent-containment-endpoint-case {
42                 list parent-containment-endpoint {
43                     key "context-type context-id";
44                     uses forwarding:context-key;
45                 }
46             }
47             case parent-endpoint-case {
48                 list parent-endpoint {
49                     key "context-type context-id address-type address";
50                     uses address-endpoint-key;
51                 }
52             }
53         }
54         uses has-child-endpoints;
55     }
56
57     grouping common-endpoint-fields {
58         leaf tenant {
59             type gbp-common:tenant-id;
60             mandatory true;
61             description
62                         "The tenant with which this endpoint is associated";
63         }
64         container network-containment {
65             description
66                         "The network domain associated with this endpoint's fowarding
67                         context.";
68             uses forwarding:network-domain-key;
69         }
70         leaf-list endpoint-group {
71             type gbp-common:endpoint-group-id;
72             description
73                         "The groups associated with this endpoint";
74             ordered-by user;
75             min-elements 1;
76         }
77         leaf-list condition {
78             type gbp-common:condition-name;
79             description
80                         "The conditions associated with this endpoint";
81         }
82         leaf timestamp {
83             type int64;
84             description
85                         "The last timestamp associated with this endpoint record. This
86                         will be used for aging data in the registry.";
87         }
88     }
89
90     grouping address-endpoint-fields {
91         uses address-endpoint-key;
92         uses parent-child-endpoints;
93         uses common-endpoint-fields;
94     }
95
96     grouping containment-endpoint-fields {
97         uses forwarding:context-key;
98         uses has-child-endpoints;
99         uses common-endpoint-fields;
100     }
101
102     grouping has-endpoint-group-conditions {
103         description
104                 "Base type for object with endpoint group to condition mappings.";
105
106         leaf endpoint-group {
107             description "The endpoint group conditions to assign";
108             type gbp-common:endpoint-group-id;
109         }
110         list endpoint-group-condition {
111             description
112                         "The conditions associated with this endpoint group";
113             key "condition";
114             leaf condition {
115                 description "A condition name to associate.";
116                 type gbp-common:condition-name;
117             }
118         }
119     }
120
121     grouping has-regular-location {
122         leaf node {
123             mandatory true;
124             type instance-identifier;
125         }
126         leaf node-connector {
127             type instance-identifier;
128         }
129     }
130
131     grouping has-external-location {
132         leaf external-node-mount-point {
133             mandatory true;
134             type instance-identifier;
135         }
136         leaf external-node-location {
137             type string; // TODO switch to external-reference
138         }
139         leaf external-node-connector {
140             type string; // TODO switch to external-reference
141         }
142     }
143
144     grouping has-location {
145         container real-location {
146             choice location-type {
147                 case regular-location-case {
148                     uses has-regular-location;
149                 }
150                 case external-location-case {
151                     uses has-external-location;
152                 }
153             }
154         }
155         container relative-location {
156             list location {
157                 key "node node-connector";
158                 uses has-regular-location;
159             }
160             list external-location {
161                 key "external-node-mount-point external-node-connector";
162                 uses has-external-location;
163             }
164         }
165     }
166
167     container endpoints {
168         description
169                 "Repository for operational state data about endpoints needed
170                 for policy resolution.";
171         config false;
172
173         container address-endpoints {
174             list address-endpoint {
175                 key "context-type context-id address-type address";
176                 uses address-endpoint-fields;
177             }
178         }
179
180         container containment-endpoints {
181             list containment-endpoint {
182                 key "context-type context-id";
183                 uses containment-endpoint-fields;
184             }
185         }
186     }
187
188     container endpoint-locations {
189         list address-endpoint-location {
190             key "context-type context-id address-type address";
191             uses address-endpoint-key;
192             uses has-location;
193         }
194
195         list containment-endpoint-location {
196             key "context-type context-id";
197             uses forwarding:context-key;
198             uses has-location;
199         }
200     }
201
202     rpc register-endpoint {
203         description
204                 "Register a new endpoint into the registry. If there is already
205                 an existing endpoint with the same keys, they will be overwritten
206                 with the new information.";
207
208         input {
209             list address-endpoint-reg {
210                 key "context-type context-id address-type address";
211                 uses address-endpoint-fields;
212                 uses has-location;
213             }
214             list containment-endpoint-reg {
215                 key "context-type context-id";
216                 uses containment-endpoint-fields;
217                 uses has-location;
218             }
219         }
220     }
221
222     rpc unregister-endpoint {
223         description "Unregister an endpoint or endpoints from the registry.";
224
225         input {
226             list address-endpoint-unreg {
227                 key "context-type context-id address-type address";
228                 uses address-endpoint-key;
229             }
230             list containment-endpoint-unreg {
231                 key "context-type context-id";
232                 uses forwarding:context-key;
233             }
234         }
235     }
236
237 }