Merge "Make sure config.yang is MD-SAL enabled"
[controller.git] / opendaylight / config / config-api / src / main / 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 service-type-ref;
126         }
127
128         leaf name {
129             mandatory true;
130             type leafref {
131                 path "/config:services/config:service[config:type=current()/../type]/config:instance/config:name";
132             }
133         }
134     }
135
136     container modules {
137         description
138             "Top level container encapsulating configuration of all modules.";
139
140         list module {
141             key "name";
142             leaf name {
143                 description "Unique module instance name";
144                 type string;
145                 mandatory true;
146             }
147
148             leaf type {
149                 type identityref {
150                     base module-type;
151                 }
152                 mandatory true;
153             }
154
155             choice configuration {
156                 mandatory true;
157                 config true;
158             }
159
160             choice state {
161                 config false;
162             }
163         }
164     }
165
166
167     container services {
168         list service {
169             key "type";
170             leaf type {
171                 type service-type-ref;
172             }
173             list instance {
174                 key "name";
175                 leaf name {
176                     type string;
177                 }
178
179                 leaf provider {
180                     mandatory true;
181                     type leafref {
182                         path "/modules/module/name";
183                     }
184                 }
185             }
186         }
187     }
188
189
190 }