Adding endpoint registration using port-name.
[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 {prefix inet;}
17     import ietf-yang-types {
18         prefix yang;
19         revision-date 2010-09-24;
20     } 
21
22     revision "2014-04-21" {
23         description
24             "Initial revision.";
25     }
26
27     grouping l2-key {
28         description 
29             "The fields that identify an endpoint by a layer 2 address";
30         leaf l2-context {
31             type gbp-common:l2-bridge-domain-id;
32             description 
33                 "The bridge domain for the layer 2 address for this endpoint";
34         }
35         leaf mac-address {
36             type yang:mac-address;
37             description 
38                 "The MAC address for the endpoint";
39         }
40     }
41
42     grouping l3-key {
43         description 
44             "The fields that identify an endpoint by a layer 3 address";
45         leaf l3-context {
46             type gbp-common:l3-context-id;
47             mandatory true;
48             description 
49                 "The context for this layer 3 address";
50         }
51         leaf ip-address {
52             type inet:ip-address;
53             mandatory true;
54             description 
55                 "The actual IP address for the endpoint";
56         }
57     }
58
59     // A base type for an end point
60     grouping endpoint-fields {
61         description "An endpoint and its associated metadata";
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
69         uses l2-key;
70
71         list l3-address {
72             description
73                 "All the layer 3 addresses associated with this endpoint";
74             key "l3-context ip-address";
75             uses l3-key;
76         }
77         leaf endpoint-group {
78             type gbp-common:endpoint-group-id;
79             description 
80                 "The group associated with this endpoint";
81         }
82         leaf-list condition {
83             type gbp-common:condition-name;
84             description 
85                 "The conditions associated with this endpoint";
86         }
87         leaf port-name {
88             type gbp-common:name;
89             description 
90                 "Port name";
91         }
92         leaf timestamp {
93             type int64;
94             description
95                 "The last timestamp associated with this endpoint record.  
96                  This will be used for aging data in the registry.";
97         }
98     }
99
100     grouping has-endpoint-group-conditions {
101         description 
102             "Base type for object with endpoint group to condition 
103              mappings.";
104
105         leaf endpoint-group {
106             description "The endpoint group conditions to assign";
107             type gbp-common:endpoint-group-id;
108         }
109         list endpoint-group-condition {
110             description 
111                 "The conditions associated with this endpoint 
112                  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     container endpoints {
122         description 
123             "Repository for operational state data about endpoints needed for
124              policy resolution.";
125         config false;
126
127         list endpoint {
128             description 
129                 "Endpoints indexed by layer 2 addreses.  When modifying
130                  data here, you must also modify data in the
131                  endpoints-l3 list as well.";
132             key "l2-context mac-address";
133             uses endpoint-fields;
134         }
135
136         list endpoint-l3 {
137             description 
138                 "Endpoints indexed by layer 3 addreses.  When modifying 
139                  data here, you must also modify data in the endpoints
140                  list as well.";
141
142             key "l3-context ip-address";
143             uses l3-key;
144
145             uses endpoint-fields;
146         }
147
148         list condition-mapping {
149             description 
150                 "A list mapping conditions to entire endpoint groups.
151                  This offers a quickly way to set a condition on many
152                  endpoints at once.";
153
154             key "endpoint-group";
155             uses has-endpoint-group-conditions;
156         }
157     }
158
159     rpc register-endpoint {
160         description
161             "Register a new endpoint into the registry.  If there
162              is already an existing endpoint with the same keys, they 
163              will be overwritten with the new information.";
164
165         input {
166             uses endpoint-fields;
167         }
168     }
169
170     rpc unregister-endpoint {
171         description "Unregister an endpoint or endpoints from the registry.";
172
173         input {
174             list l2 {
175                 key "l2-context mac-address";
176                 uses l2-key;
177             }
178             list l3 {
179                 key "l3-context ip-address";
180                 uses l3-key;
181             }
182         }
183     }
184
185     rpc set-endpoint-group-conditions {
186         description
187             "Set a list of conditions for a particular endpoint group.  
188              These conditions will apply to all endpoints in the
189              endpoint group.  These conditions will be added to the 
190              existing list of conditions.";
191
192         input {
193             uses has-endpoint-group-conditions;
194         }
195     }
196
197     rpc unset-endpoint-group-conditions {
198         description
199             "Remove a list of conditions from an endpoint group.";
200
201         input {
202             uses has-endpoint-group-conditions;
203         }
204     }
205 }