Committed by
Gerrit Code Review
Added a new test applications to monitor network configuration change events and log them.
Change-Id: I882fc1b18cedc67fc83c405c2f8d06078fa15c23
Showing
6 changed files
with
157 additions
and
0 deletions
apps/test/netcfg-monitor/BUCK
0 → 100644
1 | +COMPILE_DEPS = [ | ||
2 | + '//lib:CORE_DEPS', | ||
3 | +] | ||
4 | + | ||
5 | +osgi_jar_with_tests ( | ||
6 | + deps = COMPILE_DEPS, | ||
7 | +) | ||
8 | + | ||
9 | +onos_app ( | ||
10 | + title = 'Network Configuration Monitor Test App', | ||
11 | + category = 'Test', | ||
12 | + url = 'http://onosproject.org', | ||
13 | + description = 'Network configuration monitor test application.', | ||
14 | +) |
apps/test/netcfg-monitor/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2016-present Open Networking Laboratory | ||
4 | + ~ | ||
5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + ~ you may not use this file except in compliance with the License. | ||
7 | + ~ You may obtain a copy of the License at | ||
8 | + ~ | ||
9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + ~ | ||
11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + ~ See the License for the specific language governing permissions and | ||
15 | + ~ limitations under the License. | ||
16 | + --> | ||
17 | + | ||
18 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
19 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
20 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
21 | + <modelVersion>4.0.0</modelVersion> | ||
22 | + | ||
23 | + <parent> | ||
24 | + <groupId>org.onosproject</groupId> | ||
25 | + <artifactId>onos-apps-test</artifactId> | ||
26 | + <version>1.7.0-SNAPSHOT</version> | ||
27 | + </parent> | ||
28 | + | ||
29 | + <artifactId>onos-app-netcfg-monitor</artifactId> | ||
30 | + <packaging>bundle</packaging> | ||
31 | + | ||
32 | + <description>Network configuration monitor test application</description> | ||
33 | + | ||
34 | + <properties> | ||
35 | + <onos.app.name>org.onosproject.netcfgmonitor</onos.app.name> | ||
36 | + <onos.app.title>Network Config Test App</onos.app.title> | ||
37 | + <onos.app.category>Test</onos.app.category> | ||
38 | + <onos.app.url>http://onosproject.org</onos.app.url> | ||
39 | + <onos.app.readme>Network configuration monitor test application.</onos.app.readme> | ||
40 | + </properties> | ||
41 | + | ||
42 | + <dependencies> | ||
43 | + <dependency> | ||
44 | + <groupId>org.onosproject</groupId> | ||
45 | + <artifactId>onos-api</artifactId> | ||
46 | + <version>${project.version}</version> | ||
47 | + <scope>test</scope> | ||
48 | + <classifier>tests</classifier> | ||
49 | + </dependency> | ||
50 | + | ||
51 | + <dependency> | ||
52 | + <groupId>org.osgi</groupId> | ||
53 | + <artifactId>org.osgi.compendium</artifactId> | ||
54 | + </dependency> | ||
55 | + | ||
56 | + <dependency> | ||
57 | + <groupId>org.osgi</groupId> | ||
58 | + <artifactId>org.osgi.core</artifactId> | ||
59 | + </dependency> | ||
60 | + | ||
61 | + </dependencies> | ||
62 | + | ||
63 | +</project> |
apps/test/netcfg-monitor/src/main/java/org/onosproject/netcfgmonitor/NetCfgEventMonitor.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.netcfgmonitor; | ||
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.onosproject.net.config.NetworkConfigEvent; | ||
24 | +import org.onosproject.net.config.NetworkConfigListener; | ||
25 | +import org.onosproject.net.config.NetworkConfigService; | ||
26 | +import org.slf4j.Logger; | ||
27 | +import org.slf4j.LoggerFactory; | ||
28 | + | ||
29 | +/** | ||
30 | + * Network configuration monitor. | ||
31 | + */ | ||
32 | +@Component(immediate = true) | ||
33 | +public class NetCfgEventMonitor { | ||
34 | + | ||
35 | + private Logger log = LoggerFactory.getLogger(getClass()); | ||
36 | + | ||
37 | + @Reference | ||
38 | + protected NetworkConfigService networkConfigService; | ||
39 | + | ||
40 | + private final NetworkConfigListener listener = new InternalListener(); | ||
41 | + | ||
42 | + @Activate | ||
43 | + protected void activate() { | ||
44 | + networkConfigService.addListener(listener); | ||
45 | + } | ||
46 | + | ||
47 | + @Deactivate | ||
48 | + protected void deactivate() { | ||
49 | + networkConfigService.removeListener(listener); | ||
50 | + } | ||
51 | + | ||
52 | + private class InternalListener implements NetworkConfigListener { | ||
53 | + @Override | ||
54 | + public void event(NetworkConfigEvent event) { | ||
55 | + log.info("Received event {}", event); | ||
56 | + } | ||
57 | + } | ||
58 | +} |
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 | + * Network configuration event monitor app. | ||
19 | + */ | ||
20 | +package org.onosproject.netcfgmonitor; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
38 | <module>flow-perf</module> | 38 | <module>flow-perf</module> |
39 | <module>demo</module> | 39 | <module>demo</module> |
40 | <module>distributed-primitives</module> | 40 | <module>distributed-primitives</module> |
41 | + <module>netcfg-monitor</module> | ||
41 | </modules> | 42 | </modules> |
42 | 43 | ||
43 | </project> | 44 | </project> | ... | ... |
... | @@ -139,6 +139,7 @@ ONOS_APPS = [ | ... | @@ -139,6 +139,7 @@ ONOS_APPS = [ |
139 | '//apps/test/flow-perf:onos-apps-test-flow-perf-oar', | 139 | '//apps/test/flow-perf:onos-apps-test-flow-perf-oar', |
140 | '//apps/test/intent-perf:onos-apps-test-intent-perf-oar', | 140 | '//apps/test/intent-perf:onos-apps-test-intent-perf-oar', |
141 | '//apps/test/loadtest:onos-apps-test-loadtest-oar', | 141 | '//apps/test/loadtest:onos-apps-test-loadtest-oar', |
142 | + '//apps/test/netcfg-monitor:onos-apps-test-netcfg-monitor-oar', | ||
142 | '//apps/test/messaging-perf:onos-apps-test-messaging-perf-oar', | 143 | '//apps/test/messaging-perf:onos-apps-test-messaging-perf-oar', |
143 | '//apps/virtualbng:onos-apps-virtualbng-oar', | 144 | '//apps/virtualbng:onos-apps-virtualbng-oar', |
144 | '//apps/vpls:onos-apps-vpls-oar', | 145 | '//apps/vpls:onos-apps-vpls-oar', | ... | ... |
-
Please register or login to post a comment