9dc61ebe6b7747c1283890f906b1e83cde533d7d
[controller.git] / opendaylight / model / model-inventory / src / main / yang / opendaylight-inventory.yang
1 module opendaylight-inventory {
2     namespace "urn:opendaylight:inventory";
3     prefix inv;
4
5     import yang-ext {prefix ext; revision-date "2013-07-09";}
6     import ietf-inet-types {prefix inet; revision-date "2010-09-24";}
7
8
9     revision "2013-08-19" {
10         description "Initial revision of Inventory model";
11     }
12
13
14     typedef support-type {
15         status deprecated;
16         type enumeration {
17             enum native;
18             enum emulated;
19             enum not-supported;
20         }
21     }
22
23     typedef node-id {
24         status deprecated;
25         type inet:uri;
26         description "Identifier for a particular node. For example:
27
28                         myprotocol:<unique_node_id>
29
30                         myprotocol:12
31
32                     It is a good practice to always lead with a scoping identifier.
33                     In the example above the scoping was 'myprotocol'. In your app you
34                     could use 'myapp' etc.";
35     }
36
37     typedef node-connector-id {
38         status deprecated;
39         type inet:uri;
40         description "Identifier for a particular node-connector. For example:
41
42                         myprotocol:<unique_node_connector_id>
43                         myprotocol:3
44
45                     It is a good practice to always lead with a scoping identifier.
46                     In the example above the scoping was 'myprotocol'. In your app you
47                     could use 'myapp' etc.";
48
49     }
50
51     //YANG does not have a statement which limits the scope of an instance-identifier to a particular subtree,
52     //which is why we are using a type capture and not an instance-identifier to define a node-ref and a node-connector-ref.
53     typedef node-ref {
54         status deprecated;
55         type instance-identifier;
56         description "A reference that points to an opendaylight-light:nodes/node in the data tree.";
57     }
58
59     typedef node-connector-ref {
60         status deprecated;
61         type instance-identifier;
62         description "A reference that points to an opendaylight-list:nodes/node/{node-id}/node-connector in the data tree.";
63     }
64
65     identity node-context {
66         status deprecated;
67         description "A node-context is a classifier for node elements which allows an RPC to provide a service on behalf of a particular element in the data tree.";
68     }
69
70     identity node-connector-context {
71         status deprecated;
72         description "A node-connector-context is a classifier for node-connector elements which allows an RPC to provide a service on behalf of a particular element in the data tree.";
73     }
74
75     //We are defining a base identity here because there are limitations with yang enums. Yang doesn't allow you to extend enumeratations.
76     //Therefore by defining a base identity we allow other yang files to extend this identity to define additional "enumerations". By
77     //using node-type as their base they are able to pass their object to fields that accept "node-types" while uniquely describing their
78     //type of node, such as "router-node" or "switch-node" etc.
79     //See https://wiki.opendaylight.org/view/YANG_Tools:YANG_to_Java_Mapping#Identity for more information.
80     identity node-type {
81         status deprecated;
82         description "A base identity definition which represents a generic node type and can be extended in other yang files.";
83     }
84
85     identity node-connector-type {
86         status deprecated;
87         description "A base identity definition which represents a generic node connector type and can be extended in other yang files.";
88     }
89
90     grouping node {
91         status deprecated;
92         description "Describes the contents of a generic node -
93                      essentially an ID and a list of node-connectors.
94                      Acts as an augmentation point where other yang files
95                       can add additional information.";
96
97         leaf id {
98             type node-id;
99             description "The unique identifier for the node.";
100         }
101
102         list "node-connector" {
103             key "id";
104
105             description "A list of node connectors that belong this node.";
106             ext:context-instance "node-connector-context";
107
108             uses node-connector;
109         }
110     }
111
112     grouping node-connector {
113         status deprecated;
114         description "Describes a generic node connector which consists of an ID.
115                      Acts as an augmentation point where other yang files can
116                       add additional information.";
117
118         leaf id {
119             type node-connector-id;
120             description "The unique identifier for the node-connector.";
121         }
122     }
123
124     grouping node-context-ref {
125         status deprecated;
126         description
127         "A helper grouping which contains a reference to a node classified with a node-context. This allows RPCs in other yang files to refine their input to a particular node instance.";
128
129         leaf node {
130             ext:context-reference "node-context";
131             type node-ref;
132             description "A reference to a particular node.";
133         }
134     }
135
136     /** Base structure **/
137     container nodes {
138         status deprecated;
139         description "The root container of all nodes.";
140
141         list node {
142             key "id";
143             ext:context-instance "node-context";
144             description "A list of nodes (as defined by the 'grouping node').";
145             uses node; //this refers to the 'grouping node' defined above.
146         }
147     }
148
149     //The following notifications should really be replaced by direct writes to the data tree with data change listeners listening to those changes.
150     //Notifications should be reserved for one time events which do not require persistence to the data tree.
151     notification node-updated {
152         status deprecated;
153
154         description "A notification sent by someone who realized there was a modification to a node, but did not modify the data tree.
155                     Describes that something on the node has been updated (including addition of a new node), but is for
156                     whatever reason is not modifying the data tree.
157
158                     Deprecated: If a process determines that a node was updated, then that
159                     logic should update the node using the DataBroker directly. Listeners interested
160                     update changes should register a data change listener for notifications on removals.";
161
162         leaf node-ref {
163             ext:context-reference "node-context";
164             description "A reference to the node which changed.";
165
166             type node-ref;
167         }
168         uses node;
169     }
170
171     notification node-connector-updated {
172
173         status deprecated;
174
175         description "A notification sent by someone who realized there was a modification to a node-connector, but did not modify the data tree.
176                     Describes that something on the node-connector has been updated (including addition of a new node-connector), but is for
177                     whatever reason is not modifying the data tree.
178
179                     Deprecated: If a process determines that a node-connector was updated, then that
180                     logic should update the node-connector using the DataBroker directly. Listeners interested
181                     update changes should register a data change listener for notifications on removals.";
182
183         leaf node-connector-ref {
184             ext:context-reference "node-connector-context";
185             type node-connector-ref;
186             description "A reference to the node-connector which changed.";
187         }
188         uses node-connector;
189     }
190
191     notification node-removed {
192
193         status deprecated;
194
195         description "A notification sent by someone who realized there was a node was removed, but did not modify the data tree.
196                     Describes that a node has been removed but is for
197                     whatever reason is not modifying the data tree.
198
199                     Deprecated: If a process determines that a node was removed, then that
200                     logic should remove the node from the DataBroker directly. Listeners interested
201                     in changes should register a data change listener for notifications on removals.";
202
203         leaf node-ref {
204             description "A reference to the node that was removed.";
205             ext:context-reference "node-context";
206             type node-ref;
207         }
208     }
209
210     notification node-connector-removed {
211
212         status deprecated;
213
214         description "A notification sent by someone who realized there was a node-connector was removed, but did not modify the data tree.
215                     Describes that a node-connector has been removed but is for
216                     whatever reason is not modifying the data tree.
217
218                     Deprecated: If a process determines that a node-connector was removed, then that
219                     logic should remove the node-connector from the DataBroker directly. Listeners interested
220                     in changes should register a data change listener for notifications on removals.";
221
222         leaf node-connector-ref {
223             description "A reference to the node-connector that was removed.";
224             ext:context-reference "node-connector-context";
225             type node-connector-ref;
226         }
227     }
228 }