Introduced DomainSpecificRegistry service
[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             choice containment {
66                 description
67                             "The network domain associated with this endpoint's fowarding
68                             context.";
69                 case network-domain-containment {
70                     uses forwarding:network-domain-key;
71                 }
72                 case forwarding-context-containment {
73                     uses forwarding:context-key;
74                 }
75             }
76         }
77         leaf-list endpoint-group {
78             type gbp-common:endpoint-group-id;
79             description
80                         "The groups associated with this endpoint";
81             ordered-by user;
82             min-elements 1;
83         }
84         leaf-list condition {
85             type gbp-common:condition-name;
86             description
87                         "The conditions associated with this endpoint";
88         }
89         leaf timestamp {
90             type int64;
91             description
92                         "The last timestamp associated with this endpoint record. This
93                         will be used for aging data in the registry.";
94         }
95     }
96
97     grouping address-endpoint-fields {
98         uses address-endpoint-key;
99         uses parent-child-endpoints;
100         uses common-endpoint-fields;
101     }
102
103     grouping containment-endpoint-fields {
104         uses forwarding:context-key;
105         uses has-child-endpoints;
106         uses common-endpoint-fields;
107     }
108
109     grouping has-endpoint-group-conditions {
110         description
111                 "Base type for object with endpoint group to condition mappings.";
112
113         leaf endpoint-group {
114             description "The endpoint group conditions to assign";
115             type gbp-common:endpoint-group-id;
116         }
117         list endpoint-group-condition {
118             description
119                         "The conditions associated with this endpoint group";
120             key "condition";
121             leaf condition {
122                 description "A condition name to associate.";
123                 type gbp-common:condition-name;
124             }
125         }
126     }
127
128     grouping internal-location-fields {
129         description "Location inside ODL - node and node-connector
130             are represented directly in ODL.";
131         leaf internal-node {
132             mandatory true;
133             type instance-identifier;
134         }
135         leaf internal-node-connector {
136             type instance-identifier;
137         }
138     }
139
140     grouping external-location-fields {
141         description "Location outside of ODL - node and node-connector
142             are outside of ODL. external-node-mount-point is path
143             to external system where node and node-connector are located.";
144         leaf external-node-mount-point {
145             mandatory true;
146             type instance-identifier;
147         }
148         leaf external-node {
149             type string; // TODO switch to external-reference
150         }
151         leaf external-node-connector {
152             type string; // TODO switch to external-reference
153         }
154     }
155
156     grouping has-absolute-location {
157         container absolute-location {
158             choice location-type {
159                 case internal-location-case {
160                     uses internal-location-fields;
161                 }
162                 case external-location-case {
163                     uses external-location-fields;
164                 }
165             }
166         }
167     }
168
169     grouping has-relative-location {
170         container relative-locations {
171             list internal-location {
172                 key "internal-node internal-node-connector";
173                 uses internal-location-fields;
174             }
175             list external-location {
176                 key "external-node-mount-point external-node-connector";
177                 uses external-location-fields;
178             }
179         }
180     }
181
182     grouping has-location {
183         uses has-absolute-location;
184         uses has-relative-location;
185     }
186
187     container endpoints {
188         description
189                 "Repository for operational state data about endpoints needed
190                 for policy resolution.";
191         config false;
192
193         container address-endpoints {
194             list address-endpoint {
195                 key "context-type context-id address-type address";
196                 uses address-endpoint-fields;
197             }
198         }
199
200         container containment-endpoints {
201             list containment-endpoint {
202                 key "context-type context-id";
203                 uses containment-endpoint-fields;
204             }
205         }
206     }
207
208     container endpoint-locations {
209         config false;
210
211         list address-endpoint-location {
212             key "context-type context-id address-type address";
213             uses address-endpoint-key;
214             uses has-location;
215         }
216
217         list containment-endpoint-location {
218             key "context-type context-id";
219             uses forwarding:context-key;
220             uses has-relative-location;
221         }
222     }
223
224     rpc register-endpoint {
225         description
226                 "Register a new endpoint into the registry. If there is already
227                 an existing endpoint with the same keys, they will be overwritten
228                 with the new information.";
229
230         input {
231             list address-endpoint-reg {
232                 key "context-type context-id address-type address";
233                 uses address-endpoint-fields;
234                 uses has-location;
235             }
236             list containment-endpoint-reg {
237                 key "context-type context-id";
238                 uses containment-endpoint-fields;
239                 uses has-relative-location;
240             }
241         }
242     }
243
244     rpc unregister-endpoint {
245         description "Unregister an endpoint or endpoints from the registry.";
246
247         input {
248             list address-endpoint-unreg {
249                 key "context-type context-id address-type address";
250                 uses address-endpoint-key;
251             }
252             list containment-endpoint-unreg {
253                 key "context-type context-id";
254                 uses forwarding:context-key;
255             }
256         }
257     }
258
259 }