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