ce394e27c1bedfb106d5a8d721e9c9db7adb174d
[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 has-regular-location {
129         leaf node {
130             mandatory true;
131             type instance-identifier;
132         }
133         leaf node-connector {
134             type instance-identifier;
135         }
136     }
137
138     grouping has-external-location {
139         leaf external-node-mount-point {
140             mandatory true;
141             type instance-identifier;
142         }
143         leaf external-node-location {
144             type string; // TODO switch to external-reference
145         }
146         leaf external-node-connector {
147             type string; // TODO switch to external-reference
148         }
149     }
150
151     grouping has-location {
152         container real-location {
153             choice location-type {
154                 case regular-location-case {
155                     uses has-regular-location;
156                 }
157                 case external-location-case {
158                     uses has-external-location;
159                 }
160             }
161         }
162         container relative-location {
163             list location {
164                 key "node node-connector";
165                 uses has-regular-location;
166             }
167             list external-location {
168                 key "external-node-mount-point external-node-connector";
169                 uses has-external-location;
170             }
171         }
172     }
173
174     container endpoints {
175         description
176                 "Repository for operational state data about endpoints needed
177                 for policy resolution.";
178         config false;
179
180         container address-endpoints {
181             list address-endpoint {
182                 key "context-type context-id address-type address";
183                 uses address-endpoint-fields;
184             }
185         }
186
187         container containment-endpoints {
188             list containment-endpoint {
189                 key "context-type context-id";
190                 uses containment-endpoint-fields;
191             }
192         }
193     }
194
195     container endpoint-locations {
196         list address-endpoint-location {
197             key "context-type context-id address-type address";
198             uses address-endpoint-key;
199             uses has-location;
200         }
201
202         list containment-endpoint-location {
203             key "context-type context-id";
204             uses forwarding:context-key;
205             uses has-location;
206         }
207     }
208
209     rpc register-endpoint {
210         description
211                 "Register a new endpoint into the registry. If there is already
212                 an existing endpoint with the same keys, they will be overwritten
213                 with the new information.";
214
215         input {
216             list address-endpoint-reg {
217                 key "context-type context-id address-type address";
218                 uses address-endpoint-fields;
219                 uses has-location;
220             }
221             list containment-endpoint-reg {
222                 key "context-type context-id";
223                 uses containment-endpoint-fields;
224                 uses has-location;
225             }
226         }
227     }
228
229     rpc unregister-endpoint {
230         description "Unregister an endpoint or endpoints from the registry.";
231
232         input {
233             list address-endpoint-unreg {
234                 key "context-type context-id address-type address";
235                 uses address-endpoint-key;
236             }
237             list containment-endpoint-unreg {
238                 key "context-type context-id";
239                 uses forwarding:context-key;
240             }
241         }
242     }
243
244 }