Bharat saraswal
Committed by Gerrit Code Review

[ONOS-5084],[ONOS-5083] YANG schema registry for YMS

Change-Id: I88394307cb9be30237be0bb17e013d7af88a607c
Showing 29 changed files with 1859 additions and 25 deletions
1 BUNDLES = [ 1 BUNDLES = [
2 '//apps/yms/api:onos-apps-yms-api', 2 '//apps/yms/api:onos-apps-yms-api',
3 - '//apps/yms/app:onos-apps-yms-app',
4 ] 3 ]
5 4
6 onos_app( 5 onos_app(
......
...@@ -26,6 +26,7 @@ import org.onosproject.yms.ydt.YdtResponse; ...@@ -26,6 +26,7 @@ import org.onosproject.yms.ydt.YdtResponse;
26 import org.onosproject.yms.ydt.YdtWalker; 26 import org.onosproject.yms.ydt.YdtWalker;
27 import org.onosproject.yms.ydt.YmsOperationType; 27 import org.onosproject.yms.ydt.YmsOperationType;
28 import org.onosproject.yms.ynh.YangNotificationService; 28 import org.onosproject.yms.ynh.YangNotificationService;
29 +import org.onosproject.yms.ysr.YangModuleIdentifier;
29 import org.onosproject.yms.ysr.YangModuleLibrary; 30 import org.onosproject.yms.ysr.YangModuleLibrary;
30 31
31 /** 32 /**
...@@ -310,11 +311,11 @@ public interface YmsService { ...@@ -310,11 +311,11 @@ public interface YmsService {
310 * The server can optionally support retrieval of the YANG modules it 311 * The server can optionally support retrieval of the YANG modules it
311 * supports. 312 * supports.
312 * 313 *
313 - * @param moduleName YANG module name. 314 + *
314 - * @param moduleNamespace namespace in which the module is defined. 315 + * @param moduleIdentifier module's identifier
315 * @return YANG file contents of the requested YANG module. 316 * @return YANG file contents of the requested YANG module.
316 */ 317 */
317 - String getYangFile(String moduleName, String moduleNamespace); 318 + String getYangFile(YangModuleIdentifier moduleIdentifier);
318 319
319 /** 320 /**
320 * Register protocol specific default CODEC. This is can be used by 1st 321 * Register protocol specific default CODEC. This is can be used by 1st
......
...@@ -28,11 +28,11 @@ public interface YangModuleIdentifier { ...@@ -28,11 +28,11 @@ public interface YangModuleIdentifier {
28 * 28 *
29 * @return the name of the YANG module 29 * @return the name of the YANG module
30 */ 30 */
31 - String getModuleName(); 31 + String moduleName();
32 32
33 /** 33 /**
34 * Retrieves revision of the YANG module. 34 * Retrieves revision of the YANG module.
35 - * 35 + * <p>
36 * Reference RFC 7895 36 * Reference RFC 7895
37 * Each YANG module and submodule within the library has a 37 * Each YANG module and submodule within the library has a
38 * revision. This is derived from the most recent revision statement 38 * revision. This is derived from the most recent revision statement
...@@ -42,5 +42,5 @@ public interface YangModuleIdentifier { ...@@ -42,5 +42,5 @@ public interface YangModuleIdentifier {
42 * 42 *
43 * @return revision of the YANG module 43 * @return revision of the YANG module
44 */ 44 */
45 - String getRevision(); 45 + String revision();
46 } 46 }
......
...@@ -48,7 +48,7 @@ public interface YangModuleInformation { ...@@ -48,7 +48,7 @@ public interface YangModuleInformation {
48 * 48 *
49 * @return YANG modules identifier 49 * @return YANG modules identifier
50 */ 50 */
51 - YangModuleIdentifier getModuleIdentifier(); 51 + YangModuleIdentifier moduleIdentifier();
52 52
53 /** 53 /**
54 * Retrieves the YANG modules namespace. 54 * Retrieves the YANG modules namespace.
...@@ -56,7 +56,7 @@ public interface YangModuleInformation { ...@@ -56,7 +56,7 @@ public interface YangModuleInformation {
56 * 56 *
57 * @return YANG modules namespace 57 * @return YANG modules namespace
58 */ 58 */
59 - String getNamespace(); 59 + String namespace();
60 60
61 /** 61 /**
62 * Reference RFC 7895 62 * Reference RFC 7895
...@@ -66,7 +66,7 @@ public interface YangModuleInformation { ...@@ -66,7 +66,7 @@ public interface YangModuleInformation {
66 * 66 *
67 * @return list of YANG features 67 * @return list of YANG features
68 */ 68 */
69 - List<String> getFeatureList(); 69 + List<String> featureList();
70 70
71 /** 71 /**
72 * Retrieves the list of submodules in the module. 72 * Retrieves the list of submodules in the module.
...@@ -78,5 +78,5 @@ public interface YangModuleInformation { ...@@ -78,5 +78,5 @@ public interface YangModuleInformation {
78 * 78 *
79 * @return list of submodules in the module 79 * @return list of submodules in the module
80 */ 80 */
81 - List<YangModuleIdentifier> getSubModuleIdentifier(); 81 + List<YangModuleIdentifier> subModuleIdentifiers();
82 } 82 }
......
...@@ -63,7 +63,7 @@ public interface YangModuleLibrary { ...@@ -63,7 +63,7 @@ public interface YangModuleLibrary {
63 * 63 *
64 * @return module set id of the YANG library 64 * @return module set id of the YANG library
65 */ 65 */
66 - String getModuleSetId(); 66 + String moduleSetId();
67 67
68 /** 68 /**
69 * Retrieves the current list of YANG modules supported in the server. 69 * Retrieves the current list of YANG modules supported in the server.
...@@ -80,5 +80,5 @@ public interface YangModuleLibrary { ...@@ -80,5 +80,5 @@ public interface YangModuleLibrary {
80 * 80 *
81 * @return the current list of YANG modules supported in the server 81 * @return the current list of YANG modules supported in the server
82 */ 82 */
83 - List<YangModuleInformation> getYangModuleList(); 83 + List<YangModuleInformation> yangModuleList();
84 } 84 }
......
1 -COMPILE_DEPS = [
2 - '//lib:CORE_DEPS',
3 - '//apps/yms/api:onos-apps-yms-api',
4 -]
5 -
6 -osgi_jar_with_tests(
7 - deps = COMPILE_DEPS,
8 -)
...@@ -34,23 +34,87 @@ ...@@ -34,23 +34,87 @@
34 34
35 <dependencies> 35 <dependencies>
36 <dependency> 36 <dependency>
37 + <groupId>org.apache.felix</groupId>
38 + <artifactId>org.apache.felix.framework</artifactId>
39 + <version>4.2.1</version>
40 + </dependency>
41 + <dependency>
42 + <groupId>commons-io</groupId>
43 + <artifactId>commons-io</artifactId>
44 + <version>2.4</version>
45 + </dependency>
46 + <dependency>
37 <groupId>org.onosproject</groupId> 47 <groupId>org.onosproject</groupId>
38 <artifactId>onos-app-yms-api</artifactId> 48 <artifactId>onos-app-yms-api</artifactId>
39 <version>${project.version}</version> 49 <version>${project.version}</version>
40 </dependency> 50 </dependency>
41 - 51 + <dependency>
52 + <groupId>org.onosproject</groupId>
53 + <artifactId>onos-yang-maven-plugin</artifactId>
54 + <version>1.8</version>
55 + </dependency>
56 + <dependency>
57 + <groupId>org.onosproject</groupId>
58 + <artifactId>onos-yang-datamodel</artifactId>
59 + <version>1.8</version>
60 + </dependency>
42 <dependency> 61 <dependency>
43 <groupId>org.onosproject</groupId> 62 <groupId>org.onosproject</groupId>
44 <artifactId>onlab-junit</artifactId> 63 <artifactId>onlab-junit</artifactId>
45 <scope>test</scope> 64 <scope>test</scope>
46 </dependency> 65 </dependency>
47 - 66 + <dependency>
67 + <groupId>org.easymock</groupId>
68 + <artifactId>easymock</artifactId>
69 + <scope>test</scope>
70 + </dependency>
48 <dependency> 71 <dependency>
49 <groupId>org.onosproject</groupId> 72 <groupId>org.onosproject</groupId>
50 - <artifactId>onos-api</artifactId> 73 + <artifactId>onlab-osgi</artifactId>
51 - <classifier>tests</classifier>
52 <scope>test</scope> 74 <scope>test</scope>
53 </dependency> 75 </dependency>
76 + <!-- https://mvnrepository.com/artifact/org.springframework.osgi/spring-osgi-mock -->
77 + <dependency>
78 + <groupId>org.springframework.osgi</groupId>
79 + <artifactId>spring-osgi-mock</artifactId>
80 + <version>1.2.1</version>
81 + </dependency>
82 +
54 </dependencies> 83 </dependencies>
55 84
85 + <build>
86 + <plugins>
87 + <plugin>
88 + <groupId>org.apache.felix</groupId>
89 + <artifactId>maven-bundle-plugin</artifactId>
90 + <version>3.2.0</version>
91 + <extensions>true</extensions>
92 + <configuration>
93 + <instructions>
94 + <Private-Package>
95 + org.onosproject.yangutils.datamodel.*,
96 + org.onosproject.yangutils.translator.*,
97 + org.onosproject.yangutils.linker.*,
98 + org.onosproject.yangutils.utils.*
99 + </Private-Package>
100 + </instructions>
101 + </configuration>
102 + </plugin>
103 + <plugin>
104 + <groupId>org.onosproject</groupId>
105 + <artifactId>onos-yang-maven-plugin</artifactId>
106 + <version>1.8</version>
107 + <configuration>
108 + <yangFilesDir>src/test/resources/</yangFilesDir>
109 + </configuration>
110 + <executions>
111 + <execution>
112 + <goals>
113 + <goal>yang2java</goal>
114 + </goals>
115 + </execution>
116 + </executions>
117 + </plugin>
118 + </plugins>
119 + </build>
56 </project> 120 </project>
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ymsm;
18 +
19 +import org.apache.felix.scr.annotations.Activate;
20 +import org.apache.felix.scr.annotations.Component;
21 +import org.apache.felix.scr.annotations.Deactivate;
22 +import org.apache.felix.scr.annotations.Reference;
23 +import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.apache.felix.scr.annotations.Service;
25 +import org.onosproject.core.ApplicationId;
26 +import org.onosproject.core.CoreService;
27 +import org.onosproject.core.IdGenerator;
28 +import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
29 +import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
30 +import org.onosproject.yms.app.ysr.YangSchemaRegistry;
31 +import org.onosproject.yms.ych.YangCodecHandler;
32 +import org.onosproject.yms.ych.YangDataTreeCodec;
33 +import org.onosproject.yms.ych.YangProtocolEncodingFormat;
34 +import org.onosproject.yms.ydt.YdtBuilder;
35 +import org.onosproject.yms.ydt.YdtResponse;
36 +import org.onosproject.yms.ydt.YdtWalker;
37 +import org.onosproject.yms.ydt.YmsOperationType;
38 +import org.onosproject.yms.ymsm.YmsService;
39 +import org.onosproject.yms.ynh.YangNotificationService;
40 +import org.onosproject.yms.ysr.YangModuleIdentifier;
41 +import org.onosproject.yms.ysr.YangModuleLibrary;
42 +import org.slf4j.Logger;
43 +import org.slf4j.LoggerFactory;
44 +
45 +import java.util.List;
46 +import java.util.concurrent.ExecutorService;
47 +import java.util.concurrent.Executors;
48 +
49 +import static org.onlab.util.Tools.groupedThreads;
50 +
51 +/**
52 + * Represents implementation of YANG management system manager.
53 + */
54 +@Service
55 +@Component(immediate = true)
56 +public class YmsManager
57 + implements YmsService {
58 +
59 + private final Logger log = LoggerFactory.getLogger(getClass());
60 +
61 + private static final String APP_ID = "org.onosproject.app.yms";
62 + private static final String MODULE_ID = "module-id";
63 + private ApplicationId appId;
64 + private YangSchemaRegistry schemaRegistry;
65 + //module id generator should be used to generate a new module id for
66 + //each YSR instance. So YCH also should generate it.
67 + private IdGenerator moduleIdGenerator;
68 + private ExecutorService schemaRegistryExecutor;
69 + private YangNotificationExtendedService ynhExtendedService;
70 +
71 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
72 + protected CoreService coreService;
73 +
74 + @Activate
75 + public void activate() {
76 + appId = coreService.registerApplication(APP_ID);
77 + moduleIdGenerator = coreService.getIdGenerator(MODULE_ID);
78 + schemaRegistry = new DefaultYangSchemaRegistry(String.valueOf(
79 + moduleIdGenerator.getNewId()));
80 + schemaRegistryExecutor =
81 + Executors.newSingleThreadExecutor(groupedThreads(
82 + "onos/apps/yang-management-system/schema-registry",
83 + "schema-registry-handler", log));
84 + log.info("Started");
85 + }
86 +
87 + @Deactivate
88 + public void deactivate() {
89 + ((DefaultYangSchemaRegistry) schemaRegistry).flushYsrData();
90 + schemaRegistryExecutor.shutdown();
91 +
92 + // TODO implementation for other components.
93 + log.info("Stopped");
94 + }
95 +
96 + @Override
97 + public YdtBuilder getYdtBuilder(String logicalRootName,
98 + String rootNamespace,
99 + YmsOperationType operationType) {
100 + return null;
101 + }
102 +
103 + @Override
104 + public YdtBuilder getYdtBuilder(String logicalRootName,
105 + String rootNamespace,
106 + YmsOperationType operationType,
107 + Object schemaRegistryForYdt) {
108 + return null;
109 + }
110 +
111 + @Override
112 + public YdtWalker getYdtWalker() {
113 + return null;
114 + }
115 +
116 + @Override
117 + public YdtResponse executeOperation(YdtBuilder operationRequest) {
118 + return null;
119 + }
120 +
121 + @Override
122 + public YangNotificationService getYangNotificationService() {
123 + return ynhExtendedService;
124 + }
125 +
126 + /**
127 + * Returns YANG notification extended service.
128 + *
129 + * @return YANG notification extended service
130 + */
131 + private YangNotificationExtendedService getYnhExtendedService() {
132 + return ynhExtendedService;
133 + }
134 +
135 + @Override
136 + public YangModuleLibrary getYangModuleLibrary() {
137 + return ((DefaultYangSchemaRegistry) schemaRegistry).getLibrary();
138 + }
139 +
140 + @Override
141 + public String getYangFile(YangModuleIdentifier moduleIdentifier) {
142 + return ((DefaultYangSchemaRegistry) schemaRegistry)
143 + .getYangFile(moduleIdentifier);
144 + }
145 +
146 + @Override
147 + public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
148 + YangProtocolEncodingFormat dataFormat) {
149 +
150 + }
151 +
152 + @Override
153 + public void registerService(Object yangManager, Class<?> yangService,
154 + List<String> supportedFeatureList) {
155 +
156 + //perform registration of service
157 + schemaRegistryExecutor.execute(() -> schemaRegistry
158 + .registerApplication(yangManager, yangService,
159 + getYnhExtendedService()));
160 + }
161 +
162 + @Override
163 + public void unRegisterService(Object appManager, Class<?> yangService) {
164 + schemaRegistry.unRegisterApplication(appManager, yangService);
165 + }
166 +
167 + @Override
168 + public YangCodecHandler getYangCodecHandler() {
169 + return null;
170 + }
171 +
172 + /**
173 + * Returns schema registry.
174 + *
175 + * @return schema registry
176 + */
177 + public YangSchemaRegistry getSchemaRegistry() {
178 + return schemaRegistry;
179 + }
180 +
181 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Provides implementation of YANG application management system manager. YMSM is manager
19 + * of the YANG Core, it manages interaction between application and protocols.
20 + */
21 +package org.onosproject.yms.app.ymsm;
1 +/*
2 + * Copyright 2015-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ynh;
18 +
19 +import org.onosproject.event.ListenerService;
20 +import org.onosproject.yms.ynh.YangNotificationService;
21 +
22 +/**
23 + * Abstraction of an entity which provides interfaces to YANG extended notification
24 + * service. It provides extended interfaces required by YMS internal modules.
25 + * Application registers their schema with YMSM, YMSM delegates the registration
26 + * request to YSR. YSR then looks for the presence of notification in application
27 + * schema, presence of notification will trigger YSR to ask YANG extended notification
28 + * service to register it as a listener to that application events.
29 + */
30 +public interface YangNotificationExtendedService extends YangNotificationService {
31 +
32 + /**
33 + * Registers as listener with application. This is called by YSR when it
34 + * detects notification presence in application YANG file at the time when
35 + * application registers it's schema with YMS.
36 + *
37 + * @param appObject application object
38 + */
39 + void registerAsListener(ListenerService appObject);
40 +
41 + // TODO handle scenario when multiple services are implemented by single manager.
42 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Provides implementation of YANG notification handler. YNH handles notification
19 + * from the application and provide it to the protocols.
20 + */
21 +package org.onosproject.yms.app.ynh;
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import org.onosproject.yms.ysr.YangModuleIdentifier;
20 +
21 +import java.util.Comparator;
22 +import java.util.Objects;
23 +
24 +import static com.google.common.base.MoreObjects.toStringHelper;
25 +
26 +/**
27 + * Representation of default YANG module identifier.
28 + */
29 +class DefaultYangModuleIdentifier implements YangModuleIdentifier,
30 + Comparator<YangModuleIdentifier> {
31 +
32 + private final String moduleName;
33 + private final String revision;
34 +
35 + /**
36 + * Creates an instance of YANG module identifier.
37 + *
38 + * @param moduleName module's name
39 + * @param revision module's revision
40 + */
41 + DefaultYangModuleIdentifier(String moduleName, String revision) {
42 + this.moduleName = moduleName;
43 + this.revision = revision;
44 + }
45 +
46 + @Override
47 + public String moduleName() {
48 + return moduleName;
49 + }
50 +
51 + @Override
52 + public String revision() {
53 + return revision;
54 + }
55 +
56 + @Override
57 + public int hashCode() {
58 + return Objects.hash(moduleName, revision);
59 + }
60 +
61 + @Override
62 + public int compare(YangModuleIdentifier id1, YangModuleIdentifier id2) {
63 + int compare = id1.moduleName().compareTo(id2.moduleName());
64 + if (compare != 0) {
65 + return compare;
66 + }
67 + return id1.revision().compareTo(id2.revision());
68 + }
69 +
70 + @Override
71 + public boolean equals(Object obj) {
72 + if (this == obj) {
73 + return true;
74 + }
75 + if (obj instanceof DefaultYangModuleIdentifier) {
76 + DefaultYangModuleIdentifier that = (DefaultYangModuleIdentifier) obj;
77 + return Objects.equals(moduleName, that.moduleName) &&
78 + Objects.equals(revision, that.revision);
79 + }
80 + return false;
81 + }
82 +
83 + @Override
84 + public String toString() {
85 + return toStringHelper(this)
86 + .add("moduleName", moduleName)
87 + .add("revision", revision)
88 + .toString();
89 + }
90 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import com.google.common.collect.ImmutableList;
20 +import org.onosproject.yms.ysr.YangModuleIdentifier;
21 +import org.onosproject.yms.ysr.YangModuleInformation;
22 +
23 +import java.util.ArrayList;
24 +import java.util.List;
25 +import java.util.Objects;
26 +
27 +import static com.google.common.base.MoreObjects.toStringHelper;
28 +
29 +/**
30 + * Representation of default YANG module information.
31 + */
32 +class DefaultYangModuleInformation implements YangModuleInformation {
33 +
34 + private final YangModuleIdentifier moduleIdentifier;
35 + private final String nameSpace;
36 + private final List<String> features;
37 + private final List<YangModuleIdentifier> subModuleIdentifiers;
38 +
39 + /**
40 + * Creates an instance of YANG module information.
41 + *
42 + * @param moduleIdentifier module identifier
43 + * @param nameSpace name space of module
44 + */
45 + DefaultYangModuleInformation(YangModuleIdentifier moduleIdentifier,
46 + String nameSpace) {
47 + this.moduleIdentifier = moduleIdentifier;
48 + this.nameSpace = nameSpace;
49 + subModuleIdentifiers = new ArrayList<>();
50 + features = new ArrayList<>();
51 + }
52 +
53 + @Override
54 + public YangModuleIdentifier moduleIdentifier() {
55 + return moduleIdentifier;
56 + }
57 +
58 + @Override
59 + public String namespace() {
60 + return nameSpace;
61 + }
62 +
63 + @Override
64 + public List<String> featureList() {
65 + return ImmutableList.copyOf(features);
66 + }
67 +
68 + @Override
69 + public List<YangModuleIdentifier> subModuleIdentifiers() {
70 + return ImmutableList.copyOf(subModuleIdentifiers);
71 + }
72 +
73 + /**
74 + * Adds to YANG sub module identifier list.
75 + *
76 + * @param subModuleIdentifier YANG sub module identifier
77 + */
78 + void addSubModuleIdentifiers(YangModuleIdentifier subModuleIdentifier) {
79 + subModuleIdentifiers.add(subModuleIdentifier);
80 + }
81 +
82 + @Override
83 + public int hashCode() {
84 + return Objects.hash(moduleIdentifier, subModuleIdentifiers, nameSpace, features);
85 + }
86 +
87 + @Override
88 + public boolean equals(Object obj) {
89 + if (this == obj) {
90 + return true;
91 + }
92 + if (obj instanceof DefaultYangModuleInformation) {
93 + DefaultYangModuleInformation that = (DefaultYangModuleInformation) obj;
94 + return Objects.equals(moduleIdentifier, that.moduleIdentifier) &&
95 + Objects.equals(nameSpace, that.nameSpace) &&
96 + Objects.equals(features, that.features) &&
97 + Objects.equals(subModuleIdentifiers, that.subModuleIdentifiers);
98 + }
99 + return false;
100 + }
101 +
102 + @Override
103 + public String toString() {
104 + return toStringHelper(this)
105 + .add("yangModuleIdentifier", moduleIdentifier)
106 + .add("nameSpace", nameSpace)
107 + .add("features", features)
108 + .add("yangModuleIdentifiers", subModuleIdentifiers)
109 + .toString();
110 + }
111 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import com.google.common.collect.ImmutableList;
20 +import org.onosproject.yms.ysr.YangModuleInformation;
21 +import org.onosproject.yms.ysr.YangModuleLibrary;
22 +
23 +import java.util.ArrayList;
24 +import java.util.List;
25 +import java.util.Objects;
26 +
27 +import static com.google.common.base.MoreObjects.toStringHelper;
28 +
29 +/**
30 + * Representation of default YANG module library.
31 + */
32 +class DefaultYangModuleLibrary implements YangModuleLibrary {
33 +
34 + private final String moduleSetId;
35 + private final List<YangModuleInformation> moduleInformation;
36 +
37 + /**
38 + * Creates an instance of YANG module library.
39 + *
40 + * @param moduleSetId module id
41 + */
42 + DefaultYangModuleLibrary(String moduleSetId) {
43 + this.moduleSetId = moduleSetId;
44 + moduleInformation = new ArrayList<>();
45 + }
46 +
47 + @Override
48 + public String moduleSetId() {
49 + return moduleSetId;
50 + }
51 +
52 + @Override
53 + public List<YangModuleInformation> yangModuleList() {
54 + return ImmutableList.copyOf(moduleInformation);
55 + }
56 +
57 + /**
58 + * Adds module information.
59 + *
60 + * @param information module information
61 + */
62 + void addModuleInformation(YangModuleInformation information) {
63 + moduleInformation.add(information);
64 + }
65 +
66 + @Override
67 + public int hashCode() {
68 + return Objects.hash(moduleInformation, moduleSetId);
69 + }
70 +
71 + @Override
72 + public boolean equals(Object obj) {
73 + if (this == obj) {
74 + return true;
75 + }
76 + if (obj instanceof DefaultYangModuleLibrary) {
77 + DefaultYangModuleLibrary that = (DefaultYangModuleLibrary) obj;
78 + return Objects.equals(moduleInformation, that.moduleInformation) &&
79 + Objects.equals(moduleSetId, that.moduleSetId);
80 + }
81 + return false;
82 + }
83 +
84 + @Override
85 + public String toString() {
86 + return toStringHelper(this)
87 + .add("moduleInformation", moduleInformation)
88 + .add("moduleId", moduleSetId)
89 + .toString();
90 + }
91 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import org.onosproject.yangutils.datamodel.YangSchemaNode;
20 +import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
21 +
22 +/**
23 + * Abstraction of entity which provides interfaces to YANG schema registry.
24 + */
25 +public interface YangSchemaRegistry {
26 +
27 + /**
28 + * Registers applications to YMS.
29 + *
30 + * @param managerObject application's object
31 + * @param serviceClass service class which needs to be
32 + * registered
33 + * @param notificationExtendedService notification extended service to
34 + * register application object with YNH
35 + */
36 + void registerApplication(Object managerObject, Class<?> serviceClass,
37 + YangNotificationExtendedService
38 + notificationExtendedService);
39 +
40 + /**
41 + * Unregisters applications to YMS.
42 + *
43 + * @param managerObject application's object
44 + * @param serviceClass service class which needs to be unregistered
45 + */
46 + void unRegisterApplication(Object managerObject, Class<?> serviceClass);
47 +
48 + /**
49 + * Returns application's implementation's class object.
50 + *
51 + * @param yangSchemaNode application's schema node
52 + * @return application's implementation's class object
53 + */
54 + Object getRegisteredApplication(YangSchemaNode yangSchemaNode);
55 +
56 + /**
57 + * Returns YANG schema node using schema name.
58 + *
59 + * @param schemaName module name.
60 + * @return YANG schema node using schema name
61 + */
62 + YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName);
63 +
64 + /**
65 + * Returns YANG schema nodes using application name.
66 + *
67 + * @param appName application's service name
68 + * @return YANG schema nodes using application name
69 + */
70 + YangSchemaNode getYangSchemaNodeUsingAppName(String appName);
71 +
72 + /**
73 + * Returns YANG schema nodes using root interface file name.
74 + *
75 + * @param rootInterfaceFileName name of generated interface file
76 + * for root node
77 + * @return YANG schema nodes using root interface file name
78 + */
79 + YangSchemaNode
80 + getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
81 + String rootInterfaceFileName);
82 +
83 + /**
84 + * Returns YANG schema nodes using root op param file name.
85 + *
86 + * @param rootOpParamFileName name of generated op param file for root node
87 + * @return YANG schema nodes using root op param file name
88 + */
89 + YangSchemaNode
90 + getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
91 + String rootOpParamFileName);
92 +
93 + /**
94 + * Returns YANG schema node of root for notifications.
95 + *
96 + * @param eventSubject event subject
97 + * @return YANG schema node of root for notifications
98 + */
99 + YangSchemaNode getRootYangSchemaNodeForNotification(String eventSubject);
100 +
101 + /**
102 + * Returns registered service class.
103 + *
104 + * @param schemaNode YANG schema node
105 + * @param appName application's name
106 + * @return registered service class
107 + */
108 + Class<?> getRegisteredClass(YangSchemaNode schemaNode, String appName);
109 +
110 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import com.google.common.collect.ImmutableMap;
20 +import org.onosproject.yangutils.datamodel.YangSchemaNode;
21 +
22 +import java.util.Map;
23 +import java.util.Objects;
24 +import java.util.concurrent.ConcurrentHashMap;
25 +import java.util.concurrent.ConcurrentMap;
26 +
27 +/**
28 + * Represents registered application's context for YANG schema registry.
29 + */
30 +public class YsrAppContext {
31 +
32 + /**
33 + * Current application's YANG schema node.
34 + */
35 + private YangSchemaNode curNode;
36 +
37 + /**
38 + * Current application's YANG schema node with different revision store.
39 + */
40 + private final ConcurrentMap<String, YangSchemaNode>
41 + multiRevisionSchemaNodeStore;
42 +
43 + /**
44 + * Current application's object.
45 + */
46 + private Object appObject;
47 +
48 + /**
49 + * Jar file path.
50 + */
51 + private String jarPath;
52 +
53 + /**
54 + * If for current object notification is registered.
55 + */
56 + private boolean isNotificationRegistered;
57 +
58 + /**
59 + * Creates an instance of YANG schema registry application context.
60 + */
61 + YsrAppContext() {
62 + multiRevisionSchemaNodeStore = new ConcurrentHashMap<>();
63 + }
64 +
65 + /**
66 + * Returns current application's object.
67 + *
68 + * @return current application's object
69 + */
70 + Object appObject() {
71 + return appObject;
72 + }
73 +
74 + /**
75 + * Sets current application's object.
76 + *
77 + * @param appObject current application's object
78 + */
79 + void appObject(Object appObject) {
80 + this.appObject = appObject;
81 + }
82 +
83 + /**
84 + * Returns current application's YANG schema node.
85 + *
86 + * @return current application's YANG schema node
87 + */
88 + YangSchemaNode curNode() {
89 + return curNode;
90 + }
91 +
92 + /**
93 + * Sets current application's schema node.
94 + *
95 + * @param node current schema's node
96 + */
97 + void curNode(YangSchemaNode node) {
98 + curNode = node;
99 + }
100 +
101 + /**
102 + * Returns jar file path.
103 + *
104 + * @return jar file path
105 + */
106 + String jarPath() {
107 + return jarPath;
108 + }
109 +
110 + /**
111 + * Sets jar file path.
112 + *
113 + * @param jarPath jar file path
114 + */
115 + void jarPath(String jarPath) {
116 + this.jarPath = jarPath;
117 + }
118 +
119 + @Override
120 + public int hashCode() {
121 + return Objects.hash(curNode, appObject);
122 + }
123 +
124 + @Override
125 + public boolean equals(Object obj) {
126 + if (this == obj) {
127 + return true;
128 + }
129 + if (obj instanceof YsrAppContext) {
130 + YsrAppContext that = (YsrAppContext) obj;
131 + return Objects.equals(curNode, that.curNode) &&
132 + Objects.equals(appObject, that.appObject);
133 + }
134 + return false;
135 + }
136 +
137 + /**
138 + * Returns true if for application object notification is registered.
139 + *
140 + * @return true if for application object notification is registered
141 + */
142 + boolean isNotificationRegistered() {
143 + return isNotificationRegistered;
144 + }
145 +
146 + /**
147 + * Sets true if for application object notification is registered.
148 + *
149 + * @param notificationRegistered true if for application object notification is registered
150 + */
151 + void setNotificationRegistered(boolean notificationRegistered) {
152 + isNotificationRegistered = notificationRegistered;
153 + }
154 +
155 + /**
156 + * Returns YANG schema node store for specific revision.
157 + *
158 + * @return YANG schema node store for specific revision
159 + */
160 + Map<String, YangSchemaNode> getYangSchemaNodeForRevisionStore() {
161 + return ImmutableMap.copyOf(multiRevisionSchemaNodeStore);
162 + }
163 +
164 + /**
165 + * Returns a schema node for specific revision from store.
166 + *
167 + * @param nodeNameWithRevision schema node name for specific revision
168 + * @return schema node for specific revision.
169 + */
170 + YangSchemaNode getSchemaNodeForRevisionStore(String nodeNameWithRevision) {
171 + return multiRevisionSchemaNodeStore.get(nodeNameWithRevision);
172 + }
173 +
174 + /**
175 + * Removes a schema node of specific revision from store.
176 + *
177 + * @param nodeNameWithRevision schema node name for specific revision
178 + */
179 + void removeSchemaNodeForRevisionStore(String nodeNameWithRevision) {
180 + multiRevisionSchemaNodeStore.remove(nodeNameWithRevision);
181 + }
182 +
183 + /**
184 + * Adds schema node with revision from store.
185 + *
186 + * @param nodeNameWithRevision schema node name for specific revision
187 + * @param schemaNode schema node for specific revision
188 + */
189 + void addSchemaNodeWithRevisionStore(String nodeNameWithRevision, YangSchemaNode schemaNode) {
190 + multiRevisionSchemaNodeStore.put(nodeNameWithRevision, schemaNode);
191 + }
192 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Provides implementation of YANG Schema Registry. YSR maintains the schema
19 + * information registry corresponding to registered app.
20 + */
21 +package org.onosproject.yms.app.ysr;
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import org.onosproject.event.ListenerRegistry;
20 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2;
21 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2OpParam;
22 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service;
23 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2Event;
24 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2EventListener;
25 +
26 +/**
27 + * Represent mock implementation for services.
28 + */
29 +public class MockIetfManager
30 + extends ListenerRegistry<IetfNetwork2Event, IetfNetwork2EventListener>
31 + implements IetfNetwork2Service {
32 +
33 + @Override
34 + public IetfNetwork2 getIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
35 + return null;
36 + }
37 +
38 + @Override
39 + public void setIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
40 +
41 + }
42 +
43 +}
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yms.app.ysr;
18 +
19 +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service;
20 +import org.onosproject.yangutils.datamodel.YangSchemaNode;
21 +
22 +import java.io.File;
23 +import java.io.IOException;
24 +import java.util.Set;
25 +
26 +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
27 +import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
28 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
29 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
30 +
31 +/**
32 + * Represents mock bundle context. provides bundle context for YSR to do unit
33 + * testing.
34 + */
35 +public class TestYangSchemaNodeProvider {
36 +
37 + private static final String FS = File.separator;
38 + private static final String PATH = System.getProperty("user.dir") +
39 + FS + "target" + FS + "classes" + FS;
40 + private static final String SER_FILE_PATH = "yang" + FS + "resources" +
41 + FS + "YangMetaData.ser";
42 + private static final String TEMP_FOLDER_PATH = PATH + TEMP;
43 + private final DefaultYangSchemaRegistry defaultYangSchemaRegistry =
44 + new DefaultYangSchemaRegistry("module-id");
45 +
46 + /**
47 + * Creates an instance of mock bundle context.
48 + */
49 + public TestYangSchemaNodeProvider() {
50 + }
51 +
52 + /**
53 + * Process YANG schema node for a application.
54 + *
55 + * @param appObject application object
56 + */
57 + public void processSchemaRegistry(Object appObject) {
58 +
59 + Set<YangSchemaNode> appNode = defaultYangSchemaRegistry
60 + .deSerializeDataModel(PATH + SER_FILE_PATH);
61 + YsrAppContext appContext = new YsrAppContext();
62 + defaultYangSchemaRegistry.ysrContextForSchemaStore(appContext);
63 + defaultYangSchemaRegistry
64 + .setClassLoader(this.getClass().getClassLoader());
65 + String appName;
66 + for (YangSchemaNode node : appNode) {
67 + defaultYangSchemaRegistry.processApplicationContext(node);
68 + defaultYangSchemaRegistry.ysrAppContext().appObject(appObject);
69 + defaultYangSchemaRegistry.ysrContextForAppStore()
70 + .appObject(appObject);
71 + defaultYangSchemaRegistry.ysrContextForSchemaStore()
72 + .appObject(appObject);
73 + appName = node.getJavaPackage() + PERIOD +
74 + getCapitalCase(node.getJavaClassNameOrBuiltInType());
75 + storeClasses(appName);
76 + }
77 +
78 + try {
79 + deleteDirectory(TEMP_FOLDER_PATH);
80 + } catch (IOException e) {
81 + }
82 + }
83 +
84 + /**
85 + * Stores test generated class to YSR store.
86 + *
87 + * @param name name of class
88 + */
89 + private void storeClasses(String name) {
90 + ClassLoader classLoader = this.getClass().getClassLoader();
91 + if (getDefaultYangSchemaRegistry().verifyClassExistence(name)) {
92 + try {
93 + Class<?> nodeClass = classLoader.loadClass(name);
94 + getDefaultYangSchemaRegistry().updateServiceClass(nodeClass);
95 + } catch (ClassNotFoundException e) {
96 + e.printStackTrace();
97 + }
98 + }
99 + }
100 +
101 + /**
102 + * Unregisters services.
103 + *
104 + * @param appName application name
105 + */
106 + public void unregisterService(String appName) {
107 +
108 + if (getDefaultYangSchemaRegistry().verifyClassExistence(appName)) {
109 + try {
110 + Class<?> curClass = Class.forName(appName);
111 + getDefaultYangSchemaRegistry()
112 + .unRegisterApplication(null, curClass);
113 + } catch (ClassNotFoundException e) {
114 + e.printStackTrace();
115 + }
116 + }
117 + }
118 +
119 + /**
120 + * Returns schema registry.
121 + *
122 + * @return schema registry
123 + */
124 + public DefaultYangSchemaRegistry getDefaultYangSchemaRegistry() {
125 + return defaultYangSchemaRegistry;
126 + }
127 +
128 + /**
129 + * Process registration of a service.
130 + */
131 + public void processRegistrationOfApp() {
132 + getDefaultYangSchemaRegistry()
133 + .processRegistration(IetfNetwork1Service.class,
134 + new MockIetfManager(), "target");
135 +
136 + }
137 +
138 +}
1 + module ietf-network4 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + notification network-up {
61 + container networks {
62 + leaf id {
63 + type int32;
64 + }
65 + container network {
66 + leaf ip-address {
67 + type int32;
68 + }
69 + }
70 + }
71 + }
72 + notification network-down {
73 + container networks {
74 + leaf id {
75 + type int32;
76 + }
77 + container network {
78 + leaf ip-address {
79 + type int32;
80 + }
81 + }
82 + }
83 + }
84 +
85 +}
1 + module ietf-network4 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + notification network-up {
71 + container networks {
72 + leaf id {
73 + type int32;
74 + }
75 + container network {
76 + leaf ip-address {
77 + type int32;
78 + }
79 + }
80 + }
81 + }
82 + notification network-down {
83 + container networks {
84 + leaf id {
85 + type int32;
86 + }
87 + container network {
88 + leaf ip-address {
89 + type int32;
90 + }
91 + }
92 + }
93 + }
94 +
95 +}
1 + module ietf-network4 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2016-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + notification network-up {
71 + container networks {
72 + leaf id {
73 + type int32;
74 + }
75 + container network {
76 + leaf ip-address {
77 + type int32;
78 + }
79 + }
80 + }
81 + }
82 + notification network-down {
83 + container networks {
84 + leaf id {
85 + type int32;
86 + }
87 + container network {
88 + leaf ip-address {
89 + type int32;
90 + }
91 + }
92 + }
93 + }
94 +
95 +}
1 + module ietf-network4 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2014-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + notification network-up {
71 + container networks {
72 + leaf id {
73 + type int32;
74 + }
75 + container network {
76 + leaf ip-address {
77 + type int32;
78 + }
79 + }
80 + }
81 + }
82 + notification network-down {
83 + container networks {
84 + leaf id {
85 + type int32;
86 + }
87 + container network {
88 + leaf ip-address {
89 + type int32;
90 + }
91 + }
92 + }
93 + }
94 +
95 +}
1 + module ietf-network4 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2017-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + container network {
71 + leaf ip {
72 + type int32;
73 + }
74 + }
75 +
76 +}
1 + module ietf-network1 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network1";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + notification network-up {
71 + container networks {
72 + leaf id {
73 + type int32;
74 + }
75 + container network {
76 + leaf ip-address {
77 + type int32;
78 + }
79 + }
80 + }
81 + }
82 + notification network-down {
83 + container networks {
84 + leaf id {
85 + type int32;
86 + }
87 + container network {
88 + leaf ip-address {
89 + type int32;
90 + }
91 + }
92 + }
93 + }
94 +
95 +}
1 + module ietf-network2 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network2";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + notification network-up {
71 + container networks {
72 + leaf id {
73 + type int32;
74 + }
75 + container network {
76 + leaf ip-address {
77 + type int32;
78 + }
79 + }
80 + }
81 + }
82 + notification network-down {
83 + container networks {
84 + leaf id {
85 + type int32;
86 + }
87 + container network {
88 + leaf ip-address {
89 + type int32;
90 + }
91 + }
92 + }
93 + }
94 +
95 +}
1 + module ietf-network3 {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network3";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + container networks {
71 + leaf id {
72 + type int32;
73 + }
74 + container network {
75 + leaf ip-address {
76 + type int32;
77 + }
78 + }
79 + }
80 +
81 +}