Kalyankumar Asangi
Committed by Gerrit Code Review

ONOS-4080 ISIS Config Provider

Change-Id: I3387bef3babd402268cb49d371d37ac9e192fba6
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 +<app name="org.onosproject.isis" 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 + <artifact>mvn:${project.groupId}/onos-isis-api/${project.version}</artifact>
22 + <artifact>mvn:${project.groupId}/onos-isis-isisio/${project.version}</artifact>
23 + <artifact>mvn:${project.groupId}/onos-isis-ctl/${project.version}</artifact>
24 + <artifact>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</artifact>
25 + <artifact>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</artifact>
26 +</app>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
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 +<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:${project.groupId}/onos-isis-api/${project.version}</bundle>
23 + <bundle>mvn:${project.groupId}/onos-isis-isisio/${project.version}</bundle>
24 + <bundle>mvn:${project.groupId}/onos-isis-ctl/${project.version}</bundle>
25 + <bundle>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</bundle>
26 + <bundle>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</bundle>
27 + </feature>
28 +</features>
...\ No newline at end of file ...\ No newline at end of file
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 +<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-isis-providers</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-isis-app</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <description>Isis protocol southbound providers</description>
33 +
34 + <dependencies>
35 + <dependency>
36 + <groupId>org.onosproject</groupId>
37 + <artifactId>onos-isis-api</artifactId>
38 + <version>${project.version}</version>
39 + </dependency>
40 + <dependency>
41 + <groupId>org.onosproject</groupId>
42 + <artifactId>onos-isis-isisio</artifactId>
43 + <version>${project.version}</version>
44 + </dependency>
45 + <dependency>
46 + <groupId>org.onosproject</groupId>
47 + <artifactId>onos-isis-ctl</artifactId>
48 + <version>${project.version}</version>
49 + </dependency>
50 + <dependency>
51 + <groupId>org.onosproject</groupId>
52 + <artifactId>onos-isis-provider-device</artifactId>
53 + <version>${project.version}</version>
54 + </dependency>
55 + <dependency>
56 + <groupId>org.onosproject</groupId>
57 + <artifactId>onos-isis-provider-cfg</artifactId>
58 + <version>${project.version}</version>
59 + </dependency>
60 + </dependencies>
61 +</project>
...\ No newline at end of file ...\ No newline at end of file
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 +<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-isis-providers</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-isis-provider-cfg</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>ONOS ISIS Providers</description>
33 + <dependencies>
34 + <dependency>
35 + <groupId>org.osgi</groupId>
36 + <artifactId>org.osgi.compendium</artifactId>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.apache.felix</groupId>
40 + <artifactId>org.apache.felix.scr.annotations</artifactId>
41 + </dependency>
42 + <dependency>
43 + <groupId>org.onosproject</groupId>
44 + <artifactId>onos-isis-ctl</artifactId>
45 + <version>${project.version}</version>
46 + </dependency>
47 + <dependency>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onos-isis-api</artifactId>
50 + <version>${project.version}</version>
51 + </dependency>
52 + </dependencies>
53 +</project>
...\ No newline at end of file ...\ No newline at end of file
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.provider.isis.cfg.impl;
18 +
19 +import com.fasterxml.jackson.databind.JsonNode;
20 +import org.apache.felix.scr.annotations.Reference;
21 +import org.apache.felix.scr.annotations.ReferenceCardinality;
22 +import org.onlab.osgi.DefaultServiceDirectory;
23 +import org.onosproject.core.ApplicationId;
24 +import org.onosproject.isis.controller.IsisController;
25 +import org.onosproject.net.config.Config;
26 +
27 +/**
28 + * Configuration object for ISIS.
29 + */
30 +public class IsisAppConfig extends Config<ApplicationId> {
31 + public static final String METHOD = "method";
32 + public static final String PROCESSES = "processes";
33 +
34 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
35 + IsisController isisController;
36 +
37 + /**
38 + * Returns the configuration method, add, delete etc.
39 + *
40 + * @return the configuration method, add, delete etc
41 + */
42 + public String method() {
43 + return get(METHOD, null);
44 + }
45 +
46 + /**
47 + * Returns the configured processes.
48 + *
49 + * @return the configured processes
50 + */
51 + public JsonNode processes() {
52 +
53 + JsonNode jsonNodes = object.get(PROCESSES);
54 +
55 + return jsonNodes;
56 + }
57 +
58 + @Override
59 + public boolean isValid() {
60 + this.isisController = DefaultServiceDirectory.getService(IsisController.class);
61 +
62 + return true;
63 + }
64 +}
...\ No newline at end of file ...\ No newline at end of file
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.provider.isis.cfg.impl;
18 +
19 +import com.fasterxml.jackson.databind.JsonNode;
20 +import org.apache.felix.scr.annotations.Activate;
21 +import org.apache.felix.scr.annotations.Component;
22 +import org.apache.felix.scr.annotations.Deactivate;
23 +import org.apache.felix.scr.annotations.Reference;
24 +import org.apache.felix.scr.annotations.ReferenceCardinality;
25 +import org.apache.felix.scr.annotations.Service;
26 +import org.onosproject.core.ApplicationId;
27 +import org.onosproject.core.CoreService;
28 +import org.onosproject.isis.controller.IsisController;
29 +import org.onosproject.net.config.ConfigFactory;
30 +import org.onosproject.net.config.NetworkConfigEvent;
31 +import org.onosproject.net.config.NetworkConfigListener;
32 +import org.onosproject.net.config.NetworkConfigRegistry;
33 +import org.onosproject.net.config.NetworkConfigService;
34 +import org.onosproject.net.config.basics.SubjectFactories;
35 +import org.onosproject.net.provider.AbstractProvider;
36 +import org.onosproject.net.provider.ProviderId;
37 +import org.slf4j.Logger;
38 +
39 +import static org.slf4j.LoggerFactory.getLogger;
40 +
41 +/**
42 + * ISIS config provider to validate and populate the configuration.
43 + */
44 +@Component(immediate = true)
45 +@Service
46 +public class IsisCfgProvider extends AbstractProvider {
47 +
48 + private static final String PROVIDER_ID = "org.onosproject.provider.isis.cfg";
49 + private static final Logger log = getLogger(IsisCfgProvider.class);
50 + private final ConfigFactory configFactory =
51 + new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, IsisAppConfig.class, "isisapp") {
52 + @Override
53 + public IsisAppConfig createConfig() {
54 + return new IsisAppConfig();
55 + }
56 + };
57 + private final NetworkConfigListener configListener = new InternalConfigListener();
58 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 + protected IsisController isisController;
60 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
61 + protected CoreService coreService;
62 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
63 + protected NetworkConfigRegistry configRegistry;
64 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
65 + protected NetworkConfigService configService;
66 + private ApplicationId appId;
67 +
68 + /**
69 + * Creates an ISIS config provider.
70 + */
71 + public IsisCfgProvider() {
72 + super(new ProviderId("isis", PROVIDER_ID));
73 + }
74 +
75 + @Activate
76 + public void activate() {
77 + log.debug("Activate...!!!");
78 + appId = coreService.registerApplication(PROVIDER_ID);
79 + configService.addListener(configListener);
80 + configRegistry.registerConfigFactory(configFactory);
81 + log.debug("ISIS cfg service got started");
82 + }
83 +
84 + @Deactivate
85 + public void deactivate() {
86 + log.debug("Deactivate...!!!");
87 + configRegistry.unregisterConfigFactory(configFactory);
88 + configService.removeListener(configListener);
89 + }
90 +
91 + /**
92 + * Pushes the configuration changes to ISIS controller.
93 + */
94 + private void updateConfig() {
95 + IsisAppConfig isisAppConfig = configRegistry.getConfig(appId, IsisAppConfig.class);
96 + log.debug("IsisAppConfig::config processes::" + isisAppConfig.processes());
97 + log.debug("IsisAppConfig::prop 1::" + isisAppConfig.method());
98 + if ("ADD".equalsIgnoreCase(isisAppConfig.method())) {
99 + JsonNode jsonNode = isisAppConfig.processes();
100 + isisController.updateConfig(jsonNode);
101 + }
102 + }
103 +
104 + /**
105 + * Isis config listener to populate the configuration.
106 + */
107 + private class InternalConfigListener implements NetworkConfigListener {
108 +
109 + @Override
110 + public void event(NetworkConfigEvent event) {
111 + log.debug("config event is getting called...!!!");
112 + if (!event.configClass().equals(IsisAppConfig.class)) {
113 + return;
114 + }
115 +
116 + switch (event.type()) {
117 + case CONFIG_ADDED:
118 + updateConfig();
119 + break;
120 + case CONFIG_UPDATED:
121 + updateConfig();
122 + break;
123 + case CONFIG_REMOVED:
124 + break;
125 + default:
126 + break;
127 + }
128 + }
129 + }
130 +}
...\ No newline at end of file ...\ No newline at end of file
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 + * Provider that uses network configuration capability as a means of infrastructure configuration.
19 + */
20 +package org.onosproject.provider.isis.cfg.impl;
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 +<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-isis-providers</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-isis-provider-device</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <description>ONOS ISIS Providers</description>
33 + <dependencies>
34 + <dependency>
35 + <groupId>org.osgi</groupId>
36 + <artifactId>org.osgi.compendium</artifactId>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.apache.felix</groupId>
40 + <artifactId>org.apache.felix.scr.annotations</artifactId>
41 + </dependency>
42 + </dependencies>
43 +</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.provider.isis.device.impl;
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.onosproject.isis.controller.IsisController;
25 +import org.onosproject.net.provider.AbstractProvider;
26 +import org.onosproject.net.provider.ProviderId;
27 +import org.slf4j.Logger;
28 +
29 +import static org.slf4j.LoggerFactory.getLogger;
30 +
31 +/**
32 + * Provider which advertises device descriptions to the core.
33 + */
34 +@Component(immediate = true)
35 +public class IsisTopologyProvider extends AbstractProvider {
36 +
37 + private static final Logger log = getLogger(IsisTopologyProvider.class);
38 + final InternalDeviceProvider listener = new InternalDeviceProvider();
39 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
40 + private IsisController isisController;
41 +
42 +
43 + /**
44 + * Creates an ISIS device provider.
45 + */
46 + public IsisTopologyProvider() {
47 + super(new ProviderId("isis", "org.onosproject.provider.isis"));
48 + }
49 +
50 + @Activate
51 + public void activate() {
52 + log.debug("Activate...!!!");
53 + }
54 +
55 + @Deactivate
56 + public void deactivate() {
57 + log.debug("Deactivate...!!!");
58 + }
59 +
60 + /**
61 + * Internal device provider implementation.
62 + */
63 + private class InternalDeviceProvider {
64 +
65 + }
66 +}
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 + * Provider that uses ISIS request as a means of infrastructure device discovery.
19 + */
20 +package org.onosproject.provider.isis.device.impl;
...\ No newline at end of file ...\ No newline at end of file
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 +<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-providers</artifactId>
25 + <version>1.6.0-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-isis-providers</artifactId>
30 + <packaging>pom</packaging>
31 +
32 + <description>ONOS ISIS protocol adapters</description>
33 +
34 + <modules>
35 + <module>device</module>
36 + <module>app</module>
37 + <module>cfg</module>
38 + </modules>
39 +
40 + <dependencies>
41 + <dependency>
42 + <groupId>org.onosproject</groupId>
43 + <artifactId>onos-isis-ctl</artifactId>
44 + <version>${project.version}</version>
45 + </dependency>
46 + <dependency>
47 + <groupId>org.onosproject</groupId>
48 + <artifactId>onos-api</artifactId>
49 + <classifier>tests</classifier>
50 + <scope>test</scope>
51 + </dependency>
52 + </dependencies>
53 +</project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
46 <module>lldp</module> 46 <module>lldp</module>
47 <module>netcfglinks</module> 47 <module>netcfglinks</module>
48 <module>bmv2</module> 48 <module>bmv2</module>
49 + <module>isis</module>
49 </modules> 50 </modules>
50 51
51 <dependencies> 52 <dependencies>
......