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