Committed by
Gerrit Code Review
[ONOS-5084],[ONOS-5083] YANG schema registry for YMS
Change-Id: I88394307cb9be30237be0bb17e013d7af88a607c
Showing
29 changed files
with
3650 additions
and
25 deletions
| ... | @@ -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 | } | ... | ... |
apps/yms/app/BUCK
deleted
100644 → 0
| ... | @@ -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; |
apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationExtendedService.java
0 → 100644
| 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.event.ListenerService; | ||
| 20 | +import org.onosproject.yangutils.datamodel.RpcNotificationContainer; | ||
| 21 | +import org.onosproject.yangutils.datamodel.YangInclude; | ||
| 22 | +import org.onosproject.yangutils.datamodel.YangModule; | ||
| 23 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
| 24 | +import org.onosproject.yangutils.datamodel.YangSchemaNode; | ||
| 25 | +import org.onosproject.yangutils.datamodel.YangSubModule; | ||
| 26 | +import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | ||
| 27 | +import org.onosproject.yms.app.ynh.YangNotificationExtendedService; | ||
| 28 | +import org.onosproject.yms.ysr.YangModuleIdentifier; | ||
| 29 | +import org.onosproject.yms.ysr.YangModuleInformation; | ||
| 30 | +import org.onosproject.yms.ysr.YangModuleLibrary; | ||
| 31 | +import org.osgi.framework.BundleContext; | ||
| 32 | +import org.slf4j.Logger; | ||
| 33 | +import org.slf4j.LoggerFactory; | ||
| 34 | + | ||
| 35 | +import java.io.File; | ||
| 36 | +import java.io.FileInputStream; | ||
| 37 | +import java.io.IOException; | ||
| 38 | +import java.io.ObjectInputStream; | ||
| 39 | +import java.text.SimpleDateFormat; | ||
| 40 | +import java.util.ArrayList; | ||
| 41 | +import java.util.Collections; | ||
| 42 | +import java.util.HashSet; | ||
| 43 | +import java.util.Iterator; | ||
| 44 | +import java.util.List; | ||
| 45 | +import java.util.Set; | ||
| 46 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 47 | +import java.util.concurrent.ConcurrentMap; | ||
| 48 | +import java.util.regex.Pattern; | ||
| 49 | + | ||
| 50 | +import static org.apache.commons.io.FileUtils.deleteDirectory; | ||
| 51 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.parseJarFile; | ||
| 52 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; | ||
| 53 | +import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; | ||
| 54 | +import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; | ||
| 55 | +import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM; | ||
| 56 | +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
| 57 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | ||
| 58 | +import static org.osgi.framework.FrameworkUtil.getBundle; | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +/** | ||
| 62 | + * Representation of default YANG schema registry. Yang schema registry | ||
| 63 | + * provides interface to an application to register its YANG schema | ||
| 64 | + * with YMS. It provides YANG schema nodes to YDT, YNB and YSB. | ||
| 65 | + */ | ||
| 66 | +public class DefaultYangSchemaRegistry | ||
| 67 | + implements YangSchemaRegistry { | ||
| 68 | + | ||
| 69 | + private static final String SYSTEM = File.separator + "system" + | ||
| 70 | + File.separator; | ||
| 71 | + private static final String MAVEN = "mvn:"; | ||
| 72 | + private static final String HYPHEN = "-"; | ||
| 73 | + private static final String DELIMITER = "."; | ||
| 74 | + private static final String SERVICE = "Service"; | ||
| 75 | + private static final String JAR = ".jar"; | ||
| 76 | + private static final String USER_DIRECTORY = "user.dir"; | ||
| 77 | + private static final String SLASH = File.separator; | ||
| 78 | + private static final String AT = "@"; | ||
| 79 | + private static final String DATE_FORMAT = "yyyy-mm-dd"; | ||
| 80 | + private static final Logger log = | ||
| 81 | + LoggerFactory.getLogger(DefaultYangSchemaRegistry.class); | ||
| 82 | + | ||
| 83 | + /* | ||
| 84 | + * Map for storing app objects. | ||
| 85 | + */ | ||
| 86 | + private final ConcurrentMap<String, YsrAppContext> appObjectStore; | ||
| 87 | + | ||
| 88 | + /* | ||
| 89 | + * Map for storing YANG schema nodes. | ||
| 90 | + */ | ||
| 91 | + private final ConcurrentMap<String, YsrAppContext> yangSchemaStore; | ||
| 92 | + | ||
| 93 | + /* | ||
| 94 | + * Map for storing YANG schema nodes with respect to root's generated | ||
| 95 | + * interface file name. | ||
| 96 | + */ | ||
| 97 | + private final ConcurrentMap<String, YsrAppContext> | ||
| 98 | + yangSchemaStoreForRootInterface; | ||
| 99 | + | ||
| 100 | + /* | ||
| 101 | + * Map for storing YANG schema nodes root's generated op param file name. | ||
| 102 | + */ | ||
| 103 | + private final ConcurrentMap<String, YsrAppContext> | ||
| 104 | + yangSchemaStoreForRootOpParam; | ||
| 105 | + | ||
| 106 | + /* | ||
| 107 | + * Map for storing YANG schema nodes with respect to notifications. | ||
| 108 | + */ | ||
| 109 | + private final ConcurrentMap<String, YsrAppContext> | ||
| 110 | + yangRootSchemaStoreForNotification; | ||
| 111 | + | ||
| 112 | + /* | ||
| 113 | + * Map for storing registered classes. | ||
| 114 | + */ | ||
| 115 | + private final ConcurrentMap<String, Class<?>> registerClassStore; | ||
| 116 | + | ||
| 117 | + /* | ||
| 118 | + * Map for storing YANG file details. | ||
| 119 | + */ | ||
| 120 | + private final ConcurrentMap<YangModuleIdentifier, String> yangFileStore; | ||
| 121 | + | ||
| 122 | + /* | ||
| 123 | + * Context of application which is registering with YMS. | ||
| 124 | + */ | ||
| 125 | + private YsrAppContext ysrAppContext; | ||
| 126 | + | ||
| 127 | + /* | ||
| 128 | + * Context of application which is registering with YMS with multiple | ||
| 129 | + * revision. | ||
| 130 | + */ | ||
| 131 | + private YsrAppContext ysrContextForSchemaStore; | ||
| 132 | + | ||
| 133 | + /* | ||
| 134 | + * Context of application which is registering with YMS with multiple | ||
| 135 | + * manager object. | ||
| 136 | + */ | ||
| 137 | + private YsrAppContext ysrContextForAppStore; | ||
| 138 | + | ||
| 139 | + /* | ||
| 140 | + * Class loader of service application. | ||
| 141 | + */ | ||
| 142 | + private ClassLoader classLoader; | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * YANG module library. | ||
| 146 | + */ | ||
| 147 | + private final YangModuleLibrary library; | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * Creates an instance of default YANG schema registry. | ||
| 151 | + * | ||
| 152 | + * @param moduleId module set id of YSR module library | ||
| 153 | + */ | ||
| 154 | + public DefaultYangSchemaRegistry(String moduleId) { | ||
| 155 | + appObjectStore = new ConcurrentHashMap<>(); | ||
| 156 | + yangSchemaStore = new ConcurrentHashMap<>(); | ||
| 157 | + yangSchemaStoreForRootInterface = new ConcurrentHashMap<>(); | ||
| 158 | + yangSchemaStoreForRootOpParam = new ConcurrentHashMap<>(); | ||
| 159 | + yangRootSchemaStoreForNotification = new ConcurrentHashMap<>(); | ||
| 160 | + registerClassStore = new ConcurrentHashMap<>(); | ||
| 161 | + yangFileStore = new ConcurrentHashMap<>(); | ||
| 162 | + library = new DefaultYangModuleLibrary(moduleId); | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + | ||
| 166 | + @Override | ||
| 167 | + public void registerApplication(Object appObject, Class<?> serviceClass, | ||
| 168 | + YangNotificationExtendedService | ||
| 169 | + notificationExtendedService) { | ||
| 170 | + | ||
| 171 | + BundleContext bundleContext = getBundle(serviceClass) | ||
| 172 | + .getBundleContext(); | ||
| 173 | + String jarPath = getJarPathFromBundleLocation( | ||
| 174 | + bundleContext.getBundle().getLocation(), | ||
| 175 | + bundleContext.getProperty(USER_DIRECTORY)); | ||
| 176 | + // process application registration. | ||
| 177 | + processRegistration(serviceClass, appObject, jarPath); | ||
| 178 | + //process notification registration. | ||
| 179 | + processNotificationRegistration(serviceClass, appObject, | ||
| 180 | + notificationExtendedService); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * Process application registration. | ||
| 185 | + * | ||
| 186 | + * @param serviceClass service class | ||
| 187 | + * @param appObject application object | ||
| 188 | + * @param jarPath jar path | ||
| 189 | + */ | ||
| 190 | + void processRegistration(Class<?> serviceClass, Object appObject, | ||
| 191 | + String jarPath) { | ||
| 192 | + | ||
| 193 | + // set class loader for service class. | ||
| 194 | + setClassLoader(serviceClass.getClassLoader()); | ||
| 195 | + | ||
| 196 | + //Check if service should be registered? | ||
| 197 | + if (appObject != null) { | ||
| 198 | + verifyApplicationRegistration(appObject, serviceClass); | ||
| 199 | + } | ||
| 200 | + //Add app class to registered service store. | ||
| 201 | + if (!registerClassStore.containsKey(serviceClass.getName())) { | ||
| 202 | + updateServiceClass(serviceClass); | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + // process storing operations. | ||
| 206 | + if (!verifyIfApplicationAlreadyRegistered(serviceClass)) { | ||
| 207 | + List<YangNode> curNodes = | ||
| 208 | + processJarParsingOperations(jarPath); | ||
| 209 | + | ||
| 210 | + if (curNodes != null) { | ||
| 211 | + for (YangNode schemaNode : curNodes) { | ||
| 212 | + //Process application context for registrations. | ||
| 213 | + processApplicationContext(schemaNode); | ||
| 214 | + //Update YANG file store. | ||
| 215 | + updateYangFileStore(schemaNode, jarPath); | ||
| 216 | + //Process module library operation for current node list. | ||
| 217 | + processModuleLibrary(schemaNode); | ||
| 218 | + } | ||
| 219 | + //Set jar path for app context. | ||
| 220 | + ysrAppContext.jarPath(jarPath); | ||
| 221 | + ysrContextForSchemaStore.jarPath(jarPath); | ||
| 222 | + ysrContextForAppStore.jarPath(jarPath); | ||
| 223 | + } | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + //Verifies if object is updated for app store. | ||
| 227 | + updateApplicationObject(appObject, serviceClass); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + /** | ||
| 231 | + * Verifies if service class should be registered or not. | ||
| 232 | + * | ||
| 233 | + * @param appObject application object | ||
| 234 | + * @param appClass application class | ||
| 235 | + */ | ||
| 236 | + private void verifyApplicationRegistration(Object appObject, | ||
| 237 | + Class<?> appClass) { | ||
| 238 | + Class<?> managerClass = appObject.getClass(); | ||
| 239 | + Class<?>[] services = managerClass.getInterfaces(); | ||
| 240 | + List<Class<?>> classes = new ArrayList<>(); | ||
| 241 | + Collections.addAll(classes, services); | ||
| 242 | + if (!classes.contains(appClass)) { | ||
| 243 | + throw new RuntimeException("service class " + appClass.getName() + | ||
| 244 | + "is not being implemented by " + | ||
| 245 | + managerClass.getName()); | ||
| 246 | + } | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + /** | ||
| 250 | + * Verifies if application is already registered with YMS. | ||
| 251 | + * | ||
| 252 | + * @param appClass application class | ||
| 253 | + * @return true if application already registered | ||
| 254 | + */ | ||
| 255 | + private boolean verifyIfApplicationAlreadyRegistered(Class<?> appClass) { | ||
| 256 | + String simpleName = appClass.getSimpleName(); | ||
| 257 | + String appName = appClass.getName(); | ||
| 258 | + if (!appObjectStore.containsKey(appName)) { | ||
| 259 | + if (simpleName.contains(OP_PARAM)) { | ||
| 260 | + return yangSchemaStoreForRootOpParam | ||
| 261 | + .containsKey(appName); | ||
| 262 | + } else { | ||
| 263 | + return yangSchemaStoreForRootInterface | ||
| 264 | + .containsKey(appName); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + return true; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + /** | ||
| 271 | + * Verifies if service is being implemented by some new object. | ||
| 272 | + * | ||
| 273 | + * @param appObject application's object | ||
| 274 | + * @param appClass application's class | ||
| 275 | + */ | ||
| 276 | + private void updateApplicationObject(Object appObject, Class<?> appClass) { | ||
| 277 | + YsrAppContext appContext = | ||
| 278 | + appObjectStore.get(appClass.getName()); | ||
| 279 | + if (appContext != null) { | ||
| 280 | + YangSchemaNode schemaNode = appContext.curNode(); | ||
| 281 | + String name = getInterfaceClassName(schemaNode); | ||
| 282 | + if (appContext.appObject() == null) { | ||
| 283 | + //update in application store. | ||
| 284 | + appContext.appObject(appObject); | ||
| 285 | + //Update app object for schema store for root interface. | ||
| 286 | + appContext = yangSchemaStoreForRootInterface.get(name); | ||
| 287 | + if (appContext != null) { | ||
| 288 | + appContext.appObject(appObject); | ||
| 289 | + } | ||
| 290 | + // Update app object for schema store for root op param | ||
| 291 | + appContext = yangSchemaStoreForRootOpParam.get(name + OP_PARAM); | ||
| 292 | + if (appContext != null) { | ||
| 293 | + appContext.appObject(appObject); | ||
| 294 | + } | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + @Override | ||
| 300 | + public void unRegisterApplication(Object managerObject, | ||
| 301 | + Class<?> serviceClass) { | ||
| 302 | + YangSchemaNode curNode = null; | ||
| 303 | + String serviceName = serviceClass.getName(); | ||
| 304 | + | ||
| 305 | + //Check if service should be unregistered? | ||
| 306 | + if (managerObject != null) { | ||
| 307 | + verifyApplicationRegistration(managerObject, serviceClass); | ||
| 308 | + } | ||
| 309 | + //Remove registered class from store. | ||
| 310 | + registerClassStore.remove(serviceName); | ||
| 311 | + | ||
| 312 | + //check if service is in app store. | ||
| 313 | + if (appObjectStore.containsKey(serviceName)) { | ||
| 314 | + curNode = retrieveNodeForUnregister(serviceName, appObjectStore, | ||
| 315 | + managerObject); | ||
| 316 | + } else if (yangSchemaStoreForRootInterface.containsKey(serviceName)) { | ||
| 317 | + //check if service is in interface store. | ||
| 318 | + curNode = retrieveNodeForUnregister(serviceName, | ||
| 319 | + yangSchemaStoreForRootInterface, | ||
| 320 | + managerObject); | ||
| 321 | + } else if (yangSchemaStoreForRootOpParam.containsKey(serviceName)) { | ||
| 322 | + //check if service is in op param store. | ||
| 323 | + curNode = retrieveNodeForUnregister(serviceName, | ||
| 324 | + yangSchemaStoreForRootOpParam, | ||
| 325 | + managerObject); | ||
| 326 | + } | ||
| 327 | + if (curNode != null) { | ||
| 328 | + String javaName = getInterfaceClassName(curNode); | ||
| 329 | + removeFromYangSchemaStore(curNode); | ||
| 330 | + removeFromYangNotificationStore(curNode); | ||
| 331 | + removeFromAppSchemaStore(serviceName); | ||
| 332 | + removeFromYangSchemaNodeForRootInterface(javaName); | ||
| 333 | + removeFromYangSchemaNodeForRootOpParam(javaName); | ||
| 334 | + removeYangFileInfoFromStore(curNode); | ||
| 335 | + log.info(" service {} is unregistered.", | ||
| 336 | + serviceClass.getSimpleName()); | ||
| 337 | + } else { | ||
| 338 | + throw new RuntimeException(serviceClass.getSimpleName() + | ||
| 339 | + " service was not registered."); | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + @Override | ||
| 344 | + public Object getRegisteredApplication(YangSchemaNode schemaNode) { | ||
| 345 | + if (schemaNode != null) { | ||
| 346 | + String name = getInterfaceClassName(schemaNode); | ||
| 347 | + if (yangSchemaStoreForRootInterface.containsKey(name)) { | ||
| 348 | + return yangSchemaStoreForRootInterface.get(name) | ||
| 349 | + .appObject(); | ||
| 350 | + } | ||
| 351 | + log.error("{} not found.", name); | ||
| 352 | + } | ||
| 353 | + return null; | ||
| 354 | + } | ||
| 355 | + | ||
| 356 | + @Override | ||
| 357 | + public YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName) { | ||
| 358 | + return getSchemaNodeUsingSchemaNameWithRev(schemaName); | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + @Override | ||
| 362 | + public YangSchemaNode getYangSchemaNodeUsingAppName(String appName) { | ||
| 363 | + YsrAppContext appContext = appObjectStore.get(appName); | ||
| 364 | + if (appContext != null) { | ||
| 365 | + return appContext.curNode(); | ||
| 366 | + } | ||
| 367 | + log.error("{} not found.", appName); | ||
| 368 | + return null; | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + @Override | ||
| 372 | + public YangSchemaNode | ||
| 373 | + getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(String name) { | ||
| 374 | + YsrAppContext appContext = yangSchemaStoreForRootInterface.get(name); | ||
| 375 | + if (appContext != null) { | ||
| 376 | + return appContext.curNode(); | ||
| 377 | + } | ||
| 378 | + log.error("{} not found.", name); | ||
| 379 | + return null; | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + @Override | ||
| 383 | + public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 384 | + String name) { | ||
| 385 | + YsrAppContext appContext = yangSchemaStoreForRootOpParam.get(name); | ||
| 386 | + if (appContext != null) { | ||
| 387 | + return appContext.curNode(); | ||
| 388 | + } | ||
| 389 | + log.error("{} not found.", name); | ||
| 390 | + return null; | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + @Override | ||
| 394 | + public YangSchemaNode getRootYangSchemaNodeForNotification(String name) { | ||
| 395 | + YsrAppContext appContext = yangRootSchemaStoreForNotification.get(name); | ||
| 396 | + if (appContext != null) { | ||
| 397 | + return appContext.curNode(); | ||
| 398 | + } | ||
| 399 | + log.error("{} not found.", name); | ||
| 400 | + return null; | ||
| 401 | + } | ||
| 402 | + | ||
| 403 | + @Override | ||
| 404 | + public Class<?> getRegisteredClass(YangSchemaNode schemaNode, | ||
| 405 | + String appName) { | ||
| 406 | + String interfaceName = getInterfaceClassName(schemaNode); | ||
| 407 | + String serviceName = getServiceName(schemaNode); | ||
| 408 | + String defaultClass; | ||
| 409 | + if (schemaNode instanceof RpcNotificationContainer) { | ||
| 410 | + defaultClass = getOpParamClassName(schemaNode); | ||
| 411 | + } else { | ||
| 412 | + defaultClass = getDefaultClassName(schemaNode); | ||
| 413 | + } | ||
| 414 | + //If application class is registered. | ||
| 415 | + if (registerClassStore.containsKey(appName)) { | ||
| 416 | + return registerClassStore.get(appName); | ||
| 417 | + } else if (registerClassStore.containsKey(interfaceName)) { | ||
| 418 | + //If interface class is registered. | ||
| 419 | + return registerClassStore.get(interfaceName); | ||
| 420 | + } else if (registerClassStore.containsKey(serviceName)) { | ||
| 421 | + //If service class is registered. | ||
| 422 | + return registerClassStore.get(serviceName); | ||
| 423 | + } else if (registerClassStore.containsKey(defaultClass)) { | ||
| 424 | + //If default class is registered. | ||
| 425 | + return registerClassStore.get(defaultClass); | ||
| 426 | + } | ||
| 427 | + return null; | ||
| 428 | + } | ||
| 429 | + | ||
| 430 | + /** | ||
| 431 | + * Returns YANG file path for module identifier. | ||
| 432 | + * | ||
| 433 | + * @param moduleIdentifier module identifier | ||
| 434 | + * @return YANG file path for module identifier | ||
| 435 | + */ | ||
| 436 | + public String getYangFile(YangModuleIdentifier moduleIdentifier) { | ||
| 437 | + if (yangFileStore.containsKey(moduleIdentifier)) { | ||
| 438 | + return yangFileStore.get(moduleIdentifier); | ||
| 439 | + } | ||
| 440 | + log.error("YANG files for corresponding module identifier {} not " + | ||
| 441 | + "found", moduleIdentifier); | ||
| 442 | + return null; | ||
| 443 | + } | ||
| 444 | + | ||
| 445 | + /** | ||
| 446 | + * Updates service class store. | ||
| 447 | + * | ||
| 448 | + * @param serviceClass service class | ||
| 449 | + */ | ||
| 450 | + void updateServiceClass(Class<?> serviceClass) { | ||
| 451 | + registerClassStore.put(serviceClass.getName(), serviceClass); | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + /** | ||
| 455 | + * Updates application object store. | ||
| 456 | + * | ||
| 457 | + * @param appName application name | ||
| 458 | + */ | ||
| 459 | + private void updateAppObjectStore(String appName) { | ||
| 460 | + if (verifyClassExistence(appName)) { | ||
| 461 | + appObjectStore.put(appName, ysrContextForAppStore); | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + | ||
| 465 | + /** | ||
| 466 | + * Updates YANG schema object store. | ||
| 467 | + * | ||
| 468 | + * @param schemaNode application's schema node | ||
| 469 | + */ | ||
| 470 | + private void updateYangSchemaStore(YangSchemaNode schemaNode) { | ||
| 471 | + addSchemaNodeUsingSchemaNameWithRev(schemaNode); | ||
| 472 | + } | ||
| 473 | + | ||
| 474 | + /** | ||
| 475 | + * Updates YANG schema notification object store. | ||
| 476 | + * | ||
| 477 | + * @param name application's notification name | ||
| 478 | + */ | ||
| 479 | + private void updateYangNotificationStore(String name) { | ||
| 480 | + if (verifyClassExistence(name)) { | ||
| 481 | + yangRootSchemaStoreForNotification.put(name, ysrAppContext); | ||
| 482 | + } | ||
| 483 | + } | ||
| 484 | + | ||
| 485 | + /** | ||
| 486 | + * Updates YANG schema object store for root interface file name. | ||
| 487 | + * | ||
| 488 | + * @param name name of generated interface file for root | ||
| 489 | + * node | ||
| 490 | + */ | ||
| 491 | + private void updateYangSchemaForRootInterfaceFileNameStore(String name) { | ||
| 492 | + if (verifyClassExistence(name)) { | ||
| 493 | + yangSchemaStoreForRootInterface.put(name, ysrAppContext); | ||
| 494 | + } | ||
| 495 | + } | ||
| 496 | + | ||
| 497 | + /** | ||
| 498 | + * Updates YANG schema object store for root op param file name. | ||
| 499 | + * | ||
| 500 | + * @param name name of generated op param file for root node | ||
| 501 | + */ | ||
| 502 | + private void updateYangSchemaForRootOpParamFileNameStore(String name) { | ||
| 503 | + if (verifyClassExistence(name)) { | ||
| 504 | + yangSchemaStoreForRootOpParam.put(name, ysrAppContext); | ||
| 505 | + } | ||
| 506 | + } | ||
| 507 | + | ||
| 508 | + /** | ||
| 509 | + * Updates yang file store for YANG node. | ||
| 510 | + * | ||
| 511 | + * @param node YANG node | ||
| 512 | + * @param jarPath jar file path | ||
| 513 | + */ | ||
| 514 | + private void updateYangFileStore(YangNode node, String jarPath) { | ||
| 515 | + //FIXME: fix when yang tools support for file name. | ||
| 516 | + //yangFileStore.put(getModuleIdentifier(node), | ||
| 517 | + // getYangFilePath(jarPath, node.getFileName())); | ||
| 518 | + } | ||
| 519 | + | ||
| 520 | + /** | ||
| 521 | + * Returns yang file path. | ||
| 522 | + * | ||
| 523 | + * @param jarPath jar path | ||
| 524 | + * @param metaDataFileName name of yang file from metadata | ||
| 525 | + * @return yang file path | ||
| 526 | + */ | ||
| 527 | + private String getYangFilePath(String jarPath, String metaDataFileName) { | ||
| 528 | + String[] metaData = metaDataFileName.split(SLASH); | ||
| 529 | + return jarPath + SLASH + metaData[metaData.length - 1]; | ||
| 530 | + } | ||
| 531 | + | ||
| 532 | + /** | ||
| 533 | + * Process jar file for fetching YANG nodes. | ||
| 534 | + * | ||
| 535 | + * @param path jar file path | ||
| 536 | + * @return YANG schema nodes | ||
| 537 | + */ | ||
| 538 | + private List<YangNode> processJarParsingOperations(String path) { | ||
| 539 | + //Deserialize data model and get the YANG node set. | ||
| 540 | + try { | ||
| 541 | + return parseJarFile(path + JAR, path); | ||
| 542 | + } catch (IOException e) { | ||
| 543 | + log.error(" failed to parse the jar file in path {} : {} ", path, | ||
| 544 | + e.getMessage()); | ||
| 545 | + } | ||
| 546 | + return null; | ||
| 547 | + } | ||
| 548 | + | ||
| 549 | + /** | ||
| 550 | + * Process an application an updates the maps for YANG schema registry. | ||
| 551 | + * | ||
| 552 | + * @param appNode application YANG schema nodes | ||
| 553 | + */ | ||
| 554 | + void processApplicationContext(YangSchemaNode appNode) { | ||
| 555 | + | ||
| 556 | + String appName = getInterfaceClassName(appNode); | ||
| 557 | + | ||
| 558 | + //Create a new instance of ysr app context for each node. | ||
| 559 | + ysrAppContext = new YsrAppContext(); | ||
| 560 | + ysrContextForSchemaStore = new YsrAppContext(); | ||
| 561 | + ysrContextForAppStore = new YsrAppContext(); | ||
| 562 | + | ||
| 563 | + //add cur node to app context. | ||
| 564 | + ysrAppContext.curNode(appNode); | ||
| 565 | + ysrContextForAppStore.curNode(appNode); | ||
| 566 | + | ||
| 567 | + //Updates maps wih schema nodes. | ||
| 568 | + updateAppObjectStore(getServiceName(appNode)); | ||
| 569 | + | ||
| 570 | + // Updates schema store. | ||
| 571 | + updateYangSchemaStore(appNode); | ||
| 572 | + // update interface store. | ||
| 573 | + updateYangSchemaForRootInterfaceFileNameStore(appName); | ||
| 574 | + //update op param store. | ||
| 575 | + updateYangSchemaForRootOpParamFileNameStore(getOpParamClassName(appNode)); | ||
| 576 | + //Checks if notification is present then update notification store map. | ||
| 577 | + String eventSubject = null; | ||
| 578 | + try { | ||
| 579 | + if (appNode.isNotificationPresent()) { | ||
| 580 | + eventSubject = getEventClassName(appNode); | ||
| 581 | + } | ||
| 582 | + } catch (DataModelException e) { | ||
| 583 | + log.error("failed to search notification from schema map : {}", | ||
| 584 | + e.getLocalizedMessage()); | ||
| 585 | + } | ||
| 586 | + if (eventSubject != null) { | ||
| 587 | + updateYangNotificationStore(eventSubject); | ||
| 588 | + } | ||
| 589 | + log.info("successfully registered this application {}{}", appName, | ||
| 590 | + SERVICE); | ||
| 591 | + | ||
| 592 | + } | ||
| 593 | + | ||
| 594 | + /** | ||
| 595 | + * Returns jar path from bundle mvnLocationPath. | ||
| 596 | + * | ||
| 597 | + * @param mvnLocationPath mvnLocationPath of bundle | ||
| 598 | + * @return path of jar | ||
| 599 | + */ | ||
| 600 | + private String getJarPathFromBundleLocation(String mvnLocationPath, | ||
| 601 | + String currentDirectory) { | ||
| 602 | + String path = currentDirectory + SYSTEM; | ||
| 603 | + String[] strArray = mvnLocationPath.split(MAVEN); | ||
| 604 | + String[] split = strArray[1].split(File.separator); | ||
| 605 | + String[] groupId = split[0].split(Pattern.quote(DELIMITER)); | ||
| 606 | + | ||
| 607 | + return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] + | ||
| 608 | + SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2]; | ||
| 609 | + } | ||
| 610 | + | ||
| 611 | + /** | ||
| 612 | + * Returns de-serializes YANG data-model nodes. | ||
| 613 | + * | ||
| 614 | + * @param serializedFileInfo serialized File Info | ||
| 615 | + * @return de-serializes YANG data-model nodes | ||
| 616 | + */ | ||
| 617 | + Set<YangSchemaNode> deSerializeDataModel(String serializedFileInfo) { | ||
| 618 | + | ||
| 619 | + Set<YangSchemaNode> nodes = new HashSet<>(); | ||
| 620 | + Object readValue; | ||
| 621 | + try { | ||
| 622 | + FileInputStream fileInputStream = | ||
| 623 | + new FileInputStream(serializedFileInfo); | ||
| 624 | + ObjectInputStream objectInputStream = | ||
| 625 | + new ObjectInputStream(fileInputStream); | ||
| 626 | + readValue = objectInputStream.readObject(); | ||
| 627 | + if (readValue instanceof Set<?>) { | ||
| 628 | + for (Object obj : (Set<?>) readValue) { | ||
| 629 | + if (obj instanceof YangSchemaNode) { | ||
| 630 | + nodes.add((YangSchemaNode) obj); | ||
| 631 | + } else { | ||
| 632 | + throw new RuntimeException( | ||
| 633 | + "deserialize object is not an instance of " + | ||
| 634 | + "YANG schema node" + obj); | ||
| 635 | + } | ||
| 636 | + } | ||
| 637 | + } else { | ||
| 638 | + throw new RuntimeException( | ||
| 639 | + "deserialize object is not an instance of set of" + | ||
| 640 | + "YANG schema node" + readValue); | ||
| 641 | + } | ||
| 642 | + objectInputStream.close(); | ||
| 643 | + fileInputStream.close(); | ||
| 644 | + } catch (IOException | ClassNotFoundException e) { | ||
| 645 | + log.error(" {} not found.: {}", serializedFileInfo, | ||
| 646 | + e.getLocalizedMessage()); | ||
| 647 | + } | ||
| 648 | + | ||
| 649 | + return nodes; | ||
| 650 | + } | ||
| 651 | + | ||
| 652 | + /** | ||
| 653 | + * Returns ysr app context. | ||
| 654 | + * | ||
| 655 | + * @return ysr app context | ||
| 656 | + */ | ||
| 657 | + YsrAppContext ysrAppContext() { | ||
| 658 | + return ysrAppContext; | ||
| 659 | + } | ||
| 660 | + | ||
| 661 | + /** | ||
| 662 | + * Returns schema node based on the revision. | ||
| 663 | + * | ||
| 664 | + * @param name name of the schema node | ||
| 665 | + * @return schema node based on the revision | ||
| 666 | + */ | ||
| 667 | + private YangSchemaNode getSchemaNodeUsingSchemaNameWithRev(String name) { | ||
| 668 | + YsrAppContext appContext; | ||
| 669 | + YangSchemaNode schemaNode; | ||
| 670 | + if (name.contains(AT)) { | ||
| 671 | + String[] revArray = name.split(AT); | ||
| 672 | + appContext = yangSchemaStore.get(revArray[0]); | ||
| 673 | + schemaNode = appContext.getSchemaNodeForRevisionStore(name); | ||
| 674 | + if (schemaNode != null) { | ||
| 675 | + return schemaNode; | ||
| 676 | + } | ||
| 677 | + return appContext.curNode(); | ||
| 678 | + } | ||
| 679 | + if (yangSchemaStore.containsKey(name)) { | ||
| 680 | + appContext = yangSchemaStore.get(name); | ||
| 681 | + if (appContext != null) { | ||
| 682 | + Iterator<YangSchemaNode> iterator = appContext | ||
| 683 | + .getYangSchemaNodeForRevisionStore().values() | ||
| 684 | + .iterator(); | ||
| 685 | + if (iterator.hasNext()) { | ||
| 686 | + return appContext.getYangSchemaNodeForRevisionStore() | ||
| 687 | + .values().iterator().next(); | ||
| 688 | + } else { | ||
| 689 | + return null; | ||
| 690 | + } | ||
| 691 | + } | ||
| 692 | + } | ||
| 693 | + log.error("{} not found.", name); | ||
| 694 | + return null; | ||
| 695 | + } | ||
| 696 | + | ||
| 697 | + /** | ||
| 698 | + * Adds schema node when different revision of node has received. | ||
| 699 | + * | ||
| 700 | + * @param schemaNode schema node | ||
| 701 | + */ | ||
| 702 | + private void addSchemaNodeUsingSchemaNameWithRev( | ||
| 703 | + YangSchemaNode schemaNode) { | ||
| 704 | + | ||
| 705 | + String date = getDateInStringFormat(schemaNode); | ||
| 706 | + String name = schemaNode.getName(); | ||
| 707 | + if (!date.equals(EMPTY_STRING)) { | ||
| 708 | + name = name + AT + date; | ||
| 709 | + } | ||
| 710 | + //check if already present. | ||
| 711 | + if (!yangSchemaStore.containsKey(schemaNode.getName())) { | ||
| 712 | + ysrContextForSchemaStore.curNode(schemaNode); | ||
| 713 | + //if revision is not present no need to add in revision store. | ||
| 714 | + ysrContextForSchemaStore | ||
| 715 | + .addSchemaNodeWithRevisionStore(name, schemaNode); | ||
| 716 | + yangSchemaStore.put(schemaNode.getName(), | ||
| 717 | + ysrContextForSchemaStore); | ||
| 718 | + } else { | ||
| 719 | + YsrAppContext appContext = | ||
| 720 | + yangSchemaStore.get(schemaNode.getName()); | ||
| 721 | + appContext.addSchemaNodeWithRevisionStore(name, schemaNode); | ||
| 722 | + appContext.curNode(schemaNode); | ||
| 723 | + } | ||
| 724 | + } | ||
| 725 | + | ||
| 726 | + /** | ||
| 727 | + * Returns date in string format. | ||
| 728 | + * | ||
| 729 | + * @param schemaNode schema node | ||
| 730 | + * @return date in string format | ||
| 731 | + */ | ||
| 732 | + String getDateInStringFormat(YangSchemaNode schemaNode) { | ||
| 733 | + if (schemaNode != null) { | ||
| 734 | + if (((YangNode) schemaNode).getRevision() != null) { | ||
| 735 | + return new SimpleDateFormat(DATE_FORMAT) | ||
| 736 | + .format(((YangNode) schemaNode).getRevision() | ||
| 737 | + .getRevDate()); | ||
| 738 | + } | ||
| 739 | + } | ||
| 740 | + return EMPTY_STRING; | ||
| 741 | + } | ||
| 742 | + | ||
| 743 | + /** | ||
| 744 | + * Removes schema node from schema map. | ||
| 745 | + * | ||
| 746 | + * @param removableNode schema node which needs to be removed | ||
| 747 | + */ | ||
| 748 | + private void removeSchemaNode(YangSchemaNode removableNode) { | ||
| 749 | + | ||
| 750 | + String name = removableNode.getName(); | ||
| 751 | + String date = getDateInStringFormat(removableNode); | ||
| 752 | + | ||
| 753 | + if (!date.isEmpty()) { | ||
| 754 | + name = removableNode.getName() + AT + | ||
| 755 | + getDateInStringFormat(removableNode); | ||
| 756 | + } | ||
| 757 | + YsrAppContext appContext = yangSchemaStore | ||
| 758 | + .get(removableNode.getName()); | ||
| 759 | + if (appContext != null && | ||
| 760 | + !appContext.getYangSchemaNodeForRevisionStore().isEmpty() && | ||
| 761 | + appContext.getYangSchemaNodeForRevisionStore().size() != 1) { | ||
| 762 | + appContext.removeSchemaNodeForRevisionStore(name); | ||
| 763 | + } else { | ||
| 764 | + yangSchemaStore.remove(removableNode.getName()); | ||
| 765 | + } | ||
| 766 | + } | ||
| 767 | + | ||
| 768 | + /** | ||
| 769 | + * Verifies if the manager object is already registered with notification | ||
| 770 | + * handler. | ||
| 771 | + * | ||
| 772 | + * @param serviceClass service class | ||
| 773 | + * @return true if the manager object is already registered with | ||
| 774 | + * notification handler | ||
| 775 | + */ | ||
| 776 | + boolean verifyNotificationObject(Class<?> serviceClass) { | ||
| 777 | + YangSchemaNode schemaNode = null; | ||
| 778 | + String serviceName = serviceClass.getName(); | ||
| 779 | + if (appObjectStore.containsKey(serviceName)) { | ||
| 780 | + schemaNode = getYangSchemaNodeUsingAppName(serviceName); | ||
| 781 | + } else if (yangSchemaStoreForRootInterface.containsKey(serviceName)) { | ||
| 782 | + schemaNode = | ||
| 783 | + getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 784 | + serviceName); | ||
| 785 | + } else if (yangSchemaStoreForRootOpParam.containsKey(serviceName)) { | ||
| 786 | + schemaNode = getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 787 | + serviceName); | ||
| 788 | + } | ||
| 789 | + | ||
| 790 | + if (schemaNode != null) { | ||
| 791 | + String name = getEventClassName(schemaNode); | ||
| 792 | + | ||
| 793 | + YsrAppContext appContext = | ||
| 794 | + yangRootSchemaStoreForNotification.get(name); | ||
| 795 | + if (appContext != null && !appContext.isNotificationRegistered()) { | ||
| 796 | + appContext.setNotificationRegistered(true); | ||
| 797 | + return true; | ||
| 798 | + } | ||
| 799 | + } | ||
| 800 | + return false; | ||
| 801 | + } | ||
| 802 | + | ||
| 803 | + /** | ||
| 804 | + * Returns schema node's generated interface class name. | ||
| 805 | + * | ||
| 806 | + * @param schemaNode schema node | ||
| 807 | + * @return schema node's generated interface class name | ||
| 808 | + */ | ||
| 809 | + private String getInterfaceClassName(YangSchemaNode schemaNode) { | ||
| 810 | + return schemaNode.getJavaPackage() + PERIOD + | ||
| 811 | + getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()); | ||
| 812 | + } | ||
| 813 | + | ||
| 814 | + /** | ||
| 815 | + * Returns schema node's generated op param class name. | ||
| 816 | + * | ||
| 817 | + * @param schemaNode schema node | ||
| 818 | + * @return schema node's generated op param class name | ||
| 819 | + */ | ||
| 820 | + private String getOpParamClassName(YangSchemaNode schemaNode) { | ||
| 821 | + return getInterfaceClassName(schemaNode) + OP_PARAM; | ||
| 822 | + } | ||
| 823 | + | ||
| 824 | + /** | ||
| 825 | + * Returns schema node's generated op param class name. | ||
| 826 | + * | ||
| 827 | + * @param schemaNode schema node | ||
| 828 | + * @return schema node's generated op param class name | ||
| 829 | + */ | ||
| 830 | + private String getDefaultClassName(YangSchemaNode schemaNode) { | ||
| 831 | + return schemaNode.getJavaPackage() + PERIOD + getCapitalCase(DEFAULT) + | ||
| 832 | + getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()); | ||
| 833 | + } | ||
| 834 | + | ||
| 835 | + /** | ||
| 836 | + * Returns schema node's generated event class name. | ||
| 837 | + * | ||
| 838 | + * @param schemaNode schema node | ||
| 839 | + * @return schema node's generated event class name | ||
| 840 | + */ | ||
| 841 | + private String getEventClassName(YangSchemaNode schemaNode) { | ||
| 842 | + return getInterfaceClassName(schemaNode).toLowerCase() + PERIOD + | ||
| 843 | + getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()) + | ||
| 844 | + EVENT_STRING; | ||
| 845 | + } | ||
| 846 | + | ||
| 847 | + /** | ||
| 848 | + * Returns schema node's generated service class name. | ||
| 849 | + * | ||
| 850 | + * @param schemaNode schema node | ||
| 851 | + * @return schema node's generated service class name | ||
| 852 | + */ | ||
| 853 | + private String getServiceName(YangSchemaNode schemaNode) { | ||
| 854 | + return getInterfaceClassName(schemaNode) + SERVICE; | ||
| 855 | + } | ||
| 856 | + | ||
| 857 | + /** | ||
| 858 | + * Returns YSR application context for schema map. | ||
| 859 | + * | ||
| 860 | + * @return YSR application context for schema map | ||
| 861 | + */ | ||
| 862 | + YsrAppContext ysrContextForSchemaStore() { | ||
| 863 | + return ysrContextForSchemaStore; | ||
| 864 | + } | ||
| 865 | + | ||
| 866 | + /** | ||
| 867 | + * Sets YSR application context for schema map. | ||
| 868 | + * | ||
| 869 | + * @param context YSR application context for | ||
| 870 | + * schema map | ||
| 871 | + */ | ||
| 872 | + void ysrContextForSchemaStore(YsrAppContext context) { | ||
| 873 | + ysrContextForSchemaStore = context; | ||
| 874 | + } | ||
| 875 | + | ||
| 876 | + /** | ||
| 877 | + * Returns YSR app context for application store. | ||
| 878 | + * | ||
| 879 | + * @return YSR app context for application store | ||
| 880 | + */ | ||
| 881 | + YsrAppContext ysrContextForAppStore() { | ||
| 882 | + return ysrContextForAppStore; | ||
| 883 | + } | ||
| 884 | + | ||
| 885 | + /** | ||
| 886 | + * Retrieves schema node from the store and deletes jar file path. | ||
| 887 | + * | ||
| 888 | + * @param appName application name | ||
| 889 | + * @param store YSR stores | ||
| 890 | + * @param appObject applications object | ||
| 891 | + * @return schema node from the store | ||
| 892 | + */ | ||
| 893 | + private YangSchemaNode retrieveNodeForUnregister( | ||
| 894 | + String appName, | ||
| 895 | + ConcurrentMap<String, YsrAppContext> store, Object appObject) { | ||
| 896 | + | ||
| 897 | + YsrAppContext curContext = store.get(appName); | ||
| 898 | + boolean isValidObject; | ||
| 899 | + if (curContext != null) { | ||
| 900 | + isValidObject = verifyAppObject(appObject, curContext.appObject()); | ||
| 901 | + if (isValidObject) { | ||
| 902 | + YangSchemaNode curNode = curContext.curNode(); | ||
| 903 | + //Delete all the generated ysr information in application's | ||
| 904 | + // package. | ||
| 905 | + removeYsrGeneratedTemporaryResources(curContext.jarPath(), | ||
| 906 | + appName); | ||
| 907 | + return curNode; | ||
| 908 | + } | ||
| 909 | + } | ||
| 910 | + return null; | ||
| 911 | + } | ||
| 912 | + | ||
| 913 | + /** | ||
| 914 | + * Verifies the application object which needs to be unregistered. | ||
| 915 | + * | ||
| 916 | + * @param appObject current received application object | ||
| 917 | + * @param context stored application object | ||
| 918 | + * @return true if objects are equal | ||
| 919 | + */ | ||
| 920 | + private boolean verifyAppObject(Object appObject, Object context) { | ||
| 921 | + if (appObject != null && context != null) { | ||
| 922 | + return appObject.equals(context); | ||
| 923 | + } | ||
| 924 | + return appObject == null && context == null; | ||
| 925 | + } | ||
| 926 | + | ||
| 927 | + /** | ||
| 928 | + * Removes YSR generated temporary resources. | ||
| 929 | + * | ||
| 930 | + * @param rscPath resource path | ||
| 931 | + * @param appName application name | ||
| 932 | + */ | ||
| 933 | + private void removeYsrGeneratedTemporaryResources(String rscPath, | ||
| 934 | + String appName) { | ||
| 935 | + if (rscPath != null) { | ||
| 936 | + File jarPath = new File(rscPath); | ||
| 937 | + if (jarPath.exists()) { | ||
| 938 | + try { | ||
| 939 | + deleteDirectory(jarPath); | ||
| 940 | + } catch (IOException e) { | ||
| 941 | + log.error("failed to delete ysr resources for {} : {}", | ||
| 942 | + appName, e.getLocalizedMessage()); | ||
| 943 | + } | ||
| 944 | + } | ||
| 945 | + } | ||
| 946 | + } | ||
| 947 | + | ||
| 948 | + /** | ||
| 949 | + * Removes from YANG schema store. | ||
| 950 | + * | ||
| 951 | + * @param curNode schema node | ||
| 952 | + */ | ||
| 953 | + private void removeFromYangSchemaStore(YangSchemaNode curNode) { | ||
| 954 | + removeSchemaNode(curNode); | ||
| 955 | + } | ||
| 956 | + | ||
| 957 | + /** | ||
| 958 | + * Removes from YANG schema notification store. | ||
| 959 | + * | ||
| 960 | + * @param curNode schema node | ||
| 961 | + */ | ||
| 962 | + private void removeFromYangNotificationStore(YangSchemaNode curNode) { | ||
| 963 | + yangRootSchemaStoreForNotification | ||
| 964 | + .remove(getEventClassName(curNode)); | ||
| 965 | + } | ||
| 966 | + | ||
| 967 | + /** | ||
| 968 | + * Removes from app store. | ||
| 969 | + * | ||
| 970 | + * @param appName application name | ||
| 971 | + */ | ||
| 972 | + private void removeFromAppSchemaStore(String appName) { | ||
| 973 | + appObjectStore.remove(appName); | ||
| 974 | + } | ||
| 975 | + | ||
| 976 | + /** | ||
| 977 | + * Removes from interface store. | ||
| 978 | + * | ||
| 979 | + * @param appName application name | ||
| 980 | + */ | ||
| 981 | + private void removeFromYangSchemaNodeForRootInterface(String appName) { | ||
| 982 | + yangSchemaStoreForRootInterface.remove(appName); | ||
| 983 | + } | ||
| 984 | + | ||
| 985 | + /** | ||
| 986 | + * Removes from op param store. | ||
| 987 | + * | ||
| 988 | + * @param appName application name | ||
| 989 | + */ | ||
| 990 | + private void removeFromYangSchemaNodeForRootOpParam(String appName) { | ||
| 991 | + yangSchemaStoreForRootOpParam.remove(appName + OP_PARAM); | ||
| 992 | + } | ||
| 993 | + | ||
| 994 | + /** | ||
| 995 | + * Removes YANG file information from file store. | ||
| 996 | + * | ||
| 997 | + * @param schemaNode schema node | ||
| 998 | + */ | ||
| 999 | + private void removeYangFileInfoFromStore(YangSchemaNode schemaNode) { | ||
| 1000 | + yangFileStore.remove(getModuleIdentifier(schemaNode)); | ||
| 1001 | + } | ||
| 1002 | + | ||
| 1003 | + /** | ||
| 1004 | + * Verifies if class with given name exists. | ||
| 1005 | + * | ||
| 1006 | + * @param appName application name | ||
| 1007 | + * @return true if class exists | ||
| 1008 | + */ | ||
| 1009 | + boolean verifyClassExistence(String appName) { | ||
| 1010 | + try { | ||
| 1011 | + classLoader.loadClass(appName); | ||
| 1012 | + return true; | ||
| 1013 | + } catch (ClassNotFoundException e) { | ||
| 1014 | + return false; | ||
| 1015 | + } | ||
| 1016 | + } | ||
| 1017 | + | ||
| 1018 | + /** | ||
| 1019 | + * Process notification registration for manager class object. | ||
| 1020 | + * | ||
| 1021 | + * @param yangService yang service | ||
| 1022 | + * @param yangManager yang manager | ||
| 1023 | + * @param ynhService notification extended service | ||
| 1024 | + */ | ||
| 1025 | + private void processNotificationRegistration( | ||
| 1026 | + Class<?> yangService, Object yangManager, | ||
| 1027 | + YangNotificationExtendedService ynhService) { | ||
| 1028 | + | ||
| 1029 | + if (yangManager != null && yangManager instanceof ListenerService) { | ||
| 1030 | + if (verifyNotificationObject(yangService)) { | ||
| 1031 | + ynhService.registerAsListener( | ||
| 1032 | + (ListenerService) yangManager); | ||
| 1033 | + } | ||
| 1034 | + } | ||
| 1035 | + } | ||
| 1036 | + | ||
| 1037 | + /** | ||
| 1038 | + * Clears database for YSR. | ||
| 1039 | + */ | ||
| 1040 | + public void flushYsrData() { | ||
| 1041 | + appObjectStore.clear(); | ||
| 1042 | + yangSchemaStore.clear(); | ||
| 1043 | + yangRootSchemaStoreForNotification.clear(); | ||
| 1044 | + yangSchemaStoreForRootOpParam.clear(); | ||
| 1045 | + yangSchemaStoreForRootInterface.clear(); | ||
| 1046 | + registerClassStore.clear(); | ||
| 1047 | + yangFileStore.clear(); | ||
| 1048 | + } | ||
| 1049 | + | ||
| 1050 | + /** | ||
| 1051 | + * Sets class loader of registered class. | ||
| 1052 | + * | ||
| 1053 | + * @param classLoader class loader of registered class | ||
| 1054 | + */ | ||
| 1055 | + void setClassLoader(ClassLoader classLoader) { | ||
| 1056 | + this.classLoader = classLoader; | ||
| 1057 | + } | ||
| 1058 | + | ||
| 1059 | + /** | ||
| 1060 | + * Process module library for a registered service. | ||
| 1061 | + * | ||
| 1062 | + * @param node YANG schema nodes | ||
| 1063 | + */ | ||
| 1064 | + private void processModuleLibrary(YangNode node) { | ||
| 1065 | + YangModuleInformation moduleInformation = | ||
| 1066 | + new DefaultYangModuleInformation(getModuleIdentifier(node), | ||
| 1067 | + node.getNameSpace()); | ||
| 1068 | + addSubModuleIdentifier(node, ( | ||
| 1069 | + DefaultYangModuleInformation) moduleInformation); | ||
| 1070 | + //TODO: add feature list to module information. | ||
| 1071 | + ((DefaultYangModuleLibrary) library) | ||
| 1072 | + .addModuleInformation(moduleInformation); | ||
| 1073 | + } | ||
| 1074 | + | ||
| 1075 | + /** | ||
| 1076 | + * Adds sub module identifier. | ||
| 1077 | + * | ||
| 1078 | + * @param node schema node | ||
| 1079 | + * @param information module information | ||
| 1080 | + */ | ||
| 1081 | + private void addSubModuleIdentifier( | ||
| 1082 | + YangSchemaNode node, DefaultYangModuleInformation information) { | ||
| 1083 | + List<YangInclude> includeList = new ArrayList<>(); | ||
| 1084 | + if (node instanceof YangModule) { | ||
| 1085 | + includeList = ((YangModule) node).getIncludeList(); | ||
| 1086 | + } else if (node instanceof YangSubModule) { | ||
| 1087 | + includeList = ((YangSubModule) node).getIncludeList(); | ||
| 1088 | + } | ||
| 1089 | + for (YangInclude include : includeList) { | ||
| 1090 | + information.addSubModuleIdentifiers(getModuleIdentifier( | ||
| 1091 | + include.getIncludedNode())); | ||
| 1092 | + } | ||
| 1093 | + } | ||
| 1094 | + | ||
| 1095 | + /** | ||
| 1096 | + * Returns module identifier for schema node. | ||
| 1097 | + * | ||
| 1098 | + * @param schemaNode schema node | ||
| 1099 | + * @return module identifier for schema node | ||
| 1100 | + */ | ||
| 1101 | + private YangModuleIdentifier getModuleIdentifier( | ||
| 1102 | + YangSchemaNode schemaNode) { | ||
| 1103 | + return new DefaultYangModuleIdentifier( | ||
| 1104 | + schemaNode.getName(), getDateInStringFormat(schemaNode)); | ||
| 1105 | + } | ||
| 1106 | + | ||
| 1107 | + /** | ||
| 1108 | + * Returns module library. | ||
| 1109 | + * | ||
| 1110 | + * @return module library | ||
| 1111 | + */ | ||
| 1112 | + public YangModuleLibrary getLibrary() { | ||
| 1113 | + return library; | ||
| 1114 | + } | ||
| 1115 | + | ||
| 1116 | +} |
| 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; |
apps/yms/app/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java
0 → 100644
| 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.junit.Rule; | ||
| 20 | +import org.junit.Test; | ||
| 21 | +import org.junit.rules.ExpectedException; | ||
| 22 | +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1; | ||
| 23 | +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1OpParam; | ||
| 24 | +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service; | ||
| 25 | +import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service; | ||
| 26 | +import org.onosproject.yangutils.datamodel.YangNode; | ||
| 27 | +import org.onosproject.yangutils.datamodel.YangSchemaNode; | ||
| 28 | + | ||
| 29 | +import java.io.IOException; | ||
| 30 | + | ||
| 31 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
| 32 | +import static org.hamcrest.core.Is.is; | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * Unit test case for default schema registry. | ||
| 36 | + */ | ||
| 37 | +public class DefaultYangSchemaRegistryTest { | ||
| 38 | + | ||
| 39 | + private static final String SERVICE_NAME_1 = | ||
| 40 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 41 | + ".network1.rev20151208.IetfNetwork1Service"; | ||
| 42 | + private static final String SCHEMA_NAME_1 = "ietf-network1"; | ||
| 43 | + private static final String EVENT_NAME_1 = | ||
| 44 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 45 | + ".network1.rev20151208.ietfnetwork1.IetfNetwork1Event"; | ||
| 46 | + private static final String INTERFACE_NAME_1 = | ||
| 47 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 48 | + ".network1.rev20151208.IetfNetwork1"; | ||
| 49 | + private static final String OP_PARAM_NAME_1 = | ||
| 50 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 51 | + ".network1.rev20151208.IetfNetwork1OpParam"; | ||
| 52 | + | ||
| 53 | + private static final String SERVICE_NAME_2 = | ||
| 54 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 55 | + ".network2.rev20151208.IetfNetwork2Service"; | ||
| 56 | + private static final String SCHEMA_NAME_2 = "ietf-network2"; | ||
| 57 | + private static final String EVENT_NAME_2 = | ||
| 58 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 59 | + ".network2.rev20151208.ietfnetwork2.IetfNetwork2Event"; | ||
| 60 | + private static final String INTERFACE_NAME_2 = | ||
| 61 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 62 | + ".network2.rev20151208.IetfNetwork2"; | ||
| 63 | + private static final String OP_PARAM_NAME_2 = | ||
| 64 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 65 | + ".network2.rev20151208.IetfNetwork2OpParam"; | ||
| 66 | + | ||
| 67 | + private static final String SERVICE_NAME_3 = | ||
| 68 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 69 | + ".network3.rev20151208.IetfNetwork3Service"; | ||
| 70 | + private static final String SCHEMA_NAME_3 = "ietf-network3"; | ||
| 71 | + private static final String EVENT_NAME_3 = | ||
| 72 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 73 | + ".network3.rev20151208.ietfnetwork3.IetfNetwork3Event"; | ||
| 74 | + private static final String INTERFACE_NAME_3 = | ||
| 75 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 76 | + ".network3.rev20151208.IetfNetwork3"; | ||
| 77 | + private static final String OP_PARAM_NAME_3 = | ||
| 78 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 79 | + ".network3.rev20151208.IetfNetwork3OpParam"; | ||
| 80 | + | ||
| 81 | + private static final String SCHEMA_NAME_4 = "ietf-network4"; | ||
| 82 | + private static final String SERVICE_NAME_REV_14 = | ||
| 83 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 84 | + ".network4.rev20141208.IetfNetwork4Service"; | ||
| 85 | + private static final String EVENT_NAME_REV_14 = | ||
| 86 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 87 | + ".network4.rev20141208.ietfnetwork4.IetfNetwork4Event"; | ||
| 88 | + private static final String INTERFACE_NAME_REV_14 = | ||
| 89 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 90 | + ".network4.rev20141208.IetfNetwork4"; | ||
| 91 | + private static final String OP_PARAM_NAME_REV_14 = | ||
| 92 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 93 | + ".network4.rev20141208.IetfNetwork4OpParam"; | ||
| 94 | + | ||
| 95 | + private static final String SERVICE_NAME_REV_15 = | ||
| 96 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 97 | + ".network4.rev20151208.IetfNetwork4Service"; | ||
| 98 | + private static final String EVENT_NAME_REV_15 = | ||
| 99 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 100 | + ".network4.rev20151208.ietfnetwork4.IetfNetwork4Event"; | ||
| 101 | + private static final String INTERFACE_NAME_REV_15 = | ||
| 102 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 103 | + ".network4.rev20151208.IetfNetwork4"; | ||
| 104 | + private static final String OP_PARAM_NAME_REV_15 = | ||
| 105 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 106 | + ".network4.rev20151208.IetfNetwork4OpParam"; | ||
| 107 | + | ||
| 108 | + private static final String SERVICE_NAME_REV_16 = | ||
| 109 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 110 | + ".network4.rev20161208.IetfNetwork4Service"; | ||
| 111 | + | ||
| 112 | + private static final String EVENT_NAME_REV_16 = | ||
| 113 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 114 | + ".network4.rev20161208.ietfnetwork4.IetfNetwork4Event"; | ||
| 115 | + private static final String INTERFACE_NAME_REV_16 = | ||
| 116 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 117 | + ".network4.rev20161208.IetfNetwork4"; | ||
| 118 | + private static final String OP_PARAM_NAME_REV_16 = | ||
| 119 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 120 | + ".network4.rev20161208.IetfNetwork4OpParam"; | ||
| 121 | + | ||
| 122 | + private static final String SERVICE_NAME_REV_17 = | ||
| 123 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 124 | + ".network4.rev20171208.IetfNetwork4Service"; | ||
| 125 | + private static final String EVENT_NAME_REV_17 = | ||
| 126 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 127 | + ".network4.rev20171208.ietfnetwork4.IetfNetwork4Event"; | ||
| 128 | + private static final String INTERFACE_NAME_REV_17 = | ||
| 129 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 130 | + ".network4.rev20171208.IetfNetwork4"; | ||
| 131 | + private static final String OP_PARAM_NAME_REV_17 = | ||
| 132 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 133 | + ".network4.rev20171208.IetfNetwork4OpParam"; | ||
| 134 | + | ||
| 135 | + private static final String SERVICE_NAME_NO_REV = | ||
| 136 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 137 | + ".network4.IetfNetwork4Service"; | ||
| 138 | + private static final String EVENT_NAME_NO_REV = | ||
| 139 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 140 | + ".network4.ietfnetwork4.IetfNetwork4Event"; | ||
| 141 | + private static final String INTERFACE_NAME_NO_REV = | ||
| 142 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 143 | + ".network4.IetfNetwork4"; | ||
| 144 | + private static final String OP_PARAM_NAME_NO_REV = | ||
| 145 | + "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" + | ||
| 146 | + ".network4.IetfNetwork4OpParam"; | ||
| 147 | + | ||
| 148 | + private static final String DATE = "2014-00-08"; | ||
| 149 | + private static final String SCHEMA_NAME_WITH_DATE = | ||
| 150 | + "ietf-network4@2014-00-08"; | ||
| 151 | + | ||
| 152 | + private static final String UN_REG_SCHEMA_NAME = "ietf-routing"; | ||
| 153 | + private static final String UN_REG_INTERFACE_NAME = "IetfRouting"; | ||
| 154 | + private static final String UN_REG_OP_PARAM_NAME = "IetfRoutingOpParam"; | ||
| 155 | + private static final String UN_REG_SERVICE_NAME = "IetfRoutingService"; | ||
| 156 | + private static final String UN_REG_EVENT_NAME = "IetfRoutingEvent"; | ||
| 157 | + | ||
| 158 | + private final TestYangSchemaNodeProvider testYangSchemaNodeProvider = | ||
| 159 | + new TestYangSchemaNodeProvider(); | ||
| 160 | + @Rule | ||
| 161 | + public ExpectedException thrown = ExpectedException.none(); | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * Unit test case in which schema node should be present. | ||
| 165 | + * | ||
| 166 | + * @throws IOException when fails to do IO operation | ||
| 167 | + */ | ||
| 168 | + @Test | ||
| 169 | + public void testForGetSchemaNode() | ||
| 170 | + throws IOException { | ||
| 171 | + | ||
| 172 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 173 | + | ||
| 174 | + DefaultYangSchemaRegistry registry = | ||
| 175 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry(); | ||
| 176 | + | ||
| 177 | + YangSchemaNode yangNode = | ||
| 178 | + registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1); | ||
| 179 | + assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName()))); | ||
| 180 | + | ||
| 181 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1); | ||
| 182 | + assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName()))); | ||
| 183 | + | ||
| 184 | + yangNode = | ||
| 185 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 186 | + INTERFACE_NAME_1); | ||
| 187 | + assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName()))); | ||
| 188 | + | ||
| 189 | + yangNode = | ||
| 190 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 191 | + OP_PARAM_NAME_1); | ||
| 192 | + assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName()))); | ||
| 193 | + | ||
| 194 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1); | ||
| 195 | + assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName()))); | ||
| 196 | + | ||
| 197 | + //As we have not registered an application this object should be null. | ||
| 198 | + Object object = registry.getRegisteredApplication(yangNode); | ||
| 199 | + assertThat(true, is(object == null)); | ||
| 200 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_1); | ||
| 201 | + | ||
| 202 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1); | ||
| 203 | + assertThat(true, is(yangNode == null)); | ||
| 204 | + | ||
| 205 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1); | ||
| 206 | + assertThat(true, is(yangNode == null)); | ||
| 207 | + | ||
| 208 | + yangNode = | ||
| 209 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 210 | + INTERFACE_NAME_1); | ||
| 211 | + assertThat(true, is(yangNode == null)); | ||
| 212 | + | ||
| 213 | + yangNode = | ||
| 214 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 215 | + OP_PARAM_NAME_1); | ||
| 216 | + assertThat(true, is(yangNode == null)); | ||
| 217 | + | ||
| 218 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1); | ||
| 219 | + assertThat(true, is(yangNode == null)); | ||
| 220 | + | ||
| 221 | + //As we have not registered an application this object should be null. | ||
| 222 | + object = registry.getRegisteredApplication(yangNode); | ||
| 223 | + assertThat(true, is(object == null)); | ||
| 224 | + | ||
| 225 | + //With second service. | ||
| 226 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2); | ||
| 227 | + assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName()))); | ||
| 228 | + | ||
| 229 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2); | ||
| 230 | + assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName()))); | ||
| 231 | + | ||
| 232 | + yangNode = | ||
| 233 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 234 | + INTERFACE_NAME_2); | ||
| 235 | + assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName()))); | ||
| 236 | + | ||
| 237 | + yangNode = | ||
| 238 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 239 | + OP_PARAM_NAME_2); | ||
| 240 | + assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName()))); | ||
| 241 | + | ||
| 242 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2); | ||
| 243 | + assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName()))); | ||
| 244 | + | ||
| 245 | + //As we have not registered an application this object should be null. | ||
| 246 | + object = registry.getRegisteredApplication(yangNode); | ||
| 247 | + assertThat(true, is(object == null)); | ||
| 248 | + | ||
| 249 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_2); | ||
| 250 | + | ||
| 251 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2); | ||
| 252 | + assertThat(true, is(yangNode == null)); | ||
| 253 | + | ||
| 254 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2); | ||
| 255 | + assertThat(true, is(yangNode == null)); | ||
| 256 | + | ||
| 257 | + yangNode = | ||
| 258 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 259 | + INTERFACE_NAME_2); | ||
| 260 | + assertThat(true, is(yangNode == null)); | ||
| 261 | + | ||
| 262 | + yangNode = | ||
| 263 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 264 | + OP_PARAM_NAME_2); | ||
| 265 | + assertThat(true, is(yangNode == null)); | ||
| 266 | + | ||
| 267 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2); | ||
| 268 | + assertThat(true, is(yangNode == null)); | ||
| 269 | + | ||
| 270 | + //As we have not registered an application this object should be null. | ||
| 271 | + object = registry.getRegisteredApplication(yangNode); | ||
| 272 | + assertThat(true, is(object == null)); | ||
| 273 | + | ||
| 274 | + //With third service. | ||
| 275 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3); | ||
| 276 | + assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName()))); | ||
| 277 | + | ||
| 278 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3); | ||
| 279 | + assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName()))); | ||
| 280 | + | ||
| 281 | + yangNode = | ||
| 282 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 283 | + INTERFACE_NAME_3); | ||
| 284 | + assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName()))); | ||
| 285 | + | ||
| 286 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3); | ||
| 287 | + assertThat(true, is(yangNode == null)); | ||
| 288 | + | ||
| 289 | + yangNode = | ||
| 290 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 291 | + OP_PARAM_NAME_3); | ||
| 292 | + assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName()))); | ||
| 293 | + | ||
| 294 | + //As we have not registered an application this object should be null. | ||
| 295 | + object = registry.getRegisteredApplication(yangNode); | ||
| 296 | + assertThat(true, is(object == null)); | ||
| 297 | + | ||
| 298 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_3); | ||
| 299 | + | ||
| 300 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3); | ||
| 301 | + assertThat(true, is(yangNode == null)); | ||
| 302 | + | ||
| 303 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3); | ||
| 304 | + assertThat(true, is(yangNode == null)); | ||
| 305 | + | ||
| 306 | + yangNode = | ||
| 307 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 308 | + INTERFACE_NAME_3); | ||
| 309 | + assertThat(true, is(yangNode == null)); | ||
| 310 | + | ||
| 311 | + yangNode = | ||
| 312 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 313 | + OP_PARAM_NAME_3); | ||
| 314 | + assertThat(true, is(yangNode == null)); | ||
| 315 | + | ||
| 316 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3); | ||
| 317 | + assertThat(true, is(yangNode == null)); | ||
| 318 | + | ||
| 319 | + //As we have not registered an application this object should be null. | ||
| 320 | + object = registry.getRegisteredApplication(yangNode); | ||
| 321 | + assertThat(true, is(object == null)); | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + /** | ||
| 325 | + * Unit test case in which schema node should not be present. | ||
| 326 | + * | ||
| 327 | + * @throws IOException when fails to do IO operation | ||
| 328 | + */ | ||
| 329 | + @Test | ||
| 330 | + public void testForDoNotGetSchemaNode() | ||
| 331 | + throws IOException { | ||
| 332 | + | ||
| 333 | + DefaultYangSchemaRegistry registry = | ||
| 334 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry(); | ||
| 335 | + | ||
| 336 | + // here all nodes should be null as we have not done any registration | ||
| 337 | + // for this application. | ||
| 338 | + YangSchemaNode yangNode = | ||
| 339 | + registry.getYangSchemaNodeUsingAppName(UN_REG_SERVICE_NAME); | ||
| 340 | + assertThat(true, is(yangNode == null)); | ||
| 341 | + | ||
| 342 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(UN_REG_SCHEMA_NAME); | ||
| 343 | + assertThat(true, is(yangNode == null)); | ||
| 344 | + | ||
| 345 | + yangNode = | ||
| 346 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 347 | + UN_REG_INTERFACE_NAME); | ||
| 348 | + assertThat(true, is(yangNode == null)); | ||
| 349 | + | ||
| 350 | + yangNode = | ||
| 351 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 352 | + UN_REG_OP_PARAM_NAME); | ||
| 353 | + assertThat(true, is(yangNode == null)); | ||
| 354 | + | ||
| 355 | + yangNode = registry.getRootYangSchemaNodeForNotification( | ||
| 356 | + UN_REG_EVENT_NAME); | ||
| 357 | + assertThat(true, is(yangNode == null)); | ||
| 358 | + | ||
| 359 | + //As we have not registered an application this object should be null. | ||
| 360 | + Object object = registry.getRegisteredApplication(yangNode); | ||
| 361 | + assertThat(true, is(object == null)); | ||
| 362 | + | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + /** | ||
| 366 | + * Unit test case in which schema node should be present with multi | ||
| 367 | + * revisions. | ||
| 368 | + * | ||
| 369 | + * @throws IOException when fails to do IO operation | ||
| 370 | + */ | ||
| 371 | + @Test | ||
| 372 | + public void testForGetSchemaNodeWhenNoRevision() | ||
| 373 | + throws IOException { | ||
| 374 | + | ||
| 375 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 376 | + DefaultYangSchemaRegistry registry = | ||
| 377 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry(); | ||
| 378 | + | ||
| 379 | + //Service with rev. | ||
| 380 | + YangSchemaNode yangNode = | ||
| 381 | + registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15); | ||
| 382 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 383 | + | ||
| 384 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 385 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 386 | + | ||
| 387 | + yangNode = | ||
| 388 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 389 | + INTERFACE_NAME_REV_15); | ||
| 390 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 391 | + | ||
| 392 | + yangNode = | ||
| 393 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 394 | + OP_PARAM_NAME_REV_15); | ||
| 395 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 396 | + | ||
| 397 | + yangNode = registry.getRootYangSchemaNodeForNotification( | ||
| 398 | + EVENT_NAME_REV_15); | ||
| 399 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 400 | + | ||
| 401 | + //As we have not registered an application this object should be null. | ||
| 402 | + Object object = registry.getRegisteredApplication(yangNode); | ||
| 403 | + assertThat(true, is(object == null)); | ||
| 404 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15); | ||
| 405 | + | ||
| 406 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15); | ||
| 407 | + assertThat(true, is(yangNode == null)); | ||
| 408 | + | ||
| 409 | + //Here the yangNode should be the node which does not have revision. | ||
| 410 | + // asset should pass with false. | ||
| 411 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 412 | + assertThat(true, is(((YangNode) yangNode).getRevision() != null)); | ||
| 413 | + | ||
| 414 | + //Service no revision. | ||
| 415 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV); | ||
| 416 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 417 | + | ||
| 418 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 419 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 420 | + | ||
| 421 | + yangNode = | ||
| 422 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 423 | + INTERFACE_NAME_NO_REV); | ||
| 424 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 425 | + | ||
| 426 | + yangNode = | ||
| 427 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 428 | + OP_PARAM_NAME_NO_REV); | ||
| 429 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 430 | + | ||
| 431 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_NO_REV); | ||
| 432 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 433 | + | ||
| 434 | + //As we have not registered an application this object should be null. | ||
| 435 | + object = registry.getRegisteredApplication(yangNode); | ||
| 436 | + assertThat(true, is(object == null)); | ||
| 437 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_NO_REV); | ||
| 438 | + | ||
| 439 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV); | ||
| 440 | + assertThat(true, is(yangNode == null)); | ||
| 441 | + | ||
| 442 | + //Here the yangNode should be the node which have different revision. | ||
| 443 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 444 | + assertThat(true, is(((YangNode) yangNode).getRevision() != null)); | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + /** | ||
| 448 | + * Unit test case in which schema node should be present with multi | ||
| 449 | + * revisions. | ||
| 450 | + * | ||
| 451 | + * @throws IOException when fails to do IO operation | ||
| 452 | + */ | ||
| 453 | + @Test | ||
| 454 | + public void testForGetSchemaNodeWhenMultiRevision() | ||
| 455 | + throws IOException { | ||
| 456 | + | ||
| 457 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 458 | + DefaultYangSchemaRegistry registry = | ||
| 459 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry(); | ||
| 460 | + | ||
| 461 | + //Service with rev. | ||
| 462 | + YangSchemaNode yangNode = | ||
| 463 | + registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15); | ||
| 464 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 465 | + | ||
| 466 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 467 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 468 | + | ||
| 469 | + yangNode = | ||
| 470 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 471 | + INTERFACE_NAME_REV_15); | ||
| 472 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 473 | + | ||
| 474 | + yangNode = | ||
| 475 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 476 | + OP_PARAM_NAME_REV_15); | ||
| 477 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 478 | + | ||
| 479 | + yangNode = registry.getRootYangSchemaNodeForNotification( | ||
| 480 | + EVENT_NAME_REV_15); | ||
| 481 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 482 | + | ||
| 483 | + //As we have not registered an application this object should be null. | ||
| 484 | + Object object = registry.getRegisteredApplication(yangNode); | ||
| 485 | + assertThat(true, is(object == null)); | ||
| 486 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15); | ||
| 487 | + | ||
| 488 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15); | ||
| 489 | + assertThat(true, is(yangNode == null)); | ||
| 490 | + | ||
| 491 | + //Here the yangNode should be the node which does not have revision. | ||
| 492 | + // asset should pass with false. | ||
| 493 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 494 | + assertThat(true, is(((YangNode) yangNode).getRevision() != null)); | ||
| 495 | + | ||
| 496 | + //Service with different revision. | ||
| 497 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16); | ||
| 498 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 499 | + | ||
| 500 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 501 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 502 | + | ||
| 503 | + yangNode = | ||
| 504 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 505 | + INTERFACE_NAME_REV_16); | ||
| 506 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 507 | + | ||
| 508 | + yangNode = | ||
| 509 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 510 | + OP_PARAM_NAME_REV_16); | ||
| 511 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 512 | + | ||
| 513 | + yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_REV_16); | ||
| 514 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 515 | + | ||
| 516 | + //As we have not registered an application this object should be null. | ||
| 517 | + object = registry.getRegisteredApplication(yangNode); | ||
| 518 | + assertThat(true, is(object == null)); | ||
| 519 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_16); | ||
| 520 | + | ||
| 521 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16); | ||
| 522 | + assertThat(true, is(yangNode == null)); | ||
| 523 | + | ||
| 524 | + //Here the yangNode should be the node which have different revision. | ||
| 525 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 526 | + assertThat(true, is(((YangNode) yangNode).getRevision() != null)); | ||
| 527 | + | ||
| 528 | + //Service with different revision. | ||
| 529 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17); | ||
| 530 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 531 | + | ||
| 532 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 533 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 534 | + | ||
| 535 | + yangNode = | ||
| 536 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 537 | + INTERFACE_NAME_REV_17); | ||
| 538 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 539 | + | ||
| 540 | + yangNode = | ||
| 541 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 542 | + OP_PARAM_NAME_REV_17); | ||
| 543 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 544 | + | ||
| 545 | + yangNode = registry.getRootYangSchemaNodeForNotification( | ||
| 546 | + EVENT_NAME_REV_17); | ||
| 547 | + assertThat(true, is(yangNode == null)); | ||
| 548 | + | ||
| 549 | + //As we have not registered an application this object should be null. | ||
| 550 | + object = registry.getRegisteredApplication(yangNode); | ||
| 551 | + assertThat(true, is(object == null)); | ||
| 552 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_17); | ||
| 553 | + | ||
| 554 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17); | ||
| 555 | + assertThat(true, is(yangNode == null)); | ||
| 556 | + | ||
| 557 | + //Here the yangNode should be the node which have different revision. | ||
| 558 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 559 | + assertThat(true, is(((YangNode) yangNode).getRevision() == null)); | ||
| 560 | + | ||
| 561 | + //Service with different revision. | ||
| 562 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14); | ||
| 563 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 564 | + | ||
| 565 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 566 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 567 | + | ||
| 568 | + yangNode = | ||
| 569 | + registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName( | ||
| 570 | + INTERFACE_NAME_REV_14); | ||
| 571 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 572 | + | ||
| 573 | + yangNode = | ||
| 574 | + registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName( | ||
| 575 | + OP_PARAM_NAME_REV_14); | ||
| 576 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 577 | + | ||
| 578 | + yangNode = registry.getRootYangSchemaNodeForNotification( | ||
| 579 | + EVENT_NAME_REV_14); | ||
| 580 | + assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName()))); | ||
| 581 | + | ||
| 582 | + //As we have not registered an application this object should be null. | ||
| 583 | + object = registry.getRegisteredApplication(yangNode); | ||
| 584 | + assertThat(true, is(object == null)); | ||
| 585 | + testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_14); | ||
| 586 | + | ||
| 587 | + yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14); | ||
| 588 | + assertThat(true, is(yangNode == null)); | ||
| 589 | + | ||
| 590 | + //Here the yangNode should be the node which does not have revision. | ||
| 591 | + // asset should pass with false. | ||
| 592 | + yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4); | ||
| 593 | + assertThat(true, is(yangNode != null)); | ||
| 594 | + | ||
| 595 | + } | ||
| 596 | + | ||
| 597 | + /** | ||
| 598 | + * Unit test case should generate exceptions. | ||
| 599 | + */ | ||
| 600 | + @Test | ||
| 601 | + public void testRegistration() { | ||
| 602 | + thrown.expect(RuntimeException.class); | ||
| 603 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 604 | + testYangSchemaNodeProvider.processRegistrationOfApp(); | ||
| 605 | + } | ||
| 606 | + | ||
| 607 | + /** | ||
| 608 | + * Unit test case should not generate any exceptions and should | ||
| 609 | + * return specific revision node. | ||
| 610 | + */ | ||
| 611 | + @Test | ||
| 612 | + public void testGetWithSpecificRevision() { | ||
| 613 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 614 | + YangSchemaNode schemaNode = testYangSchemaNodeProvider | ||
| 615 | + .getDefaultYangSchemaRegistry() | ||
| 616 | + .getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_WITH_DATE); | ||
| 617 | + | ||
| 618 | + assertThat(true, is(schemaNode.getName().equals(SCHEMA_NAME_4))); | ||
| 619 | + String date = testYangSchemaNodeProvider | ||
| 620 | + .getDefaultYangSchemaRegistry() | ||
| 621 | + .getDateInStringFormat(schemaNode); | ||
| 622 | + assertThat(true, is(date.equals(DATE))); | ||
| 623 | + } | ||
| 624 | + | ||
| 625 | + /** | ||
| 626 | + * Unit test case should not generate any exceptions | ||
| 627 | + * verify notification should be checked for registration. | ||
| 628 | + */ | ||
| 629 | + @Test | ||
| 630 | + public void testNotification() { | ||
| 631 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 632 | + boolean isRegWithNotification = | ||
| 633 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry() | ||
| 634 | + .verifyNotificationObject(IetfNetwork1Service.class); | ||
| 635 | + assertThat(true, is(isRegWithNotification)); | ||
| 636 | + isRegWithNotification = testYangSchemaNodeProvider | ||
| 637 | + .getDefaultYangSchemaRegistry() | ||
| 638 | + .verifyNotificationObject(IetfNetwork1.class); | ||
| 639 | + assertThat(false, is(isRegWithNotification)); | ||
| 640 | + isRegWithNotification = testYangSchemaNodeProvider | ||
| 641 | + .getDefaultYangSchemaRegistry() | ||
| 642 | + .verifyNotificationObject(IetfNetwork1OpParam.class); | ||
| 643 | + assertThat(false, is(isRegWithNotification)); | ||
| 644 | + } | ||
| 645 | + | ||
| 646 | + /** | ||
| 647 | + * Unit test case should not generate any exceptions. | ||
| 648 | + */ | ||
| 649 | + @Test | ||
| 650 | + public void testNotificationRegistrationInYnh() { | ||
| 651 | + testYangSchemaNodeProvider.processSchemaRegistry(null); | ||
| 652 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry() | ||
| 653 | + .verifyNotificationObject(IetfNetwork1Service.class); | ||
| 654 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry() | ||
| 655 | + .verifyNotificationObject(IetfNetwork1.class); | ||
| 656 | + testYangSchemaNodeProvider.getDefaultYangSchemaRegistry() | ||
| 657 | + .verifyNotificationObject(IetfNetwork1OpParam.class); | ||
| 658 | + | ||
| 659 | + boolean isRegWithNotification = testYangSchemaNodeProvider | ||
| 660 | + .getDefaultYangSchemaRegistry() | ||
| 661 | + .verifyNotificationObject(IetfNetwork2Service.class); | ||
| 662 | + | ||
| 663 | + //Register should work. | ||
| 664 | + assertThat(true, is(isRegWithNotification)); | ||
| 665 | + isRegWithNotification = testYangSchemaNodeProvider | ||
| 666 | + .getDefaultYangSchemaRegistry() | ||
| 667 | + .verifyNotificationObject(IetfNetwork2Service.class); | ||
| 668 | + | ||
| 669 | + //Re register should not happen | ||
| 670 | + assertThat(false, is(isRegWithNotification)); | ||
| 671 | + } | ||
| 672 | + | ||
| 673 | +} | ||
| 674 | + | ||
| 675 | + |
| 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 | +} |
-
Please register or login to post a comment