Committed by
Gerrit Code Review
Turned netconf providers into an app and made NetconfDeviceProvider register its…
… configs with ComponentConfigService. More cleanup needs to be done to avoid log messages with "+" and some other stylistic issues. Change-Id: Ic1be1ce6d3340f5a6284ba5514d0052e01bdaaed
Showing
7 changed files
with
108 additions
and
20 deletions
... | @@ -130,10 +130,4 @@ | ... | @@ -130,10 +130,4 @@ |
130 | <bundle>mvn:org.onosproject/onos-core-trivial/@ONOS-VERSION</bundle> | 130 | <bundle>mvn:org.onosproject/onos-core-trivial/@ONOS-VERSION</bundle> |
131 | </feature> | 131 | </feature> |
132 | 132 | ||
133 | - <feature name="onos-netconf" version="@FEATURE-VERSION" | ||
134 | - description="ONOS Netconf providers"> | ||
135 | - <feature>onos-api</feature> | ||
136 | - <bundle>mvn:org.onosproject/onos-netconf-provider-device/@ONOS-VERSION</bundle> | ||
137 | - </feature> | ||
138 | - | ||
139 | </features> | 133 | </features> | ... | ... |
providers/netconf/app/app.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2015 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 | +<app name="org.onosproject.netconf" origin="ON.Lab" version="${project.version}" | ||
18 | + featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features" | ||
19 | + features="${project.artifactId}"> | ||
20 | + <description>${project.description}</description> | ||
21 | + | ||
22 | + <artifact>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</artifact> | ||
23 | + <!-- Question: should there be the jnc stuff here? Or is it just for testing --> | ||
24 | +</app> |
providers/netconf/app/features.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2015 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 | +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}"> | ||
18 | + <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository> | ||
19 | + <feature name="${project.artifactId}" version="${project.version}" | ||
20 | + description="${project.description}"> | ||
21 | + <feature>onos-api</feature> | ||
22 | + <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | ||
23 | + <bundle>mvn:${project.groupId}/onos-netconf-provider-device/${project.version}</bundle> | ||
24 | + <!-- Question: should there be the jnc stuff here? Or is it just for testing --> | ||
25 | + </feature> | ||
26 | +</features> | ||
27 | + |
providers/netconf/app/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2015 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 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | + <modelVersion>4.0.0</modelVersion> | ||
21 | + | ||
22 | + <parent> | ||
23 | + <groupId>org.onosproject</groupId> | ||
24 | + <artifactId>onos-netconf-providers</artifactId> | ||
25 | + <version>1.2.0-SNAPSHOT</version> | ||
26 | + <relativePath>../pom.xml</relativePath> | ||
27 | + </parent> | ||
28 | + | ||
29 | + <artifactId>onos-netconf</artifactId> | ||
30 | + <packaging>pom</packaging> | ||
31 | + | ||
32 | + <description>NetConf protocol southbound providers</description> | ||
33 | + | ||
34 | + <dependencies> | ||
35 | + <dependency> | ||
36 | + <groupId>org.onosproject</groupId> | ||
37 | + <artifactId>onos-netconf-provider-device</artifactId> | ||
38 | + <version>${project.version}</version> | ||
39 | + </dependency> | ||
40 | + <!-- TODO: add other dependencies here as more bundles are added to the app --> | ||
41 | + </dependencies> | ||
42 | + | ||
43 | +</project> |
This diff is collapsed. Click to expand it.
... | @@ -39,6 +39,7 @@ import org.apache.felix.scr.annotations.Property; | ... | @@ -39,6 +39,7 @@ import org.apache.felix.scr.annotations.Property; |
39 | import org.apache.felix.scr.annotations.Reference; | 39 | import org.apache.felix.scr.annotations.Reference; |
40 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 40 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
41 | import org.onlab.packet.ChassisId; | 41 | import org.onlab.packet.ChassisId; |
42 | +import org.onosproject.cfg.ComponentConfigService; | ||
42 | import org.onosproject.cluster.ClusterService; | 43 | import org.onosproject.cluster.ClusterService; |
43 | import org.onosproject.net.Device; | 44 | import org.onosproject.net.Device; |
44 | import org.onosproject.net.DeviceId; | 45 | import org.onosproject.net.DeviceId; |
... | @@ -78,9 +79,11 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -78,9 +79,11 @@ public class NetconfDeviceProvider extends AbstractProvider |
78 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 79 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
79 | protected ClusterService clusterService; | 80 | protected ClusterService clusterService; |
80 | 81 | ||
82 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
83 | + protected ComponentConfigService cfgService; | ||
84 | + | ||
81 | private ExecutorService deviceBuilder = Executors | 85 | private ExecutorService deviceBuilder = Executors |
82 | - .newFixedThreadPool(1, | 86 | + .newFixedThreadPool(1, groupedThreads("onos/netconf", "device-creator")); |
83 | - groupedThreads("onos/netconf", "device-creator")); | ||
84 | 87 | ||
85 | // Delay between events in ms. | 88 | // Delay between events in ms. |
86 | private static final int EVENTINTERVAL = 5; | 89 | private static final int EVENTINTERVAL = 5; |
... | @@ -90,7 +93,7 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -90,7 +93,7 @@ public class NetconfDeviceProvider extends AbstractProvider |
90 | @Property(name = "devConfigs", value = "", label = "Instance-specific configurations") | 93 | @Property(name = "devConfigs", value = "", label = "Instance-specific configurations") |
91 | private String devConfigs = null; | 94 | private String devConfigs = null; |
92 | 95 | ||
93 | - @Property(name = "devPasswords", value = "", label = "Instace-specific password") | 96 | + @Property(name = "devPasswords", value = "", label = "Instance-specific password") |
94 | private String devPasswords = null; | 97 | private String devPasswords = null; |
95 | 98 | ||
96 | /** | 99 | /** |
... | @@ -102,13 +105,15 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -102,13 +105,15 @@ public class NetconfDeviceProvider extends AbstractProvider |
102 | 105 | ||
103 | @Activate | 106 | @Activate |
104 | public void activate(ComponentContext context) { | 107 | public void activate(ComponentContext context) { |
105 | - log.info("Netconf Device Provider Started"); | 108 | + cfgService.registerProperties(getClass()); |
106 | providerService = providerRegistry.register(this); | 109 | providerService = providerRegistry.register(this); |
107 | modified(context); | 110 | modified(context); |
111 | + log.info("Started"); | ||
108 | } | 112 | } |
109 | 113 | ||
110 | @Deactivate | 114 | @Deactivate |
111 | public void deactivate(ComponentContext context) { | 115 | public void deactivate(ComponentContext context) { |
116 | + cfgService.unregisterProperties(getClass(), false); | ||
112 | try { | 117 | try { |
113 | for (Entry<DeviceId, NetconfDevice> deviceEntry : netconfDeviceMap | 118 | for (Entry<DeviceId, NetconfDevice> deviceEntry : netconfDeviceMap |
114 | .entrySet()) { | 119 | .entrySet()) { |
... | @@ -134,13 +139,9 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -134,13 +139,9 @@ public class NetconfDeviceProvider extends AbstractProvider |
134 | } | 139 | } |
135 | Dictionary<?, ?> properties = context.getProperties(); | 140 | Dictionary<?, ?> properties = context.getProperties(); |
136 | String deviceCfgValue = get(properties, "devConfigs"); | 141 | String deviceCfgValue = get(properties, "devConfigs"); |
137 | - log.info("Getting Device configuration from cfg file: " | 142 | + log.info("Settings: devConfigs={}", deviceCfgValue); |
138 | - + deviceCfgValue); | ||
139 | if (!isNullOrEmpty(deviceCfgValue)) { | 143 | if (!isNullOrEmpty(deviceCfgValue)) { |
140 | addOrRemoveDevicesConfig(deviceCfgValue); | 144 | addOrRemoveDevicesConfig(deviceCfgValue); |
141 | - } else { | ||
142 | - log.info("Device Configuration value receiviced from the property 'devConfigs': " | ||
143 | - + deviceCfgValue + ", is not valid"); | ||
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
... | @@ -148,11 +149,9 @@ public class NetconfDeviceProvider extends AbstractProvider | ... | @@ -148,11 +149,9 @@ public class NetconfDeviceProvider extends AbstractProvider |
148 | for (String deviceEntry : deviceConfig.split(",")) { | 149 | for (String deviceEntry : deviceConfig.split(",")) { |
149 | NetconfDevice device = processDeviceEntry(deviceEntry); | 150 | NetconfDevice device = processDeviceEntry(deviceEntry); |
150 | if (device != null) { | 151 | if (device != null) { |
151 | - log.info("Device Detail: " + "username: " | 152 | + log.info("Device Detail: username: {}, host={}, port={}, state={}", |
152 | - + device.getUsername() + ", host: " | 153 | + device.getUsername(), device.getSshHost(), |
153 | - + device.getSshHost() + ", port: " | 154 | + device.getSshPort(), device.getDeviceState().name()); |
154 | - + device.getSshPort() + " device state: " | ||
155 | - + device.getDeviceState().name()); | ||
156 | if (device.isActive()) { | 155 | if (device.isActive()) { |
157 | deviceBuilder.submit(new DeviceCreator(device, true)); | 156 | deviceBuilder.submit(new DeviceCreator(device, true)); |
158 | } else { | 157 | } else { | ... | ... |
-
Please register or login to post a comment