Initial code drop of yang model driven configuration system
[controller.git] / opendaylight / config / config-api / src / main / resources / META-INF / yang / config.yang
1 // vi: set smarttab et sw=4 tabstop=4:
2 module config {
3     yang-version 1;
4     namespace "urn:opendaylight:params:xml:ns:yang:controller:config";
5     prefix "config";
6
7
8     description
9          "This module contains the base YANG definitions for NS-OS
10          configuration subsystem. The system modeled revolves around two
11          major concepts: modules and services.";
12
13     revision "2013-04-05" {
14         description
15             "Reworked to give modules their own space.";
16     }
17
18     revision "2013-04-03" {
19         description
20             "Initial revision.";
21     }
22
23     extension java-class {
24         description
25             "YANG language extension carrying the fully-qualified name of
26              a Java class. Code generation tools use the provided reference
27              to tie a specific construct to its Java representation.";
28
29         argument "name";
30     }
31
32     extension required-identity {
33         description
34             "YANG language extension which indicates that a particular
35              leafref, which points to a identityref, should additionally
36              require the target node is actually set to a descendant to
37              of a particular identity.
38
39              This is a workaround to two YANG deficiencies:
40              1) not being able to leafref instances of identityref
41              2) not being able to refine an identityref
42
43              This extension takes one argument, name, which MUST be the name
44              of an identity. Furthermore, that identity MUST be based,
45              directly or indirectly, on the identity, which is referenced by
46              the leaf reference, which is annotated with this extension.";
47
48         argument "name";
49     }
50
51     extension inner-state-bean {
52         description
53             "YANG language extension which indicates that a particular
54              list located under module's state should be treated as a list
55              of child state beans instead of just an ordinary list attribute";
56     }
57
58     extension provided-service {
59         description
60             "YANG language extension which indicates that a particular
61             module provides certain service. This extension can be placed
62             on identities that are based on module-type. Zero or more services
63             can be provided.
64             This extension takes one argument - name - which MUST be the name
65             of an identity. Furthermore, this identity MUST be based on
66             service-type.";
67
68         argument "name";
69     }
70
71     extension java-name-prefix {
72         description
73             "YANG language extension carrying java simple class name prefix
74             that will be taken into account when generating java code from
75             identities that are based on module-type.";
76             argument "java-prefix";
77     }
78
79     identity module-type {
80         description
81             "Module identity base type. All module identities must be derived
82             from this type. A module type uniquely defines a single atomic
83             component, such as an application. Each such component is assumed
84             to have its unique, stable and versioned configuration structure.";
85     }
86
87     identity service-type {
88         description
89             "Service identity base type. All service identities must be
90              derived from this type. A service type uniquely defines a single
91              atomic API contract, such as a Java interface, a set of C
92              function declarations, or similar.
93
94              If the service type has a corresponding Java interface, the name
95              of that interface should be attached to the derived identity MUST
96              include a java-class keyword, whose name argument points to that
97              interface.";
98     }
99
100     typedef service-type-ref {
101         description
102             "Internal type of references to service type identity.";
103
104         type identityref {
105             base service-type;
106         }
107     }
108
109     grouping service-ref {
110         description
111             "Type of references to a particular service instance. This type
112              can be used when defining module configuration to refer to a
113              particular service instance. Containers using this grouping
114              should not define anything else. The run-time implementation
115              is expected to inject a reference to the service as the value
116              of the container.";
117
118         leaf type {
119             description
120                 "Type of the service being referenced. Users of this grouping
121                  should refine this leaf with required-identity pointing to
122                  the actual service-type which is actually required.";
123
124             mandatory true;
125             type leafref {
126                 path "/config:services/config:service/config:type";
127             }
128         }
129
130         leaf name {
131             mandatory true;
132             type leafref {
133                 path "/config:services/config:service[config:type=current()/../type]/config:instance/config:name";
134             }
135         }
136     }
137
138     container modules {
139         description
140             "Top level container encapsulating configuration of all modules.";
141
142         list module {
143             key "name";
144             leaf name {
145                 description "Unique module instance name";
146                 type string;
147                 mandatory true;
148             }
149
150             leaf type {
151                 type identityref {
152                     base module-type;
153                 }
154                 mandatory true;
155             }
156
157             choice configuration {
158                 mandatory true;
159                 config true;
160             }
161
162             choice state {
163                 config false;
164             }
165         }
166     }
167
168
169     container services {
170         list service {
171             key "type";
172             leaf type {
173                 type service-type-ref;
174             }
175             list instance {
176                 key "name";
177                 leaf name {
178                     type string;
179                 }
180
181                 leaf provider {
182                     mandatory true;
183                     type leafref {
184                         path "/modules/module/name";
185                     }
186                 }
187             }
188         }
189     }
190
191
192 }