alshabib
Committed by Ali Al-Shabibi

removing cord-related applications

Change-Id: Ia232adeecf0f5ea17061b3fb7ca851b6a00e0f99
Showing 96 changed files with 0 additions and 4789 deletions
...@@ -99,7 +99,6 @@ APPS = [ ...@@ -99,7 +99,6 @@ APPS = [
99 # Apps 99 # Apps
100 '//apps/dhcp:onos-apps-dhcp-oar', 100 '//apps/dhcp:onos-apps-dhcp-oar',
101 '//apps/fwd:onos-apps-fwd-oar', 101 '//apps/fwd:onos-apps-fwd-oar',
102 - '//apps/aaa:onos-apps-aaa-oar',
103 '//apps/acl:onos-apps-acl-oar', 102 '//apps/acl:onos-apps-acl-oar',
104 '//apps/bgprouter:onos-apps-bgprouter-oar', 103 '//apps/bgprouter:onos-apps-bgprouter-oar',
105 '//apps/cip:onos-apps-cip-oar', 104 '//apps/cip:onos-apps-cip-oar',
...@@ -109,10 +108,7 @@ APPS = [ ...@@ -109,10 +108,7 @@ APPS = [
109 '//apps/segmentrouting:onos-apps-segmentrouting-oar', 108 '//apps/segmentrouting:onos-apps-segmentrouting-oar',
110 '//apps/gangliametrics:onos-apps-gangliametrics-oar', 109 '//apps/gangliametrics:onos-apps-gangliametrics-oar',
111 '//apps/graphitemetrics:onos-apps-graphitemetrics-oar', 110 '//apps/graphitemetrics:onos-apps-graphitemetrics-oar',
112 - '//apps/igmp:onos-apps-igmp-oar',
113 - '//apps/cordmcast:onos-apps-cordmcast-oar',
114 '//apps/flowanalyzer:onos-apps-flowanalyzer-oar', 111 '//apps/flowanalyzer:onos-apps-flowanalyzer-oar',
115 - '//apps/olt:onos-apps-olt-oar',
116 '//apps/influxdbmetrics:onos-apps-influxdbmetrics-oar', 112 '//apps/influxdbmetrics:onos-apps-influxdbmetrics-oar',
117 '//apps/metrics:onos-apps-metrics-oar', 113 '//apps/metrics:onos-apps-metrics-oar',
118 '//apps/mfwd:onos-apps-mfwd-oar', 114 '//apps/mfwd:onos-apps-mfwd-oar',
...@@ -137,7 +133,6 @@ APPS = [ ...@@ -137,7 +133,6 @@ APPS = [
137 '//apps/test/loadtest:onos-apps-test-loadtest-oar', 133 '//apps/test/loadtest:onos-apps-test-loadtest-oar',
138 '//apps/test/messaging-perf:onos-apps-test-messaging-perf-oar', 134 '//apps/test/messaging-perf:onos-apps-test-messaging-perf-oar',
139 '//apps/virtualbng:onos-apps-virtualbng-oar', 135 '//apps/virtualbng:onos-apps-virtualbng-oar',
140 - '//apps/cordvtn:onos-apps-cordvtn-oar',
141 '//apps/vpls:onos-apps-vpls-oar', 136 '//apps/vpls:onos-apps-vpls-oar',
142 '//apps/vrouter:onos-apps-vrouter-oar', 137 '//apps/vrouter:onos-apps-vrouter-oar',
143 '//apps/vtn:onos-apps-vtn-oar', 138 '//apps/vtn:onos-apps-vtn-oar',
...@@ -145,7 +140,6 @@ APPS = [ ...@@ -145,7 +140,6 @@ APPS = [
145 '//apps/openstacknode:onos-apps-openstacknode-oar', 140 '//apps/openstacknode:onos-apps-openstacknode-oar',
146 '//apps/cpman/app:onos-apps-cpman-app-oar', 141 '//apps/cpman/app:onos-apps-cpman-app-oar',
147 '//apps/xosclient:onos-apps-xosclient-oar', 142 '//apps/xosclient:onos-apps-xosclient-oar',
148 - '//apps/cordconfig:onos-apps-cordconfig',
149 ] 143 ]
150 144
151 APP_JARS = [ 145 APP_JARS = [
...@@ -154,7 +148,6 @@ APP_JARS = [ ...@@ -154,7 +148,6 @@ APP_JARS = [
154 '//apps/dhcp/api:onos-apps-dhcp-api', 148 '//apps/dhcp/api:onos-apps-dhcp-api',
155 '//apps/dhcp/app:onos-apps-dhcp-app', 149 '//apps/dhcp/app:onos-apps-dhcp-app',
156 '//apps/fwd:onos-apps-fwd', 150 '//apps/fwd:onos-apps-fwd',
157 - '//apps/olt:onos-apps-olt-api',
158 '//apps/iptopology-api:onos-apps-iptopology-api', 151 '//apps/iptopology-api:onos-apps-iptopology-api',
159 '//apps/openstacknode:onos-apps-openstacknode', 152 '//apps/openstacknode:onos-apps-openstacknode',
160 '//apps/routing:onos-apps-routing', 153 '//apps/routing:onos-apps-routing',
......
1 -COMPILE_DEPS = [
2 - '//lib:CORE_DEPS',
3 - '//lib:org.apache.karaf.shell.console',
4 - '//cli:onos-cli',
5 -]
6 -
7 -TEST_DEPS = [
8 - '//lib:TEST_ADAPTERS',
9 - '//core/common:onos-core-common',
10 -]
11 -
12 -osgi_jar_with_tests (
13 - deps = COMPILE_DEPS,
14 - test_deps = TEST_DEPS,
15 -)
16 -
17 -onos_app (
18 - title = 'Authentication App',
19 - category = 'Security',
20 - url = 'http://onosproject.org',
21 - description = 'ONOS authentication application.',
22 -)
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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.aaa" origin="ATT" version="${project.version}"
18 - category="Security" url="http://onosproject.org" title="Authentication App"
19 - featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
20 - features="${project.artifactId}">
21 - <description>${project.description}</description>
22 - <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
23 -</app>
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 -<!--
3 - ~ Copyright 2015-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 - <feature name="${project.artifactId}" version="${project.version}"
19 - description="${project.description}">
20 - <feature>onos-api</feature>
21 - <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
22 - </feature>
23 -</features>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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-apps</artifactId>
25 - <version>1.6.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-aaa</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS authentication application</description>
33 -
34 - <dependencies>
35 - <dependency>
36 - <groupId>org.osgi</groupId>
37 - <artifactId>org.osgi.compendium</artifactId>
38 - </dependency>
39 -
40 - <dependency>
41 - <groupId>org.onosproject</groupId>
42 - <artifactId>onos-api</artifactId>
43 - <version>${project.version}</version>
44 - </dependency>
45 -
46 - <dependency>
47 - <groupId>org.onosproject</groupId>
48 - <artifactId>onlab-junit</artifactId>
49 - <scope>test</scope>
50 - </dependency>
51 -
52 - <dependency>
53 - <groupId>org.onosproject</groupId>
54 - <artifactId>onlab-osgi</artifactId>
55 - <version>${project.version}</version>
56 - <classifier>tests</classifier>
57 - <scope>test</scope>
58 - </dependency>
59 -
60 - <dependency>
61 - <groupId>org.onosproject</groupId>
62 - <artifactId>onos-api</artifactId>
63 - <version>${project.version}</version>
64 - <classifier>tests</classifier>
65 - <scope>test</scope>
66 - </dependency>
67 -
68 - <dependency>
69 - <groupId>org.onosproject</groupId>
70 - <artifactId>onos-cli</artifactId>
71 - <version>${project.version}</version>
72 - </dependency>
73 -
74 - <dependency>
75 - <groupId>org.apache.karaf.shell</groupId>
76 - <artifactId>org.apache.karaf.shell.console</artifactId>
77 - </dependency>
78 - </dependencies>
79 -
80 -
81 - <build>
82 - <plugins>
83 - <plugin>
84 - <groupId>org.apache.felix</groupId>
85 - <artifactId>maven-bundle-plugin</artifactId>
86 - </plugin>
87 -
88 - <plugin>
89 - <groupId>org.apache.felix</groupId>
90 - <artifactId>maven-scr-plugin</artifactId>
91 - </plugin>
92 - <plugin>
93 - <groupId>org.onosproject</groupId>
94 - <artifactId>onos-maven-plugin</artifactId>
95 - </plugin>
96 - </plugins>
97 - </build>
98 -</project>
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 -package org.onosproject.aaa;
17 -
18 -import org.onosproject.core.ApplicationId;
19 -import org.onosproject.net.config.Config;
20 -import org.onosproject.net.config.basics.BasicElementConfig;
21 -
22 -import java.net.InetAddress;
23 -import java.net.UnknownHostException;
24 -
25 -/**
26 - * Network config for the AAA app.
27 - */
28 -public class AaaConfig extends Config<ApplicationId> {
29 -
30 - private static final String RADIUS_IP = "radiusIp";
31 - private static final String RADIUS_SERVER_PORT = "1812";
32 - private static final String RADIUS_MAC = "radiusMac";
33 - private static final String NAS_IP = "nasIp";
34 - private static final String NAS_MAC = "nasMac";
35 - private static final String RADIUS_SECRET = "radiusSecret";
36 - private static final String RADIUS_SWITCH = "radiusSwitch";
37 - private static final String RADIUS_PORT = "radiusPort";
38 -
39 - // RADIUS server IP address
40 - protected static final String DEFAULT_RADIUS_IP = "10.128.10.4";
41 -
42 - // RADIUS MAC address
43 - protected static final String DEFAULT_RADIUS_MAC = "00:00:00:00:01:10";
44 -
45 - // NAS IP address
46 - protected static final String DEFAULT_NAS_IP = "10.128.9.244";
47 -
48 - // NAS MAC address
49 - protected static final String DEFAULT_NAS_MAC = "00:00:00:00:10:01";
50 -
51 - // RADIUS server shared secret
52 - protected static final String DEFAULT_RADIUS_SECRET = "ONOSecret";
53 -
54 - // Radius Switch Id
55 - protected static final String DEFAULT_RADIUS_SWITCH = "of:90e2ba82f97791e9";
56 -
57 - // Radius Port Number
58 - protected static final String DEFAULT_RADIUS_PORT = "129";
59 -
60 - // Radius Server UDP Port Number
61 - protected static final String DEFAULT_RADIUS_SERVER_PORT = "1812";
62 -
63 - /**
64 - * Gets the value of a string property, protecting for an empty
65 - * JSON object.
66 - *
67 - * @param name name of the property
68 - * @param defaultValue default value if none has been specified
69 - * @return String value if one os found, default value otherwise
70 - */
71 - private String getStringProperty(String name, String defaultValue) {
72 - if (object == null) {
73 - return defaultValue;
74 - }
75 - return get(name, defaultValue);
76 - }
77 -
78 - /**
79 - * Returns the NAS ip.
80 - *
81 - * @return ip address or null if not set
82 - */
83 - public InetAddress nasIp() {
84 - try {
85 - return InetAddress.getByName(getStringProperty(NAS_IP, DEFAULT_NAS_IP));
86 - } catch (UnknownHostException e) {
87 - return null;
88 - }
89 - }
90 -
91 - /**
92 - * Sets the NAS ip.
93 - *
94 - * @param ip new ip address; null to clear
95 - * @return self
96 - */
97 - public BasicElementConfig nasIp(String ip) {
98 - return (BasicElementConfig) setOrClear(NAS_IP, ip);
99 - }
100 -
101 - /**
102 - * Returns the RADIUS server ip.
103 - *
104 - * @return ip address or null if not set
105 - */
106 - public InetAddress radiusIp() {
107 - try {
108 - return InetAddress.getByName(getStringProperty(RADIUS_IP, DEFAULT_RADIUS_IP));
109 - } catch (UnknownHostException e) {
110 - return null;
111 - }
112 - }
113 -
114 - /**
115 - * Sets the RADIUS server ip.
116 - *
117 - * @param ip new ip address; null to clear
118 - * @return self
119 - */
120 - public BasicElementConfig radiusIp(String ip) {
121 - return (BasicElementConfig) setOrClear(RADIUS_IP, ip);
122 - }
123 -
124 - /**
125 - * Returns the RADIUS MAC address.
126 - *
127 - * @return mac address or null if not set
128 - */
129 - public String radiusMac() {
130 - return getStringProperty(RADIUS_MAC, DEFAULT_RADIUS_MAC);
131 - }
132 -
133 - /**
134 - * Sets the RADIUS MAC address.
135 - *
136 - * @param mac new MAC address; null to clear
137 - * @return self
138 - */
139 - public BasicElementConfig radiusMac(String mac) {
140 - return (BasicElementConfig) setOrClear(RADIUS_MAC, mac);
141 - }
142 -
143 - /**
144 - * Returns the RADIUS MAC address.
145 - *
146 - * @return mac address or null if not set
147 - */
148 - public String nasMac() {
149 - return getStringProperty(NAS_MAC, DEFAULT_NAS_MAC);
150 - }
151 -
152 - /**
153 - * Sets the RADIUS MAC address.
154 - *
155 - * @param mac new MAC address; null to clear
156 - * @return self
157 - */
158 - public BasicElementConfig nasMac(String mac) {
159 - return (BasicElementConfig) setOrClear(NAS_MAC, mac);
160 - }
161 -
162 - /**
163 - * Returns the RADIUS secret.
164 - *
165 - * @return radius secret or null if not set
166 - */
167 - public String radiusSecret() {
168 - return getStringProperty(RADIUS_SECRET, DEFAULT_RADIUS_SECRET);
169 - }
170 -
171 - /**
172 - * Sets the RADIUS secret.
173 - *
174 - * @param secret new MAC address; null to clear
175 - * @return self
176 - */
177 - public BasicElementConfig radiusSecret(String secret) {
178 - return (BasicElementConfig) setOrClear(RADIUS_SECRET, secret);
179 - }
180 -
181 - /**
182 - * Returns the ID of the RADIUS switch.
183 - *
184 - * @return radius switch ID or null if not set
185 - */
186 - public String radiusSwitch() {
187 - return getStringProperty(RADIUS_SWITCH, DEFAULT_RADIUS_SWITCH);
188 - }
189 -
190 - /**
191 - * Sets the ID of the RADIUS switch.
192 - *
193 - * @param switchId new RADIUS switch ID; null to clear
194 - * @return self
195 - */
196 - public BasicElementConfig radiusSwitch(String switchId) {
197 - return (BasicElementConfig) setOrClear(RADIUS_SWITCH, switchId);
198 - }
199 -
200 - /**
201 - * Returns the RADIUS port.
202 - *
203 - * @return radius port or null if not set
204 - */
205 - public long radiusPort() {
206 - return Integer.parseInt(getStringProperty(RADIUS_PORT, DEFAULT_RADIUS_PORT));
207 - }
208 -
209 - /**
210 - * Sets the RADIUS port.
211 - *
212 - * @param port new RADIUS port; null to clear
213 - * @return self
214 - */
215 - public BasicElementConfig radiusPort(long port) {
216 - return (BasicElementConfig) setOrClear(RADIUS_PORT, port);
217 - }
218 -
219 - /**
220 - * Returns the RADIUS server UDP port.
221 - *
222 - * @return radius server UDP port.
223 - */
224 - public short radiusServerUdpPort() {
225 - return Short.parseShort(getStringProperty(RADIUS_SERVER_PORT,
226 - DEFAULT_RADIUS_SERVER_PORT));
227 - }
228 -
229 - /**
230 - * Sets the RADIUS port.
231 - *
232 - * @param port new RADIUS UDP port; -1 to clear
233 - * @return self
234 - */
235 - public BasicElementConfig radiusServerUdpPort(short port) {
236 - return (BasicElementConfig) setOrClear(RADIUS_SERVER_PORT, (long) port);
237 - }
238 -
239 -}
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 -package org.onosproject.aaa;
17 -
18 -import org.apache.karaf.shell.commands.Command;
19 -import org.onosproject.cli.AbstractShellCommand;
20 -
21 -/**
22 - * Shows the users in the aaa.
23 - */
24 -@Command(scope = "onos", name = "aaa-users",
25 - description = "Shows the aaa users")
26 -public class AaaShowUsersCommand extends AbstractShellCommand {
27 - @Override
28 - protected void execute() {
29 - String[] state = {
30 - "IDLE",
31 - "STARTED",
32 - "PENDING",
33 - "AUTHORIZED",
34 - "UNAUTHORIZED"
35 - };
36 - for (StateMachine stateMachine : StateMachine.sessionIdMap().values()) {
37 - String deviceId = stateMachine.supplicantConnectpoint().deviceId().toString();
38 - String portNum = stateMachine.supplicantConnectpoint().port().toString();
39 - String username = new String(stateMachine.username());
40 - print("UserName=%s,CurrentState=%s,DeviceId=%s,PortNumber=%s",
41 - username, state[stateMachine.state()], deviceId, portNum);
42 - }
43 - }
44 -}
1 -/*
2 - *
3 - * Copyright 2015 AT&T Foundry
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 -package org.onosproject.aaa;
19 -
20 -/**
21 - * Exception for the State Machine.
22 - */
23 -class StateMachineException extends Exception {
24 - public StateMachineException(String message) {
25 - super(message);
26 -
27 - }
28 -}
1 -/*
2 - *
3 - * Copyright 2015 AT&T Foundry
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 -package org.onosproject.aaa;
19 -
20 -/**
21 - * Exception raised when the transition from one state to another is invalid.
22 - */
23 -class StateMachineInvalidTransitionException extends StateMachineException {
24 - public StateMachineInvalidTransitionException(String message) {
25 - super(message);
26 - }
27 -}
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 -/**
18 - * AAA implmentation.
19 - */
20 -package org.onosproject.aaa;
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 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 -
18 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 - <command>
20 - <action class="org.onosproject.aaa.AaaShowUsersCommand"/>
21 - </command>
22 - </command-bundle>
23 -</blueprint>
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 -package org.onosproject.aaa;
17 -
18 -import org.junit.Before;
19 -import org.junit.Ignore;
20 -import org.junit.Test;
21 -import org.onlab.packet.EAP;
22 -import org.onlab.packet.EAPOL;
23 -import org.onlab.packet.Ethernet;
24 -import org.onosproject.core.CoreServiceAdapter;
25 -import org.onosproject.net.config.Config;
26 -import org.onosproject.net.config.NetworkConfigRegistryAdapter;
27 -
28 -import static org.hamcrest.Matchers.is;
29 -import static org.hamcrest.Matchers.notNullValue;
30 -import static org.junit.Assert.assertThat;
31 -
32 -/**
33 - * Set of tests of the ONOS application component. These use an existing RADIUS
34 - * server and sends live packets over the network to it.
35 - */
36 -@Ignore ("This should not be run as part of the standard build")
37 -public class AaaIntegrationTest extends AaaTestBase {
38 -
39 - private AaaManager aaa;
40 -
41 - /**
42 - * Mocks the network config registry.
43 - */
44 - @SuppressWarnings("unchecked")
45 - static final class TestNetworkConfigRegistry
46 - extends NetworkConfigRegistryAdapter {
47 - @Override
48 - public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
49 - return (C) new AaaConfig();
50 - }
51 - }
52 -
53 - /**
54 - * Sets up the services required by the AAA application.
55 - */
56 - @Before
57 - public void setUp() {
58 - aaa = new AaaManager();
59 - aaa.netCfgService = new TestNetworkConfigRegistry();
60 - aaa.coreService = new CoreServiceAdapter();
61 - aaa.packetService = new MockPacketService();
62 - aaa.activate();
63 - }
64 -
65 - /**
66 - * Fetches the sent packet at the given index. The requested packet
67 - * must be the last packet on the list.
68 - *
69 - * @param index index into sent packets array
70 - * @return packet
71 - */
72 - private Ethernet fetchPacket(int index) {
73 - for (int iteration = 0; iteration < 20; iteration++) {
74 - if (savedPackets.size() > index) {
75 - return (Ethernet) savedPackets.get(index);
76 - } else {
77 - try {
78 - Thread.sleep(250);
79 - } catch (Exception ex) {
80 - return null;
81 - }
82 - }
83 - }
84 - return null;
85 - }
86 -
87 - /**
88 - * Tests the authentication path through the AAA application by sending
89 - * packets to the RADIUS server and checking the state machine
90 - * transitions.
91 - *
92 - * @throws Exception when an unhandled error occurs
93 - */
94 - @Test
95 - public void testAuthentication() throws Exception {
96 -
97 - // (1) Supplicant start up
98 -
99 - Ethernet startPacket = constructSupplicantStartPacket();
100 - sendPacket(startPacket);
101 -
102 - Ethernet responsePacket = fetchPacket(0);
103 - assertThat(responsePacket, notNullValue());
104 - checkRadiusPacket(aaa, responsePacket, EAP.REQUEST);
105 -
106 - // (2) Supplicant identify
107 -
108 - Ethernet identifyPacket = constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null);
109 - sendPacket(identifyPacket);
110 -
111 - // State machine should have been created by now
112 -
113 - StateMachine stateMachine =
114 - StateMachine.lookupStateMachineBySessionId(SESSION_ID);
115 - assertThat(stateMachine, notNullValue());
116 - assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING));
117 -
118 - // (3) RADIUS MD5 challenge
119 -
120 - Ethernet radiusChallengeMD5Packet = fetchPacket(1);
121 - assertThat(radiusChallengeMD5Packet, notNullValue());
122 - checkRadiusPacket(aaa, radiusChallengeMD5Packet, EAP.REQUEST);
123 -
124 -
125 - // (4) Supplicant MD5 response
126 -
127 - Ethernet md5RadiusPacket =
128 - constructSupplicantIdentifyPacket(stateMachine,
129 - EAP.ATTR_MD5,
130 - stateMachine.challengeIdentifier(),
131 - radiusChallengeMD5Packet);
132 - sendPacket(md5RadiusPacket);
133 -
134 -
135 - // (5) RADIUS Success
136 -
137 - Ethernet successRadiusPacket = fetchPacket(2);
138 - assertThat(successRadiusPacket, notNullValue());
139 - EAPOL successEapol = (EAPOL) successRadiusPacket.getPayload();
140 - EAP successEap = (EAP) successEapol.getPayload();
141 - assertThat(successEap.getCode(), is(EAP.SUCCESS));
142 -
143 - // State machine should be in authorized state
144 -
145 - assertThat(stateMachine, notNullValue());
146 - assertThat(stateMachine.state(), is(StateMachine.STATE_AUTHORIZED));
147 -
148 - }
149 -
150 -}
151 -
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 -package org.onosproject.aaa;
17 -
18 -import com.google.common.base.Charsets;
19 -import org.junit.After;
20 -import org.junit.Before;
21 -import org.junit.Test;
22 -import org.onlab.packet.BasePacket;
23 -import org.onlab.packet.DeserializationException;
24 -import org.onlab.packet.EAP;
25 -import org.onlab.packet.Ethernet;
26 -import org.onlab.packet.IpAddress;
27 -import org.onlab.packet.RADIUS;
28 -import org.onlab.packet.RADIUSAttribute;
29 -import org.onosproject.core.CoreServiceAdapter;
30 -import org.onosproject.net.config.Config;
31 -import org.onosproject.net.config.NetworkConfigRegistryAdapter;
32 -
33 -import java.net.InetAddress;
34 -import java.net.UnknownHostException;
35 -
36 -import static org.hamcrest.Matchers.is;
37 -import static org.hamcrest.Matchers.notNullValue;
38 -import static org.junit.Assert.assertThat;
39 -
40 -/**
41 - * Set of tests of the ONOS application component.
42 - */
43 -public class AaaManagerTest extends AaaTestBase {
44 -
45 - static final String BAD_IP_ADDRESS = "198.51.100.0";
46 -
47 - private AaaManager aaaManager;
48 -
49 - class AaaManagerWithoutRadiusServer extends AaaManager {
50 - protected void sendRadiusPacket(RADIUS radiusPacket) {
51 - savePacket(radiusPacket);
52 - }
53 - }
54 -
55 - /**
56 - * Mocks the AAAConfig class to force usage of an unroutable address for the
57 - * RADIUS server.
58 - */
59 - static class MockAaaConfig extends AaaConfig {
60 - @Override
61 - public InetAddress radiusIp() {
62 - try {
63 - return InetAddress.getByName(BAD_IP_ADDRESS);
64 - } catch (UnknownHostException ex) {
65 - // can't happen
66 - throw new IllegalStateException(ex);
67 - }
68 - }
69 - }
70 -
71 - /**
72 - * Mocks the network config registry.
73 - */
74 - @SuppressWarnings("unchecked")
75 - private static final class TestNetworkConfigRegistry
76 - extends NetworkConfigRegistryAdapter {
77 - @Override
78 - public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
79 - AaaConfig aaaConfig = new MockAaaConfig();
80 - return (C) aaaConfig;
81 - }
82 - }
83 -
84 - /**
85 - * Constructs an Ethernet packet containing a RADIUS challenge
86 - * packet.
87 - *
88 - * @param challengeCode code to use in challenge packet
89 - * @param challengeType type to use in challenge packet
90 - * @return Ethernet packet
91 - */
92 - private RADIUS constructRadiusCodeAccessChallengePacket(byte challengeCode, byte challengeType) {
93 -
94 - String challenge = "12345678901234567";
95 -
96 - EAP eap = new EAP(challengeType, (byte) 1, challengeType,
97 - challenge.getBytes(Charsets.US_ASCII));
98 - eap.setIdentifier((byte) 1);
99 -
100 - RADIUS radius = new RADIUS();
101 - radius.setCode(challengeCode);
102 -
103 - radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
104 - challenge.getBytes(Charsets.US_ASCII));
105 -
106 - radius.setPayload(eap);
107 - radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE,
108 - eap.serialize());
109 -
110 - return radius;
111 - }
112 -
113 - /**
114 - * Sets up the services required by the AAA application.
115 - */
116 - @Before
117 - public void setUp() {
118 - aaaManager = new AaaManagerWithoutRadiusServer();
119 - aaaManager.netCfgService = new TestNetworkConfigRegistry();
120 - aaaManager.coreService = new CoreServiceAdapter();
121 - aaaManager.packetService = new MockPacketService();
122 - aaaManager.activate();
123 - }
124 -
125 - /**
126 - * Tears down the AAA application.
127 - */
128 - @After
129 - public void tearDown() {
130 - aaaManager.deactivate();
131 - }
132 -
133 - /**
134 - * Extracts the RADIUS packet from a packet sent by the supplicant.
135 - *
136 - * @param radius RADIUS packet sent by the supplicant
137 - * @throws DeserializationException if deserialization of the packet contents
138 - * fails.
139 - */
140 - private void checkRadiusPacketFromSupplicant(RADIUS radius)
141 - throws DeserializationException {
142 - assertThat(radius, notNullValue());
143 -
144 - EAP eap = radius.decapsulateMessage();
145 - assertThat(eap, notNullValue());
146 - }
147 -
148 - /**
149 - * Fetches the sent packet at the given index. The requested packet
150 - * must be the last packet on the list.
151 - *
152 - * @param index index into sent packets array
153 - * @return packet
154 - */
155 - private BasePacket fetchPacket(int index) {
156 - BasePacket packet = savedPackets.get(index);
157 - assertThat(packet, notNullValue());
158 - return packet;
159 - }
160 -
161 - /**
162 - * Tests the authentication path through the AAA application.
163 - *
164 - * @throws DeserializationException if packed deserialization fails.
165 - */
166 - @Test
167 - public void testAuthentication() throws Exception {
168 -
169 - // (1) Supplicant start up
170 -
171 - Ethernet startPacket = constructSupplicantStartPacket();
172 - sendPacket(startPacket);
173 -
174 - Ethernet responsePacket = (Ethernet) fetchPacket(0);
175 - checkRadiusPacket(aaaManager, responsePacket, EAP.ATTR_IDENTITY);
176 -
177 - // (2) Supplicant identify
178 -
179 - Ethernet identifyPacket = constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null);
180 - sendPacket(identifyPacket);
181 -
182 - RADIUS radiusIdentifyPacket = (RADIUS) fetchPacket(1);
183 -
184 - checkRadiusPacketFromSupplicant(radiusIdentifyPacket);
185 -
186 - assertThat(radiusIdentifyPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST));
187 - assertThat(new String(radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME).getValue()),
188 - is("testuser"));
189 -
190 - IpAddress nasIp =
191 - IpAddress.valueOf(IpAddress.Version.INET,
192 - radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP)
193 - .getValue());
194 - assertThat(nasIp.toString(), is(aaaManager.nasIpAddress.getHostAddress()));
195 -
196 - // State machine should have been created by now
197 -
198 - StateMachine stateMachine =
199 - StateMachine.lookupStateMachineBySessionId(SESSION_ID);
200 - assertThat(stateMachine, notNullValue());
201 - assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING));
202 -
203 - // (3) RADIUS MD5 challenge
204 -
205 - RADIUS radiusCodeAccessChallengePacket =
206 - constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_CHALLENGE, EAP.ATTR_MD5);
207 - aaaManager.radiusListener.handleRadiusPacket(radiusCodeAccessChallengePacket);
208 -
209 - Ethernet radiusChallengeMD5Packet = (Ethernet) fetchPacket(2);
210 - checkRadiusPacket(aaaManager, radiusChallengeMD5Packet, EAP.ATTR_MD5);
211 -
212 - // (4) Supplicant MD5 response
213 -
214 - Ethernet md5RadiusPacket =
215 - constructSupplicantIdentifyPacket(stateMachine,
216 - EAP.ATTR_MD5,
217 - stateMachine.challengeIdentifier(),
218 - radiusChallengeMD5Packet);
219 - sendPacket(md5RadiusPacket);
220 -
221 - RADIUS responseMd5RadiusPacket = (RADIUS) fetchPacket(3);
222 -
223 - checkRadiusPacketFromSupplicant(responseMd5RadiusPacket);
224 - assertThat(responseMd5RadiusPacket.getIdentifier(), is((byte) 0));
225 - assertThat(responseMd5RadiusPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST));
226 -
227 - // State machine should be in pending state
228 -
229 - assertThat(stateMachine, notNullValue());
230 - assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING));
231 -
232 - // (5) RADIUS Success
233 -
234 - RADIUS successPacket =
235 - constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_ACCEPT, EAP.SUCCESS);
236 - aaaManager.radiusListener.handleRadiusPacket((successPacket));
237 - Ethernet supplicantSuccessPacket = (Ethernet) fetchPacket(4);
238 -
239 - checkRadiusPacket(aaaManager, supplicantSuccessPacket, EAP.SUCCESS);
240 -
241 - // State machine should be in authorized state
242 -
243 - assertThat(stateMachine, notNullValue());
244 - assertThat(stateMachine.state(), is(StateMachine.STATE_AUTHORIZED));
245 -
246 - }
247 -
248 - /**
249 - * Tests the default configuration.
250 - */
251 - @Test
252 - public void testConfig() {
253 - assertThat(aaaManager.nasIpAddress.getHostAddress(), is(AaaConfig.DEFAULT_NAS_IP));
254 - assertThat(aaaManager.nasMacAddress, is(AaaConfig.DEFAULT_NAS_MAC));
255 - assertThat(aaaManager.radiusIpAddress.getHostAddress(), is(BAD_IP_ADDRESS));
256 - assertThat(aaaManager.radiusMacAddress, is(AaaConfig.DEFAULT_RADIUS_MAC));
257 - }
258 -}
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 -package org.onosproject.aaa;
17 -
18 -import org.onlab.packet.BasePacket;
19 -import org.onlab.packet.EAP;
20 -import org.onlab.packet.EAPOL;
21 -import org.onlab.packet.EthType;
22 -import org.onlab.packet.Ethernet;
23 -import org.onlab.packet.MacAddress;
24 -import org.onosproject.net.packet.DefaultInboundPacket;
25 -import org.onosproject.net.packet.DefaultPacketContext;
26 -import org.onosproject.net.packet.InboundPacket;
27 -import org.onosproject.net.packet.OutboundPacket;
28 -import org.onosproject.net.packet.PacketContext;
29 -import org.onosproject.net.packet.PacketProcessor;
30 -import org.onosproject.net.packet.PacketServiceAdapter;
31 -
32 -import java.nio.ByteBuffer;
33 -import java.security.MessageDigest;
34 -import java.util.LinkedList;
35 -import java.util.List;
36 -
37 -import static org.hamcrest.Matchers.instanceOf;
38 -import static org.hamcrest.Matchers.is;
39 -import static org.hamcrest.Matchers.notNullValue;
40 -import static org.junit.Assert.assertThat;
41 -import static org.junit.Assert.fail;
42 -import static org.onosproject.net.NetTestTools.connectPoint;
43 -
44 -/**
45 - * Common methods for AAA app testing.
46 - */
47 -public class AaaTestBase {
48 -
49 - MacAddress clientMac = MacAddress.valueOf("1a:1a:1a:1a:1a:1a");
50 - MacAddress serverMac = MacAddress.valueOf("2a:2a:2a:2a:2a:2a");
51 -
52 - // Our session id will be the device ID ("of:1") with the port ("1") concatenated
53 - static final String SESSION_ID = "of:11";
54 -
55 - List<BasePacket> savedPackets = new LinkedList<>();
56 - PacketProcessor packetProcessor;
57 -
58 - /**
59 - * Saves the given packet onto the saved packets list.
60 - *
61 - * @param packet packet to save
62 - */
63 - void savePacket(BasePacket packet) {
64 - savedPackets.add(packet);
65 - }
66 -
67 - /**
68 - * Keeps a reference to the PacketProcessor and saves the OutboundPackets.
69 - */
70 - class MockPacketService extends PacketServiceAdapter {
71 -
72 - @Override
73 - public void addProcessor(PacketProcessor processor, int priority) {
74 - packetProcessor = processor;
75 - }
76 -
77 - @Override
78 - public void emit(OutboundPacket packet) {
79 - try {
80 - Ethernet eth = Ethernet.deserializer().deserialize(packet.data().array(),
81 - 0, packet.data().array().length);
82 - savePacket(eth);
83 - } catch (Exception e) {
84 - fail(e.getMessage());
85 - }
86 - }
87 - }
88 -
89 - /**
90 - * Mocks the DefaultPacketContext.
91 - */
92 - final class TestPacketContext extends DefaultPacketContext {
93 -
94 - private TestPacketContext(long time, InboundPacket inPkt,
95 - OutboundPacket outPkt, boolean block) {
96 - super(time, inPkt, outPkt, block);
97 - }
98 -
99 - @Override
100 - public void send() {
101 - // We don't send anything out.
102 - }
103 - }
104 -
105 - /**
106 - * Sends an Ethernet packet to the process method of the Packet Processor.
107 - *
108 - * @param reply Ethernet packet
109 - */
110 - void sendPacket(Ethernet reply) {
111 - final ByteBuffer byteBuffer = ByteBuffer.wrap(reply.serialize());
112 - InboundPacket inPacket = new DefaultInboundPacket(connectPoint("1", 1),
113 - reply,
114 - byteBuffer);
115 -
116 - PacketContext context = new TestPacketContext(127L, inPacket, null, false);
117 - packetProcessor.process(context);
118 - }
119 -
120 - /**
121 - * Constructs an Ethernet packet containing identification payload.
122 - *
123 - * @return Ethernet packet
124 - */
125 - Ethernet constructSupplicantIdentifyPacket(StateMachine stateMachine,
126 - byte type,
127 - byte id,
128 - Ethernet radiusChallenge)
129 - throws Exception {
130 - Ethernet eth = new Ethernet();
131 - eth.setDestinationMACAddress(clientMac.toBytes());
132 - eth.setSourceMACAddress(serverMac.toBytes());
133 - eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
134 - eth.setVlanID((short) 2);
135 -
136 - String username = "testuser";
137 - byte[] data = username.getBytes();
138 -
139 -
140 - if (type == EAP.ATTR_MD5) {
141 - String password = "testpassword";
142 - EAPOL eapol = (EAPOL) radiusChallenge.getPayload();
143 - EAP eap = (EAP) eapol.getPayload();
144 -
145 - byte[] identifier = new byte[password.length() + eap.getData().length];
146 -
147 - identifier[0] = stateMachine.challengeIdentifier();
148 - System.arraycopy(password.getBytes(), 0, identifier, 1, password.length());
149 - System.arraycopy(eap.getData(), 1, identifier, 1 + password.length(), 16);
150 -
151 - MessageDigest md = MessageDigest.getInstance("MD5");
152 - byte[] hash = md.digest(identifier);
153 - data = new byte[17];
154 - data[0] = (byte) 16;
155 - System.arraycopy(hash, 0, data, 1, 16);
156 - }
157 - EAP eap = new EAP(EAP.RESPONSE, (byte) 1, type,
158 - data);
159 - eap.setIdentifier(id);
160 -
161 - // eapol header
162 - EAPOL eapol = new EAPOL();
163 - eapol.setEapolType(EAPOL.EAPOL_PACKET);
164 - eapol.setPacketLength(eap.getLength());
165 -
166 - // eap part
167 - eapol.setPayload(eap);
168 -
169 - eth.setPayload(eapol);
170 - eth.setPad(true);
171 - return eth;
172 - }
173 -
174 - /**
175 - * Constructs an Ethernet packet containing a EAPOL_START Payload.
176 - *
177 - * @return Ethernet packet
178 - */
179 - Ethernet constructSupplicantStartPacket() {
180 - Ethernet eth = new Ethernet();
181 - eth.setDestinationMACAddress(clientMac.toBytes());
182 - eth.setSourceMACAddress(serverMac.toBytes());
183 - eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
184 - eth.setVlanID((short) 2);
185 -
186 - EAP eap = new EAP(EAPOL.EAPOL_START, (byte) 2, EAPOL.EAPOL_START, null);
187 -
188 - // eapol header
189 - EAPOL eapol = new EAPOL();
190 - eapol.setEapolType(EAPOL.EAPOL_START);
191 - eapol.setPacketLength(eap.getLength());
192 -
193 - // eap part
194 - eapol.setPayload(eap);
195 -
196 - eth.setPayload(eapol);
197 - eth.setPad(true);
198 - return eth;
199 - }
200 -
201 - /**
202 - * Checks the contents of a RADIUS packet being sent to the RADIUS server.
203 - *
204 - * @param radiusPacket packet to check
205 - * @param code expected code
206 - */
207 - void checkRadiusPacket(AaaManager aaaManager, Ethernet radiusPacket, byte code) {
208 -
209 - assertThat(radiusPacket.getSourceMAC(),
210 - is(MacAddress.valueOf(aaaManager.nasMacAddress)));
211 - assertThat(radiusPacket.getDestinationMAC(), is(serverMac));
212 -
213 - assertThat(radiusPacket.getPayload(), instanceOf(EAPOL.class));
214 - EAPOL eapol = (EAPOL) radiusPacket.getPayload();
215 - assertThat(eapol, notNullValue());
216 -
217 - assertThat(eapol.getEapolType(), is(EAPOL.EAPOL_PACKET));
218 - assertThat(eapol.getPayload(), instanceOf(EAP.class));
219 - EAP eap = (EAP) eapol.getPayload();
220 - assertThat(eap, notNullValue());
221 -
222 - assertThat(eap.getCode(), is(code));
223 - }
224 -}
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 = 'CORD Configuration',
11 - category = 'Utility',
12 - url = 'http://onosproject.org',
13 - description = 'CORD configuration meta application.',
14 -)
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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/xsd/maven-4.0.0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.6.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 -
30 - <artifactId>onos-cord-config</artifactId>
31 - <packaging>bundle</packaging>
32 -
33 - <description>Cord configuration meta applications </description>
34 -
35 - <properties>
36 - <onos.app.name>org.onosproject.cord-config</onos.app.name>
37 - <onos.app.title>Cord Configuratuon Meta Application</onos.app.title>
38 - <onos.app.category>Utility</onos.app.category>
39 - <onos.app.url>http://opencord.org</onos.app.url>
40 - </properties>
41 -
42 - <dependencies>
43 - <dependency>
44 - <groupId>org.onosproject</groupId>
45 - <artifactId>onos-api</artifactId>
46 - </dependency>
47 - </dependencies>
48 -
49 -
50 -</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.cordconfig.access;
18 -
19 -import com.fasterxml.jackson.databind.JsonNode;
20 -import com.fasterxml.jackson.databind.node.ObjectNode;
21 -import com.google.common.collect.Iterators;
22 -import com.google.common.collect.Maps;
23 -import org.apache.commons.lang.StringUtils;
24 -import org.onlab.packet.MacAddress;
25 -import org.onosproject.net.ConnectPoint;
26 -import org.onosproject.net.DeviceId;
27 -import org.onosproject.net.PortNumber;
28 -import org.onosproject.net.config.Config;
29 -
30 -import java.util.Map;
31 -import java.util.Optional;
32 -
33 -import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
34 -import static org.onosproject.net.config.Config.FieldPresence.OPTIONAL;
35 -
36 -/**
37 - * Represents configuration for an OLT agent.
38 - */
39 -public class AccessAgentConfig extends Config<DeviceId> {
40 -
41 - private static final String OLTS = "olts";
42 - private static final String AGENT_MAC = "mac";
43 -
44 - // TODO: Remove this, it is only useful as long as XOS doesn't manage this.
45 - private static final String VTN_LOCATION = "vtn-location";
46 -
47 - @Override
48 - public boolean isValid() {
49 - return hasOnlyFields(OLTS, AGENT_MAC, VTN_LOCATION) &&
50 - isMacAddress(AGENT_MAC, MANDATORY) &&
51 - isConnectPoint(VTN_LOCATION, OPTIONAL) &&
52 - isValidOlts();
53 - }
54 -
55 - /**
56 - * Gets the access agent configuration for this device.
57 - *
58 - * @return access agent configuration
59 - */
60 - public AccessAgentData getAgent() {
61 - JsonNode olts = node.get(OLTS);
62 - Map<ConnectPoint, MacAddress> oltMacInfo = Maps.newHashMap();
63 - olts.fields().forEachRemaining(item -> oltMacInfo.put(
64 - new ConnectPoint(subject(), PortNumber.fromString(item.getKey())),
65 - MacAddress.valueOf(item.getValue().asText())));
66 -
67 - MacAddress agentMac = MacAddress.valueOf(node.path(AGENT_MAC).asText());
68 -
69 - JsonNode vtn = node.path(VTN_LOCATION);
70 - Optional<ConnectPoint> vtnLocation;
71 - if (vtn.isMissingNode()) {
72 - vtnLocation = Optional.empty();
73 - } else {
74 - vtnLocation = Optional.of(ConnectPoint.deviceConnectPoint(vtn.asText()));
75 - }
76 -
77 - return new AccessAgentData(subject(), oltMacInfo, agentMac, vtnLocation);
78 - }
79 -
80 - private boolean isValidOlts() {
81 - JsonNode olts = node.get(OLTS);
82 - if (!olts.isObject()) {
83 - return false;
84 - }
85 - return !Iterators.any(olts.fields(), item -> !StringUtils.isNumeric(item.getKey()) ||
86 - !isMacAddress((ObjectNode) olts, item.getKey(), MANDATORY));
87 - }
88 -}
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.cordconfig.access;
18 -
19 -import com.google.common.collect.ImmutableMap;
20 -import org.onlab.packet.MacAddress;
21 -import org.onosproject.net.ConnectPoint;
22 -import org.onosproject.net.DeviceId;
23 -
24 -import java.util.Map;
25 -import java.util.Optional;
26 -
27 -import static com.google.common.base.Preconditions.checkNotNull;
28 -
29 -/**
30 - * Information about an access agent.
31 - */
32 -public class AccessAgentData {
33 - private static final String DEVICE_ID_MISSING = "Device ID cannot be null";
34 - private static final String OLT_INFO_MISSING = "OLT information cannot be null";
35 - private static final String AGENT_MAC_MISSING = "Agent mac cannot be null";
36 - private static final String VTN_MISSING = "VTN location cannot be null";
37 -
38 -
39 - private final Map<ConnectPoint, MacAddress> oltMacInfo;
40 - private final MacAddress agentMac;
41 - private final Optional<ConnectPoint> vtnLocation;
42 - private final DeviceId deviceId;
43 -
44 -
45 - /**
46 - * Constucts an agent configuration for a given device.
47 - *
48 - * @param deviceId access device id
49 - * @param oltMacInfo a map of olt chips and their mac address
50 - * @param agentMac the mac address of the agent
51 - * @param vtnLocation the location of the agent
52 - */
53 - public AccessAgentData(DeviceId deviceId, Map<ConnectPoint, MacAddress> oltMacInfo,
54 - MacAddress agentMac, Optional<ConnectPoint> vtnLocation) {
55 - this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING);
56 - this.oltMacInfo = checkNotNull(oltMacInfo, OLT_INFO_MISSING);
57 - this.agentMac = checkNotNull(agentMac, AGENT_MAC_MISSING);
58 - this.vtnLocation = checkNotNull(vtnLocation, VTN_MISSING);
59 - }
60 -
61 - /**
62 - * Retrieves the access device ID.
63 - *
64 - * @return device ID
65 - */
66 - public DeviceId deviceId() {
67 - return deviceId;
68 - }
69 -
70 - /**
71 - * Returns the mapping of olt chips to mac addresses. Each chip is
72 - * symbolized by a connect point.
73 - *
74 - * @return a mapping of chips (as connect points) to mac addresses
75 - */
76 - public Map<ConnectPoint, MacAddress> getOltMacInfo() {
77 - return ImmutableMap.copyOf(oltMacInfo);
78 - }
79 -
80 - /**
81 - * Reuturns the agents mac address.
82 - *
83 - * @return a mac address
84 - */
85 - public MacAddress getAgentMac() {
86 - return agentMac;
87 - }
88 -
89 - /**
90 - * Returns the location of the agent.
91 - *
92 - * @return a connection point
93 - */
94 - public Optional<ConnectPoint> getVtnLocation() {
95 - return vtnLocation;
96 - }
97 -}
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.cordconfig.access;
18 -
19 -import org.onosproject.net.DeviceId;
20 -import com.fasterxml.jackson.databind.JsonNode;
21 -import org.onlab.packet.VlanId;
22 -
23 -import org.onosproject.net.PortNumber;
24 -import org.onosproject.net.config.Config;
25 -
26 -import java.util.Optional;
27 -
28 -/**
29 - * Config object for access device data.
30 - */
31 -public class AccessDeviceConfig extends Config<DeviceId> {
32 -
33 - private static final String UPLINK = "uplink";
34 - private static final String VLAN = "vlan";
35 - private static final String DEFAULT_VLAN = "defaultVlan";
36 -
37 - /**
38 - * Gets the access device configuration for this device.
39 - *
40 - * @return access device configuration
41 - */
42 - public AccessDeviceData getOlt() {
43 - PortNumber uplink = PortNumber.portNumber(node.path(UPLINK).asText());
44 - VlanId vlan = VlanId.vlanId(Short.parseShort(node.path(VLAN).asText()));
45 - JsonNode defaultVlanNode = node.path(DEFAULT_VLAN);
46 -
47 - Optional<VlanId> defaultVlan;
48 - if (defaultVlanNode.isMissingNode()) {
49 - defaultVlan = Optional.empty();
50 - } else {
51 - defaultVlan = Optional.of(VlanId.vlanId(Short.parseShort(defaultVlanNode.asText())));
52 - }
53 -
54 - return new AccessDeviceData(subject(), uplink, vlan, defaultVlan);
55 - }
56 -}
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.cordconfig.access;
18 -
19 -import org.onlab.packet.VlanId;
20 -import org.onosproject.net.DeviceId;
21 -import org.onosproject.net.PortNumber;
22 -
23 -import java.util.Optional;
24 -
25 -import static com.google.common.base.Preconditions.checkNotNull;
26 -
27 -/**
28 - * Information about an access device.
29 - */
30 -public class AccessDeviceData {
31 - private static final String DEVICE_ID_MISSING = "Device ID cannot be null";
32 - private static final String UPLINK_MISSING = "Uplink cannot be null";
33 - private static final String VLAN_MISSING = "VLAN ID cannot be null";
34 -
35 - private final DeviceId deviceId;
36 - private final PortNumber uplink;
37 - private final VlanId vlan;
38 - private final Optional<VlanId> defaultVlan;
39 -
40 - /**
41 - * Class constructor.
42 - *
43 - * @param deviceId access device ID
44 - * @param uplink uplink port number
45 - * @param vlan device VLAN ID
46 - * @param defaultVlan default device VLAN ID
47 - */
48 - public AccessDeviceData(DeviceId deviceId, PortNumber uplink, VlanId vlan,
49 - Optional<VlanId> defaultVlan) {
50 - this.deviceId = checkNotNull(deviceId, DEVICE_ID_MISSING);
51 - this.uplink = checkNotNull(uplink, UPLINK_MISSING);
52 - this.vlan = checkNotNull(vlan, VLAN_MISSING);
53 - this.defaultVlan = checkNotNull(defaultVlan);
54 - }
55 -
56 - /**
57 - * Retrieves the access device ID.
58 - *
59 - * @return device ID
60 - */
61 - public DeviceId deviceId() {
62 - return deviceId;
63 - }
64 -
65 - /**
66 - * Retrieves the uplink port number.
67 - *
68 - * @return port number
69 - */
70 - public PortNumber uplink() {
71 - return uplink;
72 - }
73 -
74 - /**
75 - * Retrieves the VLAN ID assigned to the device.
76 - *
77 - * @return VLAN ID
78 - */
79 - public VlanId vlan() {
80 - return vlan;
81 - }
82 -
83 - /**
84 - * Retrieves the default VLAN ID that will be used for this device.
85 - *
86 - * @return default VLAN ID
87 - */
88 - public Optional<VlanId> defaultVlan() {
89 - return defaultVlan;
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 -/**
18 - * Meta Application for hosting common cord configuration classes.
19 - */
20 -package org.onosproject.cordconfig.access;
...\ No newline at end of file ...\ No newline at end of file
1 -COMPILE_DEPS = [
2 - '//lib:CORE_DEPS',
3 - '//lib:javax.ws.rs-api',
4 - '//lib:jersey-client',
5 - '//lib:jersey-common',
6 - '//utils/rest:onlab-rest',
7 - '//apps/olt:onos-apps-olt-api',
8 - '//apps/cordconfig:onos-apps-cordconfig',
9 -]
10 -
11 -BUNDLES = [
12 - '//apps/olt:onos-apps-olt-api',
13 - '//apps/cordmcast:onos-apps-cordmcast',
14 -]
15 -
16 -osgi_jar_with_tests (
17 - deps = COMPILE_DEPS,
18 -)
19 -
20 -onos_app (
21 - title = 'CORD Multicast App',
22 - category = 'Traffic Steering',
23 - url = 'http://onosproject.org',
24 - description = 'CORD Multicast application',
25 - included_bundles = BUNDLES,
26 -)
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-apps</artifactId>
25 - <version>1.6.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-cord-mcast</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>CORD Multicast application</description>
33 -
34 - <properties>
35 - <onos.app.name>org.onosproject.cordmcast</onos.app.name>
36 - <onos.app.category>Traffic Steering</onos.app.category>
37 - <onos.app.title>CORD Multicast App</onos.app.title>
38 - <onos.app.url>http://opencord.org</onos.app.url>
39 - <onos.app.requires>org.onosproject.cord-config</onos.app.requires>
40 - </properties>
41 -
42 - <dependencies>
43 - <dependency>
44 - <groupId>org.onosproject</groupId>
45 - <artifactId>onos-cli</artifactId>
46 - <version>${project.version}</version>
47 - </dependency>
48 - <dependency>
49 - <groupId>org.onosproject</groupId>
50 - <artifactId>onos-cord-config</artifactId>
51 - <version>${project.version}</version>
52 - </dependency>
53 - <dependency>
54 - <groupId>org.apache.karaf.shell</groupId>
55 - <artifactId>org.apache.karaf.shell.console</artifactId>
56 - </dependency>
57 - <dependency>
58 - <groupId>com.google.guava</groupId>
59 - <artifactId>guava</artifactId>
60 - </dependency>
61 - <dependency>
62 - <groupId>org.onosproject</groupId>
63 - <artifactId>onlab-misc</artifactId>
64 - </dependency>
65 - <dependency>
66 - <groupId>org.apache.felix</groupId>
67 - <artifactId>org.apache.felix.scr</artifactId>
68 - <version>1.8.2</version>
69 - </dependency>
70 - <dependency>
71 - <groupId>org.osgi</groupId>
72 - <artifactId>org.osgi.compendium</artifactId>
73 - <version>5.0.0</version>
74 - </dependency>
75 - <dependency>
76 - <groupId>org.glassfish.jersey.core</groupId>
77 - <artifactId>jersey-client</artifactId>
78 - <version>2.22.2</version>
79 - </dependency>
80 - <dependency>
81 - <groupId>org.onosproject</groupId>
82 - <artifactId>onos-app-olt-api</artifactId>
83 - <version>${project.version}</version>
84 - </dependency>
85 - </dependencies>
86 -</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 -/**
18 - * Application for provisioning multicast streams in the context of cord.
19 - */
20 -package org.onosproject.cordmcast;
...\ No newline at end of file ...\ No newline at end of file
1 -# app builds but is currently non functional. It needs transitive runtime
2 -# dependencies.
3 -
4 -COMPILE_DEPS = [
5 - '//lib:CORE_DEPS',
6 - '//lib:org.apache.karaf.shell.console',
7 - '//lib:javax.ws.rs-api',
8 - '//lib:jsch',
9 - '//utils/rest:onlab-rest',
10 - '//cli:onos-cli',
11 - '//core/store/serializers:onos-core-serializers',
12 - '//apps/dhcp/api:onos-apps-dhcp-api',
13 - '//apps/xosclient:onos-apps-xosclient',
14 - '//apps/cordconfig:onos-apps-cordconfig',
15 - '//protocols/ovsdb/api:onos-protocols-ovsdb-api',
16 - '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc',
17 -]
18 -
19 -BUNDLES = [
20 - '//apps/cordvtn:onos-apps-cordvtn',
21 -]
22 -
23 -EXCLUDED_BUNDLES = [
24 - '//lib:jsch',
25 -]
26 -
27 -osgi_jar_with_tests (
28 - deps = COMPILE_DEPS,
29 - web_context = '/onos/cordvtn',
30 -)
31 -
32 -onos_app (
33 - title = 'CORD VTN REST API',
34 - category = 'Traffic Steering',
35 - url = 'http://onosproject.org',
36 - included_bundles = BUNDLES,
37 - excluded_bundles = EXCLUDED_BUNDLES,
38 - description = 'APIs for interacting with the CORD VTN application.',
39 - required_apps = [ 'org.onosproject.cord-config', 'org.onosproject.xosclient', 'org.onosproject.dhcp', 'org.onosproject.ovsdb' ],
40 -)
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.cordvtn" origin="ON.Lab" version="${project.version}"
18 - category="Traffic Steering" url="http://onosproject.org" title="CORD Virtual Tenant Network"
19 - featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
20 - features="${project.artifactId}"
21 - apps="org.onosproject.ovsdb-base,org.onosproject.dhcp,org.onosproject.xosclient,org.onosproject.cord-config">
22 - <description>${project.description}</description>
23 - <artifact>mvn:${project.groupId}/onos-app-cordvtn/${project.version}</artifact>
24 -</app>
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 - <feature name="${project.artifactId}" version="${project.version}" description="${project.description}">
19 - <feature>onos-api</feature>
20 - <bundle>mvn:${project.groupId}/onos-app-cordvtn/${project.version}</bundle>
21 - <bundle>wrap:mvn:com.jcraft/jsch/0.1.53$Bundle-SymbolicName=jsch&amp;Bundle-Version=0.1.53</bundle>
22 - </feature>
23 -</features>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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/xsd/maven-4.0.0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.6.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-cordvtn</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>Virtual tenant network service for CORD</description>
33 -
34 - <properties>
35 - <web.context>/onos/cordvtn</web.context>
36 - <api.version>1.0.0</api.version>
37 - <api.title>CORD VTN REST API</api.title>
38 - <api.description>
39 - APIs for interacting with the CORD VTN application.
40 - </api.description>
41 - <api.package>org.onosproject.cordvtn.rest</api.package>
42 - </properties>
43 -
44 - <dependencies>
45 - <dependency>
46 - <groupId>org.osgi</groupId>
47 - <artifactId>org.osgi.compendium</artifactId>
48 - </dependency>
49 - <dependency>
50 - <groupId>org.onosproject</groupId>
51 - <artifactId>onos-api</artifactId>
52 - </dependency>
53 - <dependency>
54 - <groupId>org.onosproject</groupId>
55 - <artifactId>onos-core-serializers</artifactId>
56 - <version>${project.version}</version>
57 - </dependency>
58 - <dependency>
59 - <groupId>org.onosproject</groupId>
60 - <artifactId>onos-ovsdb-api</artifactId>
61 - <version>${project.version}</version>
62 - </dependency>
63 - <dependency>
64 - <groupId>org.onosproject</groupId>
65 - <artifactId>onos-cli</artifactId>
66 - <version>${project.version}</version>
67 - </dependency>
68 - <dependency>
69 - <groupId>org.apache.karaf.shell</groupId>
70 - <artifactId>org.apache.karaf.shell.console</artifactId>
71 - <version>3.0.5</version>
72 - </dependency>
73 - <dependency>
74 - <groupId>org.onosproject</groupId>
75 - <artifactId>onos-rest</artifactId>
76 - <version>${project.version}</version>
77 - </dependency>
78 - <dependency>
79 - <groupId>org.onosproject</groupId>
80 - <artifactId>onlab-rest</artifactId>
81 - <version>${project.version}</version>
82 - </dependency>
83 - <dependency>
84 - <groupId>javax.ws.rs</groupId>
85 - <artifactId>javax.ws.rs-api</artifactId>
86 - <version>2.0.1</version>
87 - </dependency>
88 - <dependency>
89 - <groupId>org.glassfish.jersey.containers</groupId>
90 - <artifactId>jersey-container-servlet</artifactId>
91 - </dependency>
92 - <dependency>
93 - <groupId>com.fasterxml.jackson.core</groupId>
94 - <artifactId>jackson-databind</artifactId>
95 - </dependency>
96 - <dependency>
97 - <groupId>com.fasterxml.jackson.core</groupId>
98 - <artifactId>jackson-annotations</artifactId>
99 - </dependency>
100 - <dependency>
101 - <groupId>org.onosproject</groupId>
102 - <artifactId>onos-app-dhcp-api</artifactId>
103 - <version>${project.version}</version>
104 - </dependency>
105 - <dependency>
106 - <groupId>org.onosproject</groupId>
107 - <artifactId>onos-app-xos-client</artifactId>
108 - <version>${project.version}</version>
109 - </dependency>
110 - <dependency>
111 - <groupId>org.onosproject</groupId>
112 - <artifactId>onos-cord-config</artifactId>
113 - <version>${project.version}</version>
114 - </dependency>
115 - <dependency>
116 - <groupId>com.jcraft</groupId>
117 - <artifactId>jsch</artifactId>
118 - <version>0.1.53</version>
119 - </dependency>
120 - </dependencies>
121 -
122 - <build>
123 - <plugins>
124 - <plugin>
125 - <groupId>org.apache.felix</groupId>
126 - <artifactId>maven-bundle-plugin</artifactId>
127 - <extensions>true</extensions>
128 - <configuration>
129 - <instructions>
130 - <_wab>src/main/webapp/</_wab>
131 - <Include-Resource>
132 - WEB-INF/classes/apidoc/swagger.json=target/swagger.json,
133 - {maven-resources}
134 - </Include-Resource>
135 - <Bundle-SymbolicName>
136 - ${project.groupId}.${project.artifactId}
137 - </Bundle-SymbolicName>
138 - <Import-Package>
139 - *,org.glassfish.jersey.servlet
140 - </Import-Package>
141 - <Web-ContextPath>${web.context}</Web-ContextPath>
142 - </instructions>
143 - </configuration>
144 - </plugin>
145 - </plugins>
146 - </build>
147 -
148 -</project>
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 -package org.onosproject.cordvtn.api;
17 -
18 -/**
19 - * Entity capable of handling a subject connected and disconnected situation.
20 - */
21 -public interface ConnectionHandler<T> {
22 -
23 - /**
24 - * Processes the connected subject.
25 - *
26 - * @param subject subject
27 - */
28 - void connected(T subject);
29 -
30 - /**
31 - * Processes the disconnected subject.
32 - *
33 - * @param subject subject.
34 - */
35 - void disconnected(T subject);
36 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -import com.google.common.collect.Maps;
20 -import com.google.common.collect.Sets;
21 -import org.onlab.packet.Ip4Address;
22 -import org.onlab.packet.IpAddress;
23 -import org.onlab.packet.IpPrefix;
24 -import org.onlab.packet.MacAddress;
25 -import org.onlab.packet.TpPort;
26 -import org.onosproject.core.ApplicationId;
27 -import org.onosproject.net.DeviceId;
28 -import org.onosproject.net.config.Config;
29 -import org.onosproject.xosclient.api.OpenStackAccess;
30 -import org.onosproject.xosclient.api.XosAccess;
31 -import org.slf4j.Logger;
32 -
33 -import java.util.Map;
34 -import java.util.Set;
35 -
36 -import static org.slf4j.LoggerFactory.getLogger;
37 -
38 -/**
39 - * Configuration object for CordVtn service.
40 - */
41 -public class CordVtnConfig extends Config<ApplicationId> {
42 -
43 - protected final Logger log = getLogger(getClass());
44 -
45 - public static final String PRIVATE_GATEWAY_MAC = "privateGatewayMac";
46 - public static final String PUBLIC_GATEWAYS = "publicGateways";
47 - public static final String GATEWAY_IP = "gatewayIp";
48 - public static final String GATEWAY_MAC = "gatewayMac";
49 - public static final String LOCAL_MANAGEMENT_IP = "localManagementIp";
50 - public static final String MANAGEMENT_IP = "managementIpRange";
51 - public static final String OVSDB_PORT = "ovsdbPort";
52 -
53 - public static final String CORDVTN_NODES = "nodes";
54 - public static final String HOSTNAME = "hostname";
55 - public static final String HOST_MANAGEMENT_IP = "hostManagementIp";
56 - public static final String DATA_PLANE_IP = "dataPlaneIp";
57 - public static final String DATA_PLANE_INTF = "dataPlaneIntf";
58 - public static final String BRIDGE_ID = "bridgeId";
59 -
60 - public static final String SSH = "ssh";
61 - public static final String SSH_PORT = "sshPort";
62 - public static final String SSH_USER = "sshUser";
63 - public static final String SSH_KEY_FILE = "sshKeyFile";
64 -
65 - public static final String OPENSTACK = "openstack";
66 - public static final String XOS = "xos";
67 -
68 - public static final String ENDPOINT = "endpoint";
69 - public static final String TENANT = "tenant";
70 - public static final String USER = "user";
71 - public static final String PASSWORD = "password";
72 -
73 - /**
74 - * Returns the set of nodes read from network config.
75 - *
76 - * @return set of CordVtnNodeConfig or empty set
77 - */
78 - public Set<CordVtnNode> cordVtnNodes() {
79 -
80 - Set<CordVtnNode> nodes = Sets.newHashSet();
81 -
82 - JsonNode cordvtnNodes = object.get(CORDVTN_NODES);
83 - if (cordvtnNodes == null) {
84 - log.debug("No CORD VTN nodes found");
85 - return nodes;
86 - }
87 -
88 - JsonNode sshNode = object.get(SSH);
89 - if (sshNode == null) {
90 - log.warn("SSH information not found");
91 - return nodes;
92 - }
93 -
94 - for (JsonNode cordvtnNode : cordvtnNodes) {
95 - try {
96 - NetworkAddress hostMgmt = NetworkAddress.valueOf(getConfig(cordvtnNode, HOST_MANAGEMENT_IP));
97 - NetworkAddress localMgmt = NetworkAddress.valueOf(getConfig(object, LOCAL_MANAGEMENT_IP));
98 - if (hostMgmt.prefix().contains(localMgmt.prefix()) ||
99 - localMgmt.prefix().contains(hostMgmt.prefix())) {
100 - log.error("hostMamt and localMgmt cannot be overlapped, skip this node");
101 - continue;
102 - }
103 -
104 - Ip4Address hostMgmtIp = hostMgmt.ip().getIp4Address();
105 - SshAccessInfo sshInfo = new SshAccessInfo(
106 - hostMgmtIp,
107 - TpPort.tpPort(Integer.parseInt(getConfig(sshNode, SSH_PORT))),
108 - getConfig(sshNode, SSH_USER), getConfig(sshNode, SSH_KEY_FILE));
109 -
110 - String hostname = getConfig(cordvtnNode, HOSTNAME);
111 - CordVtnNode newNode = new CordVtnNode(
112 - hostname, hostMgmt, localMgmt,
113 - NetworkAddress.valueOf(getConfig(cordvtnNode, DATA_PLANE_IP)),
114 - TpPort.tpPort(Integer.parseInt(getConfig(object, OVSDB_PORT))),
115 - sshInfo,
116 - DeviceId.deviceId(getConfig(cordvtnNode, BRIDGE_ID)),
117 - getConfig(cordvtnNode, DATA_PLANE_INTF),
118 - CordVtnNodeState.noState());
119 -
120 - nodes.add(newNode);
121 - } catch (IllegalArgumentException | NullPointerException e) {
122 - log.error("{}", e);
123 - }
124 - }
125 -
126 - return nodes;
127 - }
128 -
129 - /**
130 - * Returns value of a given path. If the path is missing, show log and return
131 - * null.
132 - *
133 - * @param path path
134 - * @return value or null
135 - */
136 - private String getConfig(JsonNode jsonNode, String path) {
137 - jsonNode = jsonNode.path(path);
138 -
139 - if (jsonNode.isMissingNode()) {
140 - log.error("{} is not configured", path);
141 - return null;
142 - } else {
143 - return jsonNode.asText();
144 - }
145 - }
146 -
147 - /**
148 - * Returns private network gateway MAC address.
149 - *
150 - * @return mac address, or null
151 - */
152 - public MacAddress privateGatewayMac() {
153 - JsonNode jsonNode = object.get(PRIVATE_GATEWAY_MAC);
154 - if (jsonNode == null) {
155 - return null;
156 - }
157 -
158 - try {
159 - return MacAddress.valueOf(jsonNode.asText());
160 - } catch (IllegalArgumentException e) {
161 - log.error("Wrong MAC address format {}", jsonNode.asText());
162 - return null;
163 - }
164 - }
165 -
166 - /**
167 - * Returns public network gateway IP and MAC address pairs.
168 - *
169 - * @return map of ip and mac address
170 - */
171 - public Map<IpAddress, MacAddress> publicGateways() {
172 - JsonNode jsonNodes = object.get(PUBLIC_GATEWAYS);
173 - if (jsonNodes == null) {
174 - return Maps.newHashMap();
175 - }
176 -
177 - Map<IpAddress, MacAddress> publicGateways = Maps.newHashMap();
178 - jsonNodes.forEach(jsonNode -> {
179 - try {
180 - publicGateways.put(
181 - IpAddress.valueOf(jsonNode.path(GATEWAY_IP).asText()),
182 - MacAddress.valueOf(jsonNode.path(GATEWAY_MAC).asText()));
183 - } catch (IllegalArgumentException | NullPointerException e) {
184 - log.error("Wrong address format {}", e.toString());
185 - }
186 - });
187 -
188 - return publicGateways;
189 - }
190 -
191 - /**
192 - * Returns management IP address range.
193 - *
194 - * @return management network ip prefix, or null
195 - */
196 - public IpPrefix managementIpRange() {
197 - JsonNode jsonNode = object.get(MANAGEMENT_IP);
198 - if (jsonNode == null) {
199 - return null;
200 - }
201 -
202 - try {
203 - return IpPrefix.valueOf(jsonNode.asText());
204 - } catch (IllegalArgumentException e) {
205 - log.error("{}:{} wrong address format", MANAGEMENT_IP, jsonNode);
206 - return null;
207 - }
208 - }
209 -
210 - /**
211 - * Returns XOS access information.
212 - *
213 - * @return XOS access, or null
214 - */
215 - public XosAccess xosAccess() {
216 - JsonNode jsonNode = object.get(XOS);
217 - if (jsonNode == null) {
218 - return null;
219 - }
220 -
221 - try {
222 - return new XosAccess(getConfig(jsonNode, ENDPOINT),
223 - getConfig(jsonNode, USER),
224 - getConfig(jsonNode, PASSWORD));
225 - } catch (NullPointerException e) {
226 - log.error("Failed to get XOS access");
227 - return null;
228 - }
229 - }
230 -
231 - /**
232 - * Returns OpenStack API access information.
233 - *
234 - * @return openstack access
235 - */
236 - public OpenStackAccess openstackAccess() {
237 - JsonNode jsonNode = object.get(OPENSTACK);
238 - if (jsonNode == null) {
239 - log.error("Failed to get OpenStack configurations");
240 - return null;
241 - }
242 -
243 - try {
244 - return new OpenStackAccess(
245 - jsonNode.path(ENDPOINT).asText(),
246 - jsonNode.path(TENANT).asText(),
247 - jsonNode.path(USER).asText(),
248 - jsonNode.path(PASSWORD).asText());
249 - } catch (IllegalArgumentException | NullPointerException e) {
250 - log.error("Failed to get OpenStack configurations");
251 - return null;
252 - }
253 - }
254 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import com.google.common.base.MoreObjects;
19 -import org.onlab.packet.TpPort;
20 -import org.onosproject.net.DeviceId;
21 -
22 -import java.util.Comparator;
23 -import java.util.Objects;
24 -
25 -import static com.google.common.base.Preconditions.checkNotNull;
26 -
27 -/**
28 - * Representation of a compute infrastructure node for CORD VTN service.
29 - */
30 -public final class CordVtnNode {
31 -
32 - private final String hostname;
33 - private final NetworkAddress hostMgmtIp;
34 - private final NetworkAddress localMgmtIp;
35 - private final NetworkAddress dpIp;
36 - private final TpPort ovsdbPort;
37 - private final SshAccessInfo sshInfo;
38 - private final DeviceId bridgeId;
39 - private final String dpIntf;
40 - private final CordVtnNodeState state;
41 -
42 - public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR =
43 - (node1, node2) -> node1.hostname().compareTo(node2.hostname());
44 -
45 - /**
46 - * Creates a new node.
47 - *
48 - * @param hostname hostname
49 - * @param hostMgmtIp host management network address
50 - * @param localMgmtIp local management network address
51 - * @param dpIp data plane network address
52 - * @param ovsdbPort port number for OVSDB connection
53 - * @param sshInfo SSH access information
54 - * @param bridgeId integration bridge identifier
55 - * @param dpIntf data plane interface name
56 - * @param state cordvtn node state
57 - */
58 - public CordVtnNode(String hostname, NetworkAddress hostMgmtIp, NetworkAddress localMgmtIp,
59 - NetworkAddress dpIp, TpPort ovsdbPort, SshAccessInfo sshInfo,
60 - DeviceId bridgeId, String dpIntf, CordVtnNodeState state) {
61 - this.hostname = checkNotNull(hostname, "hostname cannot be null");
62 - this.hostMgmtIp = checkNotNull(hostMgmtIp, "hostMgmtIp cannot be null");
63 - this.localMgmtIp = checkNotNull(localMgmtIp, "localMgmtIp cannot be null");
64 - this.dpIp = checkNotNull(dpIp, "dpIp cannot be null");
65 - this.ovsdbPort = checkNotNull(ovsdbPort, "ovsdbPort cannot be null");
66 - this.sshInfo = checkNotNull(sshInfo, "sshInfo cannot be null");
67 - this.bridgeId = checkNotNull(bridgeId, "bridgeId cannot be null");
68 - this.dpIntf = checkNotNull(dpIntf, "dpIntf cannot be null");
69 - this.state = state;
70 - }
71 -
72 - /**
73 - * Returns cordvtn node with new state.
74 - *
75 - * @param node cordvtn node
76 - * @param state cordvtn node init state
77 - * @return cordvtn node
78 - */
79 - public static CordVtnNode getUpdatedNode(CordVtnNode node, CordVtnNodeState state) {
80 - return new CordVtnNode(node.hostname,
81 - node.hostMgmtIp, node.localMgmtIp, node.dpIp,
82 - node.ovsdbPort,
83 - node.sshInfo,
84 - node.bridgeId,
85 - node.dpIntf, state);
86 - }
87 -
88 - /**
89 - * Returns the hostname.
90 - *
91 - * @return hostname
92 - */
93 - public String hostname() {
94 - return this.hostname;
95 - }
96 -
97 - /**
98 - * Returns the host management network address.
99 - *
100 - * @return network address
101 - */
102 - public NetworkAddress hostMgmtIp() {
103 - return this.hostMgmtIp;
104 - }
105 -
106 - /**
107 - * Returns the local management network address.
108 - *
109 - * @return network address
110 - */
111 - public NetworkAddress localMgmtIp() {
112 - return this.localMgmtIp;
113 - }
114 -
115 - /**
116 - * Returns the data plane network address.
117 - *
118 - * @return network address
119 - */
120 - public NetworkAddress dpIp() {
121 - return this.dpIp;
122 - }
123 -
124 - /**
125 - * Returns the port number used for OVSDB connection.
126 - *
127 - * @return port number
128 - */
129 - public TpPort ovsdbPort() {
130 - return this.ovsdbPort;
131 - }
132 -
133 - /**
134 - * Returns the SSH access information.
135 - *
136 - * @return ssh access information
137 - */
138 - public SshAccessInfo sshInfo() {
139 - return this.sshInfo;
140 - }
141 -
142 - /**
143 - * Returns the identifier of the integration bridge.
144 - *
145 - * @return device id
146 - */
147 - public DeviceId intBrId() {
148 - return this.bridgeId;
149 - }
150 -
151 - /**
152 - * Returns the identifier of the OVSDB device.
153 - *
154 - * @return device id
155 - */
156 - public DeviceId ovsdbId() {
157 - return DeviceId.deviceId("ovsdb:" + this.hostMgmtIp.ip().toString());
158 - }
159 -
160 - /**
161 - * Returns data plane interface name.
162 - *
163 - * @return data plane interface name
164 - */
165 - public String dpIntf() {
166 - return this.dpIntf;
167 - }
168 -
169 - /**
170 - * Returns the state of the node.
171 - *
172 - * @return state
173 - */
174 - public CordVtnNodeState state() {
175 - return this.state;
176 - }
177 -
178 - @Override
179 - public boolean equals(Object obj) {
180 - if (this == obj) {
181 - return true;
182 - }
183 -
184 - if (obj instanceof CordVtnNode) {
185 - CordVtnNode that = (CordVtnNode) obj;
186 - if (Objects.equals(hostname, that.hostname) &&
187 - Objects.equals(hostMgmtIp, that.hostMgmtIp) &&
188 - Objects.equals(localMgmtIp, that.localMgmtIp) &&
189 - Objects.equals(dpIp, that.dpIp) &&
190 - Objects.equals(ovsdbPort, that.ovsdbPort) &&
191 - Objects.equals(sshInfo, that.sshInfo) &&
192 - Objects.equals(bridgeId, that.bridgeId) &&
193 - Objects.equals(dpIntf, that.dpIntf)) {
194 - return true;
195 - }
196 - }
197 - return false;
198 - }
199 -
200 - @Override
201 - public int hashCode() {
202 - return Objects.hash(hostname, hostMgmtIp, localMgmtIp, dpIp,
203 - ovsdbPort, sshInfo, bridgeId, dpIntf);
204 - }
205 -
206 - @Override
207 - public String toString() {
208 - return MoreObjects.toStringHelper(getClass())
209 - .add("hostname", hostname)
210 - .add("hostMgmtIp", hostMgmtIp)
211 - .add("localMgmtIp", localMgmtIp)
212 - .add("dpIp", dpIp)
213 - .add("port", ovsdbPort)
214 - .add("sshInfo", sshInfo)
215 - .add("bridgeId", bridgeId)
216 - .add("dpIntf", dpIntf)
217 - .add("state", state)
218 - .toString();
219 - }
220 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -/**
19 - * Entity that defines possible init state of the cordvtn node.
20 - */
21 -public interface CordVtnNodeState {
22 - /**
23 - * Returns null for no state.
24 - *
25 - * @return null
26 - */
27 - static CordVtnNodeState noState() {
28 - return null;
29 - }
30 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import org.onosproject.xosclient.api.VtnServiceId;
19 -
20 -/**
21 - * Service for provisioning overlay virtual networks on compute nodes.
22 - */
23 -public interface CordVtnService {
24 -
25 - String CORDVTN_APP_ID = "org.onosproject.cordvtn";
26 -
27 - /**
28 - * Creates dependencies for a given tenant service.
29 - *
30 - * @param tServiceId id of the service which has a dependency
31 - * @param pServiceId id of the service which provide dependency
32 - * @param isBidirectional true to enable bidirectional connectivity between two services
33 - */
34 - void createServiceDependency(VtnServiceId tServiceId, VtnServiceId pServiceId,
35 - boolean isBidirectional);
36 -
37 - /**
38 - * Removes all dependencies from a given tenant service.
39 - *
40 - * @param tServiceId id of the service which has a dependency
41 - * @param pServiceId id of the service which provide dependency
42 - */
43 - void removeServiceDependency(VtnServiceId tServiceId, VtnServiceId pServiceId);
44 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import com.google.common.base.Strings;
19 -import org.onlab.packet.Ip4Address;
20 -import org.onlab.packet.MacAddress;
21 -import org.onosproject.net.DeviceId;
22 -import org.onosproject.net.Host;
23 -import org.onosproject.net.PortNumber;
24 -import org.onosproject.xosclient.api.VtnPortId;
25 -import org.onosproject.xosclient.api.VtnService;
26 -import org.onosproject.xosclient.api.VtnServiceId;
27 -
28 -import static com.google.common.base.Preconditions.checkArgument;
29 -import static com.google.common.base.Preconditions.checkNotNull;
30 -
31 -/**
32 - * Provides methods to help to handle network service instance.
33 - */
34 -public final class Instance {
35 -
36 - public static final String SERVICE_ID = "serviceId";
37 - public static final String SERVICE_TYPE = "serviceType";
38 - public static final String PORT_ID = "vtnPortId";
39 - public static final String CREATE_TIME = "createTime";
40 - public static final String NESTED_INSTANCE = "nestedInstance";
41 - public static final String TRUE = "true";
42 -
43 - private final Host host;
44 -
45 - /**
46 - * Default constructor.
47 - *
48 - * @param instance host object of this instance
49 - */
50 - private Instance(Host instance) {
51 - this.host = instance;
52 - }
53 -
54 - /**
55 - * Returns host object of this instance.
56 - *
57 - * @return host
58 - */
59 - public Host host() {
60 - return this.host;
61 - }
62 -
63 - /**
64 - * Returns new instance.
65 - *
66 - * @param host host object of this instance
67 - * @return instance
68 - */
69 - public static Instance of(Host host) {
70 - checkNotNull(host);
71 - checkArgument(!Strings.isNullOrEmpty(host.annotations().value(SERVICE_ID)));
72 - checkArgument(!Strings.isNullOrEmpty(host.annotations().value(SERVICE_TYPE)));
73 - checkArgument(!Strings.isNullOrEmpty(host.annotations().value(PORT_ID)));
74 - checkArgument(!Strings.isNullOrEmpty(host.annotations().value(CREATE_TIME)));
75 -
76 - return new Instance(host);
77 - }
78 -
79 - /**
80 - * Returns service ID of a given host.
81 - *
82 - * @return vtn service id
83 - */
84 - public VtnServiceId serviceId() {
85 - String serviceId = host.annotations().value(SERVICE_ID);
86 - return VtnServiceId.of(serviceId);
87 - }
88 -
89 - /**
90 - * Returns service type of a given host.
91 - *
92 - * @return vtn service type
93 - */
94 - public VtnService.ServiceType serviceType() {
95 - String serviceType = host.annotations().value(SERVICE_TYPE);
96 - return VtnService.ServiceType.valueOf(serviceType);
97 - }
98 -
99 - /**
100 - * Returns port ID of a given host.
101 - *
102 - * @return vtn port id
103 - */
104 - public VtnPortId portId() {
105 - String portId = host.annotations().value(PORT_ID);
106 - return VtnPortId.of(portId);
107 - }
108 -
109 - /**
110 - * Returns if the instance is nested container or not.
111 - *
112 - * @return true if it's nested container; false otherwise
113 - */
114 - public boolean isNestedInstance() {
115 - return host.annotations().value(NESTED_INSTANCE) != null;
116 - }
117 -
118 - /**
119 - * Returns MAC address of this instance.
120 - *
121 - * @return mac address
122 - */
123 - public MacAddress mac() {
124 - return host.mac();
125 - }
126 -
127 - /**
128 - * Returns IP address of this instance.
129 - *
130 - * @return ip address
131 - */
132 - public Ip4Address ipAddress() {
133 - // assume all instance has only one IP address, and only IP4 is supported now
134 - return host.ipAddresses().stream().findFirst().get().getIp4Address();
135 - }
136 -
137 - /**
138 - * Returns device ID of this host.
139 - *
140 - * @return device id
141 - */
142 - public DeviceId deviceId() {
143 - return host.location().deviceId();
144 - }
145 -
146 - /**
147 - * Returns the port number where this host is.
148 - *
149 - * @return port number
150 - */
151 - public PortNumber portNumber() {
152 - return host.location().port();
153 - }
154 -
155 - /**
156 - * Returns annotation value with a given key.
157 - *
158 - * @param annotationKey annotation key
159 - * @return annotation value
160 - */
161 - public String getAnnotation(String annotationKey) {
162 - return host.annotations().value(annotationKey);
163 - }
164 -
165 - @Override
166 - public String toString() {
167 - return host.toString();
168 - }
169 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -/**
19 - * Handles service instance detection and removal.
20 - */
21 -public interface InstanceHandler {
22 -
23 - /**
24 - * Handles newly detected instance.
25 - *
26 - * @param instance instance
27 - */
28 - void instanceDetected(Instance instance);
29 -
30 - /**
31 - * Handles removed instance.
32 - *
33 - * @param instance instance
34 - */
35 - void instanceRemoved(Instance instance);
36 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import com.google.common.base.MoreObjects;
19 -import org.onlab.packet.IpAddress;
20 -import org.onlab.packet.IpPrefix;
21 -
22 -import java.util.Objects;
23 -
24 -import static com.google.common.base.Preconditions.checkArgument;
25 -
26 -/**
27 - * Representation of a network address, which consists of IP address and prefix.
28 - */
29 -public final class NetworkAddress {
30 - private final IpAddress ip;
31 - private final IpPrefix prefix;
32 -
33 - /**
34 - * Constructor for a given IP address and prefix.
35 - *
36 - * @param ip ip address
37 - * @param prefix ip prefix
38 - */
39 - public NetworkAddress(IpAddress ip, IpPrefix prefix) {
40 - this.ip = ip;
41 - this.prefix = prefix;
42 - }
43 -
44 - /**
45 - * Converts a CIDR notation string into a network address.
46 - *
47 - * @param cidr cidr
48 - * @return network address
49 - * @throws IllegalArgumentException if the cidr is not valid
50 - */
51 - public static NetworkAddress valueOf(String cidr) {
52 - checkArgument(cidr.contains("/"));
53 -
54 - IpAddress ipAddress = IpAddress.valueOf(cidr.split("/")[0]);
55 - IpPrefix ipPrefix = IpPrefix.valueOf(cidr);
56 -
57 - return new NetworkAddress(ipAddress, ipPrefix);
58 - }
59 -
60 - /**
61 - * Returns the IP address value of the network address.
62 - *
63 - * @return ip address
64 - */
65 - public IpAddress ip() {
66 - return this.ip;
67 - }
68 -
69 - /**
70 - * Returns the IP prefix value of the network address.
71 - *
72 - * @return ip prefix
73 - */
74 - public IpPrefix prefix() {
75 - return this.prefix;
76 - }
77 -
78 - /**
79 - * Converts a network address to a CIDR notation.
80 - *
81 - * @return cidr notation string
82 - */
83 - public String cidr() {
84 - return ip.toString() + "/" + prefix.prefixLength();
85 - }
86 -
87 - @Override
88 - public boolean equals(Object obj) {
89 - if (this == obj) {
90 - return true;
91 - }
92 -
93 - if (obj instanceof NetworkAddress) {
94 - NetworkAddress that = (NetworkAddress) obj;
95 - if (Objects.equals(ip, that.ip) && Objects.equals(prefix, that.prefix)) {
96 - return true;
97 - }
98 - }
99 - return false;
100 - }
101 -
102 - @Override
103 - public int hashCode() {
104 - return Objects.hash(ip, prefix);
105 - }
106 -
107 - @Override
108 - public String toString() {
109 - return MoreObjects.toStringHelper(getClass())
110 - .add("IpAddress", ip)
111 - .add("IpPrefix", prefix)
112 - .toString();
113 - }
114 -}
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 -package org.onosproject.cordvtn.api;
17 -
18 -import com.google.common.base.MoreObjects;
19 -import org.onlab.packet.Ip4Address;
20 -import org.onlab.packet.TpPort;
21 -
22 -import java.util.Objects;
23 -
24 -import static com.google.common.base.Preconditions.checkNotNull;
25 -
26 -/**
27 - * Representation of SSH access information.
28 - */
29 -public final class SshAccessInfo {
30 -
31 - private final Ip4Address remoteIp;
32 - private final TpPort port;
33 - private final String user;
34 - private final String privateKey;
35 -
36 - /**
37 - * Creates a new SSH access information.
38 - *
39 - * @param remoteIp ssh remote ip address
40 - * @param port ssh port number
41 - * @param user user name
42 - * @param privateKey path of ssh private key
43 - */
44 - public SshAccessInfo(Ip4Address remoteIp, TpPort port, String user, String privateKey) {
45 - this.remoteIp = checkNotNull(remoteIp);
46 - this.port = checkNotNull(port);
47 - this.user = checkNotNull(user);
48 - this.privateKey = checkNotNull(privateKey);
49 - }
50 -
51 - /**
52 - * Returns the remote IP address.
53 - *
54 - * @return ip address
55 - */
56 - public Ip4Address remoteIp() {
57 - return this.remoteIp;
58 - }
59 -
60 - /**
61 - * Returns the port number.
62 - *
63 - * @return ssh port
64 - */
65 - public TpPort port() {
66 - return this.port;
67 - }
68 -
69 - /**
70 - * Returns the user name.
71 - *
72 - * @return user name
73 - */
74 - public String user() {
75 - return this.user;
76 - }
77 -
78 - /**
79 - * Returns the private key path.
80 - *
81 - * @return privateKey
82 - */
83 - public String privateKey() {
84 - return privateKey;
85 - }
86 -
87 - @Override
88 - public boolean equals(Object obj) {
89 - if (this == obj) {
90 - return true;
91 - }
92 -
93 - if (obj instanceof SshAccessInfo) {
94 - SshAccessInfo that = (SshAccessInfo) obj;
95 - if (Objects.equals(remoteIp, that.remoteIp) &&
96 - Objects.equals(port, that.port) &&
97 - Objects.equals(user, that.user) &&
98 - Objects.equals(privateKey, that.privateKey)) {
99 - return true;
100 - }
101 - }
102 - return false;
103 - }
104 -
105 - @Override
106 - public int hashCode() {
107 - return Objects.hash(remoteIp, port, user, privateKey);
108 - }
109 -
110 - @Override
111 - public String toString() {
112 - return MoreObjects.toStringHelper(getClass())
113 - .add("remoteIp", remoteIp)
114 - .add("port", port)
115 - .add("user", user)
116 - .add("privateKey", privateKey)
117 - .toString();
118 - }
119 -}
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 - * API for CORD VTN application.
19 - */
20 -package org.onosproject.cordvtn.api;
...\ 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.cordvtn.cli;
18 -
19 -import org.apache.karaf.shell.commands.Command;
20 -import org.onosproject.cli.AbstractShellCommand;
21 -import org.onosproject.cordvtn.impl.CordVtnPipeline;
22 -
23 -/**
24 - * Deletes nodes from the service.
25 - */
26 -@Command(scope = "onos", name = "cordvtn-flush-rules",
27 - description = "Flush flow rules installed by CORD VTN")
28 -public class CordVtnFlushRules extends AbstractShellCommand {
29 -
30 - @Override
31 - protected void execute() {
32 - CordVtnPipeline pipeline = AbstractShellCommand.get(CordVtnPipeline.class);
33 - pipeline.flushRules();
34 - print("Successfully flushed");
35 - }
36 -}
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.cordvtn.cli;
18 -
19 -import org.apache.karaf.shell.commands.Argument;
20 -import org.apache.karaf.shell.commands.Command;
21 -import org.onosproject.cli.AbstractShellCommand;
22 -import org.onosproject.cordvtn.api.CordVtnNode;
23 -import org.onosproject.cordvtn.impl.CordVtnNodeManager;
24 -import org.onosproject.net.Device;
25 -import org.onosproject.net.device.DeviceService;
26 -import org.onosproject.net.driver.DriverService;
27 -
28 -/**
29 - * Checks detailed node init state.
30 - */
31 -@Command(scope = "onos", name = "cordvtn-node-check",
32 - description = "Shows detailed node init state")
33 -public class CordVtnNodeCheckCommand extends AbstractShellCommand {
34 -
35 - @Argument(index = 0, name = "hostname", description = "Hostname",
36 - required = true, multiValued = false)
37 - private String hostname = null;
38 -
39 - @Override
40 - protected void execute() {
41 - CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class);
42 - DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
43 -
44 - CordVtnNode node = nodeManager.getNodes()
45 - .stream()
46 - .filter(n -> n.hostname().equals(hostname))
47 - .findFirst()
48 - .orElse(null);
49 -
50 - if (node == null) {
51 - print("Cannot find %s from registered nodes", hostname);
52 - return;
53 - }
54 -
55 - print(nodeManager.checkNodeInitState(node));
56 -
57 - print("%n[DEBUG]");
58 - Device device = deviceService.getDevice(node.intBrId());
59 - String driver = get(DriverService.class).getDriver(device.id()).name();
60 - print("%s available=%s driver=%s %s",
61 - device.id(),
62 - deviceService.isAvailable(device.id()),
63 - driver,
64 - device.annotations());
65 -
66 - deviceService.getPorts(node.intBrId()).forEach(port -> {
67 - Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled";
68 - print("port=%s state=%s %s",
69 - port.number(),
70 - portIsEnabled,
71 - port.annotations());
72 - });
73 - }
74 -}
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.cordvtn.cli;
18 -
19 -import org.apache.karaf.shell.commands.Argument;
20 -import org.apache.karaf.shell.commands.Command;
21 -import org.onosproject.cli.AbstractShellCommand;
22 -import org.onosproject.cordvtn.impl.CordVtnNodeManager;
23 -import org.onosproject.cordvtn.api.CordVtnNode;
24 -
25 -import java.util.NoSuchElementException;
26 -
27 -/**
28 - * Deletes nodes from the service.
29 - */
30 -@Command(scope = "onos", name = "cordvtn-node-delete",
31 - description = "Deletes nodes from CORD VTN service")
32 -public class CordVtnNodeDeleteCommand extends AbstractShellCommand {
33 -
34 - @Argument(index = 0, name = "hostnames", description = "Hostname(s)",
35 - required = true, multiValued = true)
36 - private String[] hostnames = null;
37 -
38 - @Override
39 - protected void execute() {
40 - CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class);
41 -
42 - for (String hostname : hostnames) {
43 - CordVtnNode node;
44 - try {
45 - node = nodeManager.getNodes()
46 - .stream()
47 - .filter(n -> n.hostname().equals(hostname))
48 - .findFirst().get();
49 - } catch (NoSuchElementException e) {
50 - print("Unable to find %s", hostname);
51 - continue;
52 - }
53 -
54 - nodeManager.deleteNode(node);
55 - }
56 - }
57 -}
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.cordvtn.cli;
18 -
19 -import org.apache.karaf.shell.commands.Argument;
20 -import org.apache.karaf.shell.commands.Command;
21 -import org.onosproject.cli.AbstractShellCommand;
22 -import org.onosproject.cordvtn.impl.CordVtnNodeManager;
23 -import org.onosproject.cordvtn.api.CordVtnNode;
24 -
25 -import java.util.NoSuchElementException;
26 -
27 -/**
28 - * Initializes nodes for CordVtn service.
29 - */
30 -@Command(scope = "onos", name = "cordvtn-node-init",
31 - description = "Initializes nodes for CORD VTN service")
32 -public class CordVtnNodeInitCommand extends AbstractShellCommand {
33 -
34 - @Argument(index = 0, name = "hostnames", description = "Hostname(s)",
35 - required = true, multiValued = true)
36 - private String[] hostnames = null;
37 -
38 - @Override
39 - protected void execute() {
40 - CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class);
41 -
42 - for (String hostname : hostnames) {
43 - CordVtnNode node;
44 - try {
45 - node = nodeManager.getNodes()
46 - .stream()
47 - .filter(n -> n.hostname().equals(hostname))
48 - .findFirst().get();
49 - } catch (NoSuchElementException e) {
50 - print("Unable to find %s", hostname);
51 - continue;
52 - }
53 -
54 - nodeManager.addOrUpdateNode(node);
55 - }
56 - }
57 -}
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.cordvtn.cli;
18 -
19 -import com.fasterxml.jackson.databind.JsonNode;
20 -import com.fasterxml.jackson.databind.ObjectMapper;
21 -import com.fasterxml.jackson.databind.node.ArrayNode;
22 -import org.apache.karaf.shell.commands.Command;
23 -import org.onosproject.cli.AbstractShellCommand;
24 -import org.onosproject.cordvtn.impl.CordVtnNodeManager;
25 -import org.onosproject.cordvtn.api.CordVtnNode;
26 -
27 -import java.util.Collections;
28 -import java.util.List;
29 -
30 -/**
31 - * Lists all nodes registered to the service.
32 - */
33 -@Command(scope = "onos", name = "cordvtn-nodes",
34 - description = "Lists all nodes registered in CORD VTN service")
35 -public class CordVtnNodeListCommand extends AbstractShellCommand {
36 -
37 - private static final String COMPLETE = "COMPLETE";
38 - private static final String INCOMPLETE = "INCOMPLETE";
39 -
40 - @Override
41 - protected void execute() {
42 - CordVtnNodeManager nodeManager = AbstractShellCommand.get(CordVtnNodeManager.class);
43 - List<CordVtnNode> nodes = nodeManager.getNodes();
44 - Collections.sort(nodes, CordVtnNode.CORDVTN_NODE_COMPARATOR);
45 -
46 - if (outputJson()) {
47 - print("%s", json(nodeManager, nodes));
48 - } else {
49 - for (CordVtnNode node : nodes) {
50 - print("hostname=%s, hostMgmtIp=%s, dpIp=%s, br-int=%s, dpIntf=%s, init=%s",
51 - node.hostname(),
52 - node.hostMgmtIp().cidr(),
53 - node.dpIp().cidr(),
54 - node.intBrId().toString(),
55 - node.dpIntf(),
56 - getState(nodeManager, node));
57 - }
58 - print("Total %s nodes", nodeManager.getNodeCount());
59 - }
60 - }
61 -
62 - private JsonNode json(CordVtnNodeManager nodeManager, List<CordVtnNode> nodes) {
63 - ObjectMapper mapper = new ObjectMapper();
64 - ArrayNode result = mapper.createArrayNode();
65 - for (CordVtnNode node : nodes) {
66 - result.add(mapper.createObjectNode()
67 - .put("hostname", node.hostname())
68 - .put("hostManagementIp", node.hostMgmtIp().cidr())
69 - .put("dataPlaneIp", node.dpIp().cidr())
70 - .put("bridgeId", node.intBrId().toString())
71 - .put("dataPlaneInterface", node.dpIntf())
72 - .put("init", getState(nodeManager, node)));
73 - }
74 - return result;
75 - }
76 -
77 - private String getState(CordVtnNodeManager nodeManager, CordVtnNode node) {
78 - return nodeManager.isNodeInitComplete(node) ? COMPLETE : INCOMPLETE;
79 - }
80 -}
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 -/**
18 - * Console commands to manage OVSDB nodes for cordvtn.
19 - */
20 -package org.onosproject.cordvtn.cli;
...\ 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 -package org.onosproject.cordvtn.impl;
17 -
18 -import com.google.common.collect.Maps;
19 -import org.onlab.packet.ARP;
20 -import org.onlab.packet.EthType;
21 -import org.onlab.packet.Ethernet;
22 -import org.onlab.packet.Ip4Address;
23 -import org.onlab.packet.IpAddress;
24 -import org.onlab.packet.MacAddress;
25 -import org.onosproject.cordvtn.api.Instance;
26 -import org.onosproject.core.ApplicationId;
27 -import org.onosproject.net.Host;
28 -import org.onosproject.net.flow.DefaultTrafficSelector;
29 -import org.onosproject.net.flow.DefaultTrafficTreatment;
30 -import org.onosproject.net.flow.TrafficSelector;
31 -import org.onosproject.net.flow.TrafficTreatment;
32 -import org.onosproject.net.host.HostService;
33 -import org.onosproject.net.packet.DefaultOutboundPacket;
34 -import org.onosproject.net.packet.PacketContext;
35 -import org.onosproject.net.packet.PacketPriority;
36 -import org.onosproject.net.packet.PacketService;
37 -import org.slf4j.Logger;
38 -
39 -import java.nio.ByteBuffer;
40 -import java.util.Map;
41 -import java.util.Optional;
42 -import java.util.Set;
43 -
44 -import static com.google.common.base.Preconditions.checkNotNull;
45 -import static org.slf4j.LoggerFactory.getLogger;
46 -
47 -/**
48 - * Handles ARP requests for virtual network service IPs.
49 - */
50 -public class CordVtnArpProxy {
51 - protected final Logger log = getLogger(getClass());
52 -
53 - private final ApplicationId appId;
54 - private final PacketService packetService;
55 - private final HostService hostService;
56 -
57 - private final Map<Ip4Address, MacAddress> gateways = Maps.newConcurrentMap();
58 -
59 - /**
60 - * Default constructor.
61 - *
62 - * @param appId application id
63 - * @param packetService packet service
64 - * @param hostService host service reference
65 - */
66 - public CordVtnArpProxy(ApplicationId appId, PacketService packetService, HostService hostService) {
67 - this.appId = appId;
68 - this.packetService = packetService;
69 - this.hostService = hostService;
70 - }
71 -
72 - /**
73 - * Requests ARP packet.
74 - */
75 - public void requestPacket() {
76 - TrafficSelector selector = DefaultTrafficSelector.builder()
77 - .matchEthType(EthType.EtherType.ARP.ethType().toShort())
78 - .build();
79 -
80 - packetService.requestPackets(selector,
81 - PacketPriority.CONTROL,
82 - appId,
83 - Optional.empty());
84 - }
85 -
86 - /**
87 - * Cancels ARP packet.
88 - */
89 - public void cancelPacket() {
90 - TrafficSelector selector = DefaultTrafficSelector.builder()
91 - .matchEthType(EthType.EtherType.ARP.ethType().toShort())
92 - .build();
93 -
94 - packetService.cancelPackets(selector,
95 - PacketPriority.CONTROL,
96 - appId,
97 - Optional.empty());
98 - }
99 -
100 - /**
101 - * Adds a given gateway IP and MAC address to this ARP proxy.
102 - *
103 - * @param gatewayIp gateway ip address
104 - * @param gatewayMac gateway mac address
105 - */
106 - public void addGateway(IpAddress gatewayIp, MacAddress gatewayMac) {
107 - checkNotNull(gatewayIp);
108 - checkNotNull(gatewayMac);
109 - gateways.put(gatewayIp.getIp4Address(), gatewayMac);
110 - }
111 -
112 - /**
113 - * Removes a given service IP address from this ARP proxy.
114 - *
115 - * @param gatewayIp gateway ip address
116 - */
117 - public void removeGateway(IpAddress gatewayIp) {
118 - checkNotNull(gatewayIp);
119 - gateways.remove(gatewayIp.getIp4Address());
120 - }
121 -
122 - /**
123 - * Emits ARP reply with fake MAC address for a given ARP request.
124 - * It only handles requests for the registered service IPs, and the other
125 - * requests can be handled by other ARP handlers like openstackSwitching or
126 - * proxyArp, for example.
127 - *
128 - * @param context packet context
129 - * @param ethPacket ethernet packet
130 - */
131 - public void processArpPacket(PacketContext context, Ethernet ethPacket) {
132 - ARP arpPacket = (ARP) ethPacket.getPayload();
133 - if (arpPacket.getOpCode() != ARP.OP_REQUEST) {
134 - return;
135 - }
136 -
137 - Ip4Address targetIp = Ip4Address.valueOf(arpPacket.getTargetProtocolAddress());
138 -
139 - MacAddress gatewayMac = gateways.get(targetIp);
140 - MacAddress replyMac = gatewayMac != null ? gatewayMac : getMacFromHostService(targetIp);
141 -
142 - if (replyMac.equals(MacAddress.NONE)) {
143 - log.debug("Failed to find MAC for {}", targetIp.toString());
144 - context.block();
145 - return;
146 - }
147 -
148 - log.trace("Send ARP reply for {} with {}", targetIp.toString(), replyMac.toString());
149 - Ethernet ethReply = ARP.buildArpReply(
150 - targetIp,
151 - replyMac,
152 - ethPacket);
153 -
154 - TrafficTreatment treatment = DefaultTrafficTreatment.builder()
155 - .setOutput(context.inPacket().receivedFrom().port())
156 - .build();
157 -
158 - packetService.emit(new DefaultOutboundPacket(
159 - context.inPacket().receivedFrom().deviceId(),
160 - treatment,
161 - ByteBuffer.wrap(ethReply.serialize())));
162 -
163 - context.block();
164 - }
165 -
166 - /**
167 - * Emits gratuitous ARP when a gateway mac address has been changed.
168 - *
169 - * @param gatewayIp gateway ip address to update MAC
170 - * @param instances set of instances to send gratuitous ARP packet
171 - */
172 - public void sendGratuitousArpForGateway(IpAddress gatewayIp, Set<Instance> instances) {
173 - MacAddress gatewayMac = gateways.get(gatewayIp.getIp4Address());
174 - if (gatewayMac == null) {
175 - log.debug("Gateway {} is not registered to ARP proxy", gatewayIp.toString());
176 - return;
177 - }
178 -
179 - Ethernet ethArp = buildGratuitousArp(gatewayIp.getIp4Address(), gatewayMac);
180 - instances.stream().forEach(instance -> {
181 - TrafficTreatment treatment = DefaultTrafficTreatment.builder()
182 - .setOutput(instance.portNumber())
183 - .build();
184 -
185 - packetService.emit(new DefaultOutboundPacket(
186 - instance.deviceId(),
187 - treatment,
188 - ByteBuffer.wrap(ethArp.serialize())));
189 - });
190 - }
191 -
192 - /**
193 - * Builds gratuitous ARP packet with a given IP and MAC address.
194 - *
195 - * @param ip ip address for TPA and SPA
196 - * @param mac new mac address
197 - * @return ethernet packet
198 - */
199 - private Ethernet buildGratuitousArp(IpAddress ip, MacAddress mac) {
200 - Ethernet eth = new Ethernet();
201 -
202 - eth.setEtherType(Ethernet.TYPE_ARP);
203 - eth.setSourceMACAddress(mac);
204 - eth.setDestinationMACAddress(MacAddress.BROADCAST);
205 -
206 - ARP arp = new ARP();
207 - arp.setOpCode(ARP.OP_REQUEST);
208 - arp.setHardwareType(ARP.HW_TYPE_ETHERNET);
209 - arp.setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH);
210 - arp.setProtocolType(ARP.PROTO_TYPE_IP);
211 - arp.setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH);
212 -
213 - arp.setSenderHardwareAddress(mac.toBytes());
214 - arp.setTargetHardwareAddress(MacAddress.BROADCAST.toBytes());
215 - arp.setSenderProtocolAddress(ip.getIp4Address().toOctets());
216 - arp.setTargetProtocolAddress(ip.getIp4Address().toOctets());
217 -
218 - eth.setPayload(arp);
219 - return eth;
220 - }
221 -
222 - /**
223 - * Returns MAC address of a host with a given target IP address by asking to
224 - * host service. It does not support overlapping IP.
225 - *
226 - * @param targetIp target ip
227 - * @return mac address, or NONE mac address if it fails to find the mac
228 - */
229 - private MacAddress getMacFromHostService(IpAddress targetIp) {
230 - checkNotNull(targetIp);
231 -
232 - Host host = hostService.getHostsByIp(targetIp)
233 - .stream()
234 - .findFirst()
235 - .orElse(null);
236 -
237 - if (host != null) {
238 - log.trace("Found MAC from host service for {}", targetIp.toString());
239 - return host.mac();
240 - } else {
241 - return MacAddress.NONE;
242 - }
243 - }
244 -}
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 -package org.onosproject.cordvtn.impl;
17 -
18 -import com.google.common.collect.Sets;
19 -import com.google.common.io.CharStreams;
20 -import com.jcraft.jsch.Channel;
21 -import com.jcraft.jsch.ChannelExec;
22 -import com.jcraft.jsch.JSch;
23 -import com.jcraft.jsch.JSchException;
24 -import com.jcraft.jsch.Session;
25 -import org.onlab.packet.IpAddress;
26 -import org.onosproject.cordvtn.api.NetworkAddress;
27 -import org.onosproject.cordvtn.api.SshAccessInfo;
28 -import org.slf4j.Logger;
29 -
30 -import java.io.IOException;
31 -import java.io.InputStream;
32 -import java.io.InputStreamReader;
33 -import java.util.Set;
34 -import java.util.regex.Pattern;
35 -import java.util.stream.Collectors;
36 -
37 -import static org.slf4j.LoggerFactory.getLogger;
38 -
39 -/**
40 - * {@code RemoteIpCommandUtil} provides methods to help execute Linux IP commands to a remote server.
41 - * It opens individual exec channels for each command. User can create a session with {@code connect}
42 - * method and then execute a series commands. After done with all commands, the session must be closed
43 - * explicitly by calling {@code disconnect}.
44 - */
45 -public final class RemoteIpCommandUtil {
46 -
47 - protected static final Logger log = getLogger(RemoteIpCommandUtil.class);
48 -
49 - private static final String STRICT_HOST_CHECKING = "StrictHostKeyChecking";
50 - private static final String DEFAULT_STRICT_HOST_CHECKING = "no";
51 - private static final int DEFAULT_SESSION_TIMEOUT = 60000; // milliseconds
52 -
53 - private static final String IP_PATTERN = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
54 - "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
55 - "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
56 - "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
57 -
58 - private static final String IP_ADDR_SHOW = "sudo ip addr show %s";
59 - private static final String IP_ADDR_FLUSH = "sudo ip addr flush %s";
60 - private static final String IP_ADDR_ADD = "sudo ip addr add %s dev %s";
61 - private static final String IP_ADDR_DELETE = "sudo ip addr delete %s dev %s";
62 - private static final String IP_LINK_SHOW = "sudo ip link show %s";
63 - private static final String IP_LINK_UP = "sudo ip link set %s up";
64 -
65 - /**
66 - * Default constructor.
67 - */
68 - private RemoteIpCommandUtil() {
69 - }
70 -
71 - /**
72 - * Adds a given IP address to a given device.
73 - *
74 - * @param session ssh connection
75 - * @param ip network address
76 - * @param device device name to assign the ip address
77 - * @return true if the command succeeds, or false
78 - */
79 - public static boolean addIp(Session session, NetworkAddress ip, String device) {
80 - if (session == null || !session.isConnected()) {
81 - return false;
82 - }
83 -
84 - executeCommand(session, String.format(IP_ADDR_ADD, ip.cidr(), device));
85 - Set<IpAddress> result = getCurrentIps(session, device);
86 - return result.contains(ip.ip());
87 - }
88 -
89 - /**
90 - * Removes the IP address from a given device.
91 - *
92 - * @param session ssh connection
93 - * @param ip ip address
94 - * @param device device name
95 - * @return true if the command succeeds, or false
96 - */
97 - public static boolean deleteIp(Session session, IpAddress ip, String device) {
98 - if (session == null || !session.isConnected()) {
99 - return false;
100 - }
101 -
102 - executeCommand(session, String.format(IP_ADDR_DELETE, ip, device));
103 - Set<IpAddress> result = getCurrentIps(session, device);
104 - return !result.contains(ip);
105 - }
106 -
107 - /**
108 - * Removes all IP address on a given device.
109 - *
110 - * @param session ssh connection
111 - * @param device device name
112 - * @return true if the command succeeds, or false
113 - */
114 - public static boolean flushIp(Session session, String device) {
115 - if (session == null || !session.isConnected()) {
116 - return false;
117 - }
118 -
119 - executeCommand(session, String.format(IP_ADDR_FLUSH, device));
120 - return getCurrentIps(session, device).isEmpty();
121 - }
122 -
123 - /**
124 - * Returns a set of IP address that a given device has.
125 - *
126 - * @param session ssh connection
127 - * @param device device name
128 - * @return set of IP prefix or empty set
129 - */
130 - public static Set<IpAddress> getCurrentIps(Session session, String device) {
131 - if (session == null || !session.isConnected()) {
132 - return Sets.newHashSet();
133 - }
134 -
135 - String output = executeCommand(session, String.format(IP_ADDR_SHOW, device));
136 - Set<IpAddress> result = Pattern.compile(" |/")
137 - .splitAsStream(output)
138 - .filter(s -> s.matches(IP_PATTERN))
139 - .map(IpAddress::valueOf)
140 - .collect(Collectors.toSet());
141 -
142 - return result;
143 - }
144 -
145 - /**
146 - * Sets link state up for a given device.
147 - *
148 - * @param session ssh connection
149 - * @param device device name
150 - * @return true if the command succeeds, or false
151 - */
152 - public static boolean setInterfaceUp(Session session, String device) {
153 - if (session == null || !session.isConnected()) {
154 - return false;
155 - }
156 -
157 - executeCommand(session, String.format(IP_LINK_UP, device));
158 - return isInterfaceUp(session, device);
159 - }
160 -
161 - /**
162 - * Checks if a given interface is up or not.
163 - *
164 - * @param session ssh connection
165 - * @param device device name
166 - * @return true if the interface is up, or false
167 - */
168 - public static boolean isInterfaceUp(Session session, String device) {
169 - if (session == null || !session.isConnected()) {
170 - return false;
171 - }
172 -
173 - String output = executeCommand(session, String.format(IP_LINK_SHOW, device));
174 - return output != null && output.contains("UP");
175 - }
176 -
177 - /**
178 - * Creates a new session with a given access information.
179 - *
180 - * @param sshInfo information to ssh to the remove server
181 - * @return ssh session, or null
182 - */
183 - public static Session connect(SshAccessInfo sshInfo) {
184 - try {
185 - JSch jsch = new JSch();
186 - jsch.addIdentity(sshInfo.privateKey());
187 -
188 - Session session = jsch.getSession(sshInfo.user(),
189 - sshInfo.remoteIp().toString(),
190 - sshInfo.port().toInt());
191 - session.setConfig(STRICT_HOST_CHECKING, DEFAULT_STRICT_HOST_CHECKING);
192 - session.connect(DEFAULT_SESSION_TIMEOUT);
193 -
194 - return session;
195 - } catch (JSchException e) {
196 - log.debug("Failed to connect to {} due to {}", sshInfo.toString(), e.toString());
197 - return null;
198 - }
199 - }
200 -
201 - /**
202 - * Closes a connection.
203 - *
204 - * @param session session
205 - */
206 - public static void disconnect(Session session) {
207 - if (session.isConnected()) {
208 - session.disconnect();
209 - }
210 - }
211 -
212 - /**
213 - * Executes a given command. It opens exec channel for the command and closes
214 - * the channel when it's done.
215 - *
216 - * @param session ssh connection to a remote server
217 - * @param command command to execute
218 - * @return command output string if the command succeeds, or null
219 - */
220 - private static String executeCommand(Session session, String command) {
221 - if (session == null || !session.isConnected()) {
222 - return null;
223 - }
224 -
225 - log.trace("Execute command {} to {}", command, session.getHost());
226 -
227 - try {
228 - Channel channel = session.openChannel("exec");
229 - ((ChannelExec) channel).setCommand(command);
230 - channel.setInputStream(null);
231 - InputStream output = channel.getInputStream();
232 -
233 - channel.connect();
234 - String result = CharStreams.toString(new InputStreamReader(output));
235 - channel.disconnect();
236 -
237 - return result;
238 - } catch (JSchException | IOException e) {
239 - log.debug("Failed to execute command {} due to {}", command, e.toString());
240 - return null;
241 - }
242 - }
243 -}
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 - * Implementation for CORD VTN application.
19 - */
20 -package org.onosproject.cordvtn.impl;
...\ 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 -package org.onosproject.cordvtn.impl.service;
17 -
18 -import org.apache.felix.scr.annotations.Activate;
19 -import org.apache.felix.scr.annotations.Component;
20 -
21 -import org.apache.felix.scr.annotations.Deactivate;
22 -import org.onosproject.cordvtn.api.Instance;
23 -import org.onosproject.cordvtn.api.InstanceHandler;
24 -import org.onosproject.cordvtn.impl.CordVtnInstanceHandler;
25 -import org.onosproject.xosclient.api.VtnService;
26 -
27 -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
28 -import static org.onlab.util.Tools.groupedThreads;
29 -
30 -/**
31 - * Provides network connectivity for dummy service instances.
32 - */
33 -@Component(immediate = true)
34 -public class DummyInstanceHandler extends CordVtnInstanceHandler implements InstanceHandler {
35 -
36 - @Activate
37 - protected void activate() {
38 - serviceType = VtnService.ServiceType.DUMMY;
39 - eventExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/cordvtn-dummy", "event-handler"));
40 - super.activate();
41 - }
42 -
43 - @Deactivate
44 - protected void deactivate() {
45 - super.deactivate();
46 - }
47 -
48 - @Override
49 - public void instanceDetected(Instance instance) {
50 - super.instanceDetected(instance);
51 - }
52 -
53 - @Override
54 - public void instanceRemoved(Instance instance) {
55 - super.instanceRemoved(instance);
56 - }
57 -}
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 -package org.onosproject.cordvtn.impl.service;
17 -
18 -import com.google.common.collect.Maps;
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.onlab.packet.Ethernet;
23 -import org.onlab.packet.IpPrefix;
24 -import org.onosproject.cordconfig.access.AccessAgentConfig;
25 -import org.onosproject.cordconfig.access.AccessAgentData;
26 -import org.onosproject.cordvtn.api.CordVtnConfig;
27 -import org.onosproject.cordvtn.api.Instance;
28 -import org.onosproject.cordvtn.api.InstanceHandler;
29 -import org.onosproject.cordvtn.impl.CordVtnInstanceHandler;
30 -import org.onosproject.net.DeviceId;
31 -import org.onosproject.net.PortNumber;
32 -import org.onosproject.net.config.ConfigFactory;
33 -import org.onosproject.net.config.NetworkConfigEvent;
34 -import org.onosproject.net.config.NetworkConfigListener;
35 -import org.onosproject.net.config.basics.SubjectFactories;
36 -import org.onosproject.net.flow.DefaultFlowRule;
37 -import org.onosproject.net.flow.DefaultTrafficSelector;
38 -import org.onosproject.net.flow.DefaultTrafficTreatment;
39 -import org.onosproject.net.flow.FlowRule;
40 -import org.onosproject.net.flow.TrafficSelector;
41 -import org.onosproject.net.flow.TrafficTreatment;
42 -import org.onosproject.xosclient.api.VtnService;
43 -
44 -import java.util.Map;
45 -import java.util.Set;
46 -
47 -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
48 -import static org.onlab.util.Tools.groupedThreads;
49 -import static org.onosproject.cordvtn.impl.CordVtnPipeline.PRIORITY_MANAGEMENT;
50 -import static org.onosproject.cordvtn.impl.CordVtnPipeline.TABLE_ACCESS_TYPE;
51 -
52 -/**
53 - * Provides network connectivity for OLT agent instances.
54 - */
55 -@Component(immediate = true)
56 -public class OltAgentInstanceHandler extends CordVtnInstanceHandler implements InstanceHandler {
57 -
58 - private static final Class<AccessAgentConfig> CONFIG_CLASS = AccessAgentConfig.class;
59 - private ConfigFactory<DeviceId, AccessAgentConfig> configFactory =
60 - new ConfigFactory<DeviceId, AccessAgentConfig>(
61 - SubjectFactories.DEVICE_SUBJECT_FACTORY, CONFIG_CLASS, "accessAgent") {
62 - @Override
63 - public AccessAgentConfig createConfig() {
64 - return new AccessAgentConfig();
65 - }
66 - };
67 -
68 - private Map<DeviceId, AccessAgentData> oltAgentData = Maps.newConcurrentMap();
69 - private IpPrefix mgmtIpRange = null;
70 -
71 - @Activate
72 - protected void activate() {
73 - eventExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/cordvtn-olt", "event-handler"));
74 - serviceType = VtnService.ServiceType.OLT_AGENT;
75 -
76 - configRegistry.registerConfigFactory(configFactory);
77 - configListener = new InternalConfigListener();
78 -
79 - super.activate();
80 - }
81 -
82 - @Deactivate
83 - protected void deactivate() {
84 - super.deactivate();
85 - }
86 -
87 - @Override
88 - public void instanceDetected(Instance instance) {
89 - log.info("OLT agent instance detected {}", instance);
90 -
91 - managementAccessRule(instance.deviceId(), true);
92 - // TODO implement
93 - }
94 -
95 - @Override
96 - public void instanceRemoved(Instance instance) {
97 - log.info("OLT agent instance removed {}", instance);
98 -
99 - if (getInstances(instance.serviceId()).isEmpty()) {
100 - nodeManager.completeNodes().stream().forEach(node ->
101 - managementAccessRule(node.intBrId(), false));
102 - }
103 -
104 - // TODO implement
105 - }
106 -
107 - private void managementAccessRule(DeviceId deviceId, boolean install) {
108 - // TODO remove this rule after long term management network is done
109 - if (mgmtIpRange != null) {
110 - TrafficSelector selector = DefaultTrafficSelector.builder()
111 - .matchEthType(Ethernet.TYPE_IPV4)
112 - .matchIPDst(mgmtIpRange)
113 - .build();
114 -
115 - TrafficTreatment treatment = DefaultTrafficTreatment.builder()
116 - .setOutput(PortNumber.LOCAL)
117 - .build();
118 -
119 - FlowRule flowRule = DefaultFlowRule.builder()
120 - .fromApp(appId)
121 - .withSelector(selector)
122 - .withTreatment(treatment)
123 - .withPriority(PRIORITY_MANAGEMENT)
124 - .forDevice(deviceId)
125 - .forTable(TABLE_ACCESS_TYPE)
126 - .makePermanent()
127 - .build();
128 -
129 - pipeline.processFlowRule(install, flowRule);
130 - }
131 - }
132 -
133 - private void readAccessAgentConfig() {
134 -
135 - Set<DeviceId> deviceSubjects = configRegistry.getSubjects(DeviceId.class, CONFIG_CLASS);
136 - deviceSubjects.stream().forEach(subject -> {
137 - AccessAgentConfig config = configRegistry.getConfig(subject, CONFIG_CLASS);
138 - if (config != null) {
139 - oltAgentData.put(subject, config.getAgent());
140 - }
141 - });
142 - }
143 -
144 - @Override
145 - protected void readConfiguration() {
146 - CordVtnConfig config = configRegistry.getConfig(appId, CordVtnConfig.class);
147 - if (config == null) {
148 - log.debug("No configuration found");
149 - return;
150 - }
151 -
152 - osAccess = config.openstackAccess();
153 - xosAccess = config.xosAccess();
154 - mgmtIpRange = config.managementIpRange();
155 - }
156 -
157 - public class InternalConfigListener implements NetworkConfigListener {
158 -
159 - @Override
160 - public void event(NetworkConfigEvent event) {
161 -
162 - switch (event.type()) {
163 - case CONFIG_UPDATED:
164 - case CONFIG_ADDED:
165 - if (event.configClass().equals(CordVtnConfig.class)) {
166 - readConfiguration();
167 - } else if (event.configClass().equals(CONFIG_CLASS)) {
168 - readAccessAgentConfig();
169 - }
170 - break;
171 - default:
172 - break;
173 - }
174 - }
175 - }
176 -}
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 - * Implementation of instance handlers for various network services.
19 - */
20 -package org.onosproject.cordvtn.impl.service;
...\ No newline at end of file ...\ No newline at end of file
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.cordvtn.rest;
18 -
19 -import org.onlab.rest.AbstractWebApplication;
20 -
21 -import java.util.Set;
22 -
23 -/**
24 - * CORD VTN Web application.
25 - */
26 -public class CordVtnWebApplication extends AbstractWebApplication {
27 - @Override
28 - public Set<Class<?>> getClasses() {
29 - return getClasses(ServiceDependencyWebResource.class,
30 - NeutronMl2NetworksWebResource.class,
31 - NeutronMl2SubnetsWebResource.class,
32 - NeutronMl2PortsWebResource.class);
33 - }
34 -}
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 -package org.onosproject.cordvtn.rest;
17 -
18 -import org.onosproject.rest.AbstractWebResource;
19 -import org.slf4j.Logger;
20 -import org.slf4j.LoggerFactory;
21 -
22 -import javax.ws.rs.Consumes;
23 -import javax.ws.rs.DELETE;
24 -import javax.ws.rs.POST;
25 -import javax.ws.rs.PUT;
26 -import javax.ws.rs.Path;
27 -import javax.ws.rs.PathParam;
28 -import javax.ws.rs.Produces;
29 -import javax.ws.rs.core.MediaType;
30 -import javax.ws.rs.core.Response;
31 -import java.io.InputStream;
32 -
33 -/**
34 - * Dummy Neutron ML2 mechanism driver.
35 - * It just returns OK for networks resource requests.
36 - */
37 -@Path("networks")
38 -public class NeutronMl2NetworksWebResource extends AbstractWebResource {
39 - protected final Logger log = LoggerFactory.getLogger(getClass());
40 - private static final String NETWORKS_MESSAGE = "Received networks %s";
41 -
42 - @POST
43 - @Consumes(MediaType.APPLICATION_JSON)
44 - @Produces(MediaType.APPLICATION_JSON)
45 - public Response createNetwork(InputStream input) {
46 - log.trace(String.format(NETWORKS_MESSAGE, "create"));
47 - return Response.status(Response.Status.OK).build();
48 - }
49 -
50 - @PUT
51 - @Path("{id}")
52 - @Consumes(MediaType.APPLICATION_JSON)
53 - @Produces(MediaType.APPLICATION_JSON)
54 - public Response updateNetwork(@PathParam("id") String id, InputStream input) {
55 - log.trace(String.format(NETWORKS_MESSAGE, "update"));
56 - return Response.status(Response.Status.OK).build();
57 - }
58 -
59 - @DELETE
60 - @Path("{id}")
61 - public Response deleteNetwork(@PathParam("id") String id) {
62 - log.trace(String.format(NETWORKS_MESSAGE, "delete"));
63 - return Response.noContent().build();
64 - }
65 -}
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 -package org.onosproject.cordvtn.rest;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -import com.fasterxml.jackson.databind.ObjectMapper;
20 -import com.google.common.collect.Maps;
21 -import org.onlab.osgi.DefaultServiceDirectory;
22 -import org.onlab.packet.IpAddress;
23 -import org.onlab.packet.MacAddress;
24 -import org.onosproject.cordvtn.impl.service.VsgInstanceHandler;
25 -import org.onosproject.net.HostId;
26 -import org.onosproject.rest.AbstractWebResource;
27 -import org.slf4j.Logger;
28 -import org.slf4j.LoggerFactory;
29 -
30 -import javax.ws.rs.Consumes;
31 -import javax.ws.rs.DELETE;
32 -import javax.ws.rs.POST;
33 -import javax.ws.rs.PUT;
34 -import javax.ws.rs.Path;
35 -import javax.ws.rs.PathParam;
36 -import javax.ws.rs.Produces;
37 -import javax.ws.rs.core.MediaType;
38 -import javax.ws.rs.core.Response;
39 -import java.io.InputStream;
40 -import java.util.Map;
41 -
42 -
43 -/**
44 - * Dummy Neutron ML2 mechanism driver.
45 - * It just returns OK for ports resource requests except for the port update.
46 - */
47 -@Path("ports")
48 -public class NeutronMl2PortsWebResource extends AbstractWebResource {
49 - protected final Logger log = LoggerFactory.getLogger(getClass());
50 - private static final String PORTS_MESSAGE = "Received ports %s";
51 -
52 - private static final String PORT = "port";
53 - private static final String DEVICE_ID = "device_id";
54 - private static final String NAME = "name";
55 - private static final String MAC_ADDRESS = "mac_address";
56 - private static final String ADDRESS_PAIRS = "allowed_address_pairs";
57 - private static final String IP_ADDERSS = "ip_address";
58 - private static final String STAG_PREFIX = "stag-";
59 - private static final int STAG_BEGIN_INDEX = 5;
60 -
61 - private final VsgInstanceHandler service = DefaultServiceDirectory.getService(VsgInstanceHandler.class);
62 -
63 - @POST
64 - @Consumes(MediaType.APPLICATION_JSON)
65 - @Produces(MediaType.APPLICATION_JSON)
66 - public Response createPorts(InputStream input) {
67 - log.trace(String.format(PORTS_MESSAGE, "create"));
68 - return Response.status(Response.Status.OK).build();
69 - }
70 -
71 - @PUT
72 - @Path("{id}")
73 - @Consumes(MediaType.APPLICATION_JSON)
74 - @Produces(MediaType.APPLICATION_JSON)
75 - public Response updatePorts(@PathParam("id") String id, InputStream input) {
76 - log.debug(String.format(PORTS_MESSAGE, "update"));
77 -
78 - // TODO get vSG updates from XOS to CORD VTN service directly
79 - try {
80 - ObjectMapper mapper = new ObjectMapper();
81 - JsonNode jsonNode = mapper.readTree(input).get(PORT);
82 - log.trace("{}", jsonNode.toString());
83 -
84 - String deviceId = jsonNode.path(DEVICE_ID).asText();
85 - String name = jsonNode.path(NAME).asText();
86 - if (deviceId.isEmpty() || name.isEmpty() || !name.startsWith(STAG_PREFIX)) {
87 - // ignore all updates other than allowed address pairs
88 - return Response.status(Response.Status.OK).build();
89 - }
90 -
91 - // this is allowed address pairs updates
92 - MacAddress mac = MacAddress.valueOf(jsonNode.path(MAC_ADDRESS).asText());
93 - Map<IpAddress, MacAddress> vsgInstances = Maps.newHashMap();
94 - jsonNode.path(ADDRESS_PAIRS).forEach(addrPair -> {
95 - IpAddress pairIp = IpAddress.valueOf(addrPair.path(IP_ADDERSS).asText());
96 - MacAddress pairMac = MacAddress.valueOf(addrPair.path(MAC_ADDRESS).asText());
97 - vsgInstances.put(pairIp, pairMac);
98 - });
99 -
100 - service.updateVsgInstances(HostId.hostId(mac),
101 - name.substring(STAG_BEGIN_INDEX),
102 - vsgInstances);
103 - } catch (Exception e) {
104 - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
105 - }
106 -
107 - return Response.status(Response.Status.OK).build();
108 - }
109 -
110 - @Path("{id}")
111 - @DELETE
112 - public Response deletePorts(@PathParam("id") String id) {
113 - log.trace(String.format(PORTS_MESSAGE, "delete"));
114 - return Response.noContent().build();
115 - }
116 -}
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 -package org.onosproject.cordvtn.rest;
17 -
18 -import org.onosproject.rest.AbstractWebResource;
19 -import org.slf4j.Logger;
20 -import org.slf4j.LoggerFactory;
21 -
22 -import javax.ws.rs.Consumes;
23 -import javax.ws.rs.DELETE;
24 -import javax.ws.rs.POST;
25 -import javax.ws.rs.PUT;
26 -import javax.ws.rs.Path;
27 -import javax.ws.rs.PathParam;
28 -import javax.ws.rs.Produces;
29 -import javax.ws.rs.core.MediaType;
30 -import javax.ws.rs.core.Response;
31 -import java.io.InputStream;
32 -
33 -/**
34 - * Dummy Neutron ML2 mechanism driver.
35 - * It just returns OK for subnets resource requests.
36 - */
37 -@Path("subnets")
38 -public class NeutronMl2SubnetsWebResource extends AbstractWebResource {
39 - protected final Logger log = LoggerFactory.getLogger(getClass());
40 - private static final String SUBNETS_MESSAGE = "Received subnets %s";
41 -
42 - @POST
43 - @Consumes(MediaType.APPLICATION_JSON)
44 - @Produces(MediaType.APPLICATION_JSON)
45 - public Response createSubnet(InputStream input) {
46 - log.trace(String.format(SUBNETS_MESSAGE, "create"));
47 - return Response.status(Response.Status.OK).build();
48 - }
49 -
50 -
51 - @PUT
52 - @Path("{id}")
53 - @Produces(MediaType.APPLICATION_JSON)
54 - @Consumes(MediaType.APPLICATION_JSON)
55 - public Response updateSubnet(@PathParam("id") String id, InputStream input) {
56 - log.trace(String.format(SUBNETS_MESSAGE, "update"));
57 - return Response.status(Response.Status.OK).build();
58 -
59 - }
60 -
61 - @DELETE
62 - @Path("{id}")
63 - public Response deleteSubnet(@PathParam("id") String id) {
64 - log.trace(String.format(SUBNETS_MESSAGE, "delete"));
65 - return Response.noContent().build();
66 - }
67 -}
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 -package org.onosproject.cordvtn.rest;
17 -
18 -import org.onosproject.cordvtn.api.CordVtnService;
19 -import org.onosproject.rest.AbstractWebResource;
20 -import org.onosproject.xosclient.api.VtnServiceId;
21 -
22 -import javax.ws.rs.DELETE;
23 -import javax.ws.rs.POST;
24 -import javax.ws.rs.Path;
25 -import javax.ws.rs.PathParam;
26 -import javax.ws.rs.Produces;
27 -import javax.ws.rs.core.MediaType;
28 -import javax.ws.rs.core.Response;
29 -
30 -/**
31 - * Manages service dependency.
32 - */
33 -@Path("service-dependency")
34 -public class ServiceDependencyWebResource extends AbstractWebResource {
35 -
36 - private final CordVtnService service = get(CordVtnService.class);
37 - private static final String BIDIRECTION = "b";
38 -
39 - /**
40 - * Creates service dependencies with unidirectional access between the services.
41 - *
42 - * @param tServiceId tenant service id
43 - * @param pServiceId provider service id
44 - * @return 200 OK
45 - */
46 - @POST
47 - @Path("{tenantServiceId}/{providerServiceId}")
48 - @Produces(MediaType.APPLICATION_JSON)
49 - public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId,
50 - @PathParam("providerServiceId") String pServiceId) {
51 - service.createServiceDependency(VtnServiceId.of(tServiceId),
52 - VtnServiceId.of(pServiceId),
53 - false);
54 - return Response.status(Response.Status.OK).build();
55 - }
56 -
57 - /**
58 - * Creates service dependencies with an access type extension between the services.
59 - *
60 - * @param tServiceId tenant service id
61 - * @param pServiceId provider service id
62 - * @param direction b for bidirectional access, otherwise unidirectional access
63 - * @return 200 OK
64 - */
65 - @POST
66 - @Path("{tenantServiceId}/{providerServiceId}/{direction}")
67 - @Produces(MediaType.APPLICATION_JSON)
68 - public Response createServiceDependency(@PathParam("tenantServiceId") String tServiceId,
69 - @PathParam("providerServiceId") String pServiceId,
70 - @PathParam("direction") String direction) {
71 - service.createServiceDependency(VtnServiceId.of(tServiceId),
72 - VtnServiceId.of(pServiceId),
73 - direction.equals(BIDIRECTION));
74 - return Response.status(Response.Status.OK).build();
75 - }
76 -
77 - /**
78 - * Removes service dependencies.
79 - *
80 - * @param tServiceId tenant service id
81 - * @param pServiceId provider service id
82 - * @return 204 NO CONTENT
83 - */
84 - @DELETE
85 - @Path("{tenantServiceId}/{providerServiceId}")
86 - public Response removeServiceDependency(@PathParam("tenantServiceId") String tServiceId,
87 - @PathParam("providerServiceId") String pServiceId) {
88 - service.removeServiceDependency(VtnServiceId.of(tServiceId), VtnServiceId.of(pServiceId));
89 - return Response.noContent().build();
90 - }
91 -}
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 -/**
18 - * REST APIs for CORD VTN.
19 - */
20 -package org.onosproject.cordvtn.rest;
...\ No newline at end of file ...\ No newline at end of file
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 -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
17 -
18 - <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
19 - <command>
20 - <action class="org.onosproject.cordvtn.cli.CordVtnNodeListCommand"/>
21 - </command>
22 - <command>
23 - <action class="org.onosproject.cordvtn.cli.CordVtnNodeDeleteCommand"/>
24 - </command>
25 - <command>
26 - <action class="org.onosproject.cordvtn.cli.CordVtnNodeInitCommand"/>
27 - </command>
28 - <command>
29 - <action class="org.onosproject.cordvtn.cli.CordVtnNodeCheckCommand"/>
30 - </command>
31 - <command>
32 - <action class="org.onosproject.cordvtn.cli.CordVtnFlushRules"/>
33 - </command>
34 - </command-bundle>
35 -</blueprint>
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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 -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18 - xmlns="http://java.sun.com/xml/ns/javaee"
19 - xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20 - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
21 - id="ONOS" version="2.5">
22 - <display-name>CORD VTN REST API v1.0</display-name>
23 -
24 - <security-constraint>
25 - <web-resource-collection>
26 - <web-resource-name>Secured</web-resource-name>
27 - <url-pattern>/*</url-pattern>
28 - </web-resource-collection>
29 - <auth-constraint>
30 - <role-name>admin</role-name>
31 - </auth-constraint>
32 - </security-constraint>
33 -
34 - <security-role>
35 - <role-name>admin</role-name>
36 - </security-role>
37 -
38 - <login-config>
39 - <auth-method>BASIC</auth-method>
40 - <realm-name>karaf</realm-name>
41 - </login-config>
42 -
43 - <servlet>
44 - <servlet-name>JAX-RS Service</servlet-name>
45 - <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
46 - <init-param>
47 - <param-name>javax.ws.rs.Application</param-name>
48 - <param-value>org.onosproject.cordvtn.rest.CordVtnWebApplication</param-value>
49 - </init-param>
50 - <load-on-startup>1</load-on-startup>
51 - </servlet>
52 -
53 - <servlet-mapping>
54 - <servlet-name>JAX-RS Service</servlet-name>
55 - <url-pattern>/*</url-pattern>
56 - </servlet-mapping>
57 -</web-app>
1 -COMPILE_DEPS = [
2 - '//lib:CORE_DEPS',
3 - '//lib:org.apache.karaf.shell.console',
4 - '//cli:onos-cli',
5 - '//apps/olt:onos-apps-olt-api',
6 - '//apps/cordconfig:onos-apps-cordconfig',
7 -]
8 -
9 -BUNDLES = [
10 - '//apps/olt:onos-apps-olt-api',
11 - '//apps/igmp:onos-apps-igmp',
12 -]
13 -
14 -osgi_jar_with_tests (
15 - deps = COMPILE_DEPS,
16 -)
17 -
18 -onos_app (
19 - title = 'IGMP App',
20 - category = 'Traffic Steering',
21 - url = 'http://onosproject.org',
22 - description = 'Internet Group Message Protocol',
23 - included_bundles = BUNDLES,
24 -)
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2015-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/xsd/maven-4.0.0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.6.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-igmp</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>Internet Group Message Protocol</description>
33 -
34 - <properties>
35 - <onos.app.name>org.onosproject.igmp</onos.app.name>
36 - <onos.app.title>IGMP App</onos.app.title>
37 - <onos.app.category>Traffic Steering</onos.app.category>
38 - <onos.app.url>http://onosproject.org</onos.app.url>
39 - <onos.app.readme>IGMP implementation.</onos.app.readme>
40 - <onos.app.requires>org.onosproject.cord-config</onos.app.requires>
41 - </properties>
42 -
43 - <dependencies>
44 - <dependency>
45 - <groupId>org.onosproject</groupId>
46 - <artifactId>onos-api</artifactId>
47 - <version>${project.version}</version>
48 - </dependency>
49 -
50 - <dependency>
51 - <groupId>org.onosproject</groupId>
52 - <artifactId>onos-cli</artifactId>
53 - <version>${project.version}</version>
54 - </dependency>
55 -
56 - <dependency>
57 - <groupId>org.onosproject</groupId>
58 - <artifactId>onos-app-olt-api</artifactId>
59 - <version>${project.version}</version>
60 - </dependency>
61 -
62 - <dependency>
63 - <groupId>org.onosproject</groupId>
64 - <artifactId>onlab-osgi</artifactId>
65 - <version>${project.version}</version>
66 - </dependency>
67 -
68 - <dependency>
69 - <groupId>org.onosproject</groupId>
70 - <artifactId>onos-cord-config</artifactId>
71 - <version>${project.version}</version>
72 - </dependency>
73 -
74 - <dependency>
75 - <groupId>org.onosproject</groupId>
76 - <artifactId>onlab-junit</artifactId>
77 - <scope>test</scope>
78 - </dependency>
79 -
80 - <!-- This is needed by ComponentContext, used for tunable configuration -->
81 - <dependency>
82 - <groupId>org.osgi</groupId>
83 - <artifactId>org.osgi.compendium</artifactId>
84 - </dependency>
85 -
86 - <dependency>
87 - <groupId>org.apache.felix</groupId>
88 - <artifactId>org.apache.felix.scr.annotations</artifactId>
89 - <scope>provided</scope>
90 - </dependency>
91 -
92 - </dependencies>
93 -
94 -</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.igmp;
18 -
19 -import com.fasterxml.jackson.databind.JsonNode;
20 -import com.fasterxml.jackson.databind.node.ObjectNode;
21 -import org.onlab.packet.IpAddress;
22 -import org.onosproject.core.ApplicationId;
23 -import org.onosproject.net.config.Config;
24 -import org.onosproject.net.mcast.McastRoute;
25 -
26 -import java.util.ArrayList;
27 -import java.util.List;
28 -
29 -/**
30 - * IGMP SSM translate configuration.
31 - */
32 -public class IgmpSsmTranslateConfig extends Config<ApplicationId> {
33 -
34 - private static final String SOURCE = "source";
35 - private static final String GROUP = "group";
36 -
37 - @Override
38 - public boolean isValid() {
39 - for (JsonNode node : array) {
40 - if (!hasOnlyFields((ObjectNode) node, SOURCE, GROUP)) {
41 - return false;
42 - }
43 -
44 - if (!(isIpAddress((ObjectNode) node, SOURCE, FieldPresence.MANDATORY) &&
45 - isIpAddress((ObjectNode) node, GROUP, FieldPresence.MANDATORY))) {
46 - return false;
47 - }
48 -
49 - }
50 - return true;
51 - }
52 -
53 - /**
54 - * Gets the list of SSM translations.
55 - *
56 - * @return SSM translations
57 - */
58 - public List<McastRoute> getSsmTranslations() {
59 - List<McastRoute> translations = new ArrayList();
60 - for (JsonNode node : array) {
61 - translations.add(
62 - new McastRoute(
63 - IpAddress.valueOf(node.path(SOURCE).asText().trim()),
64 - IpAddress.valueOf(node.path(GROUP).asText().trim()),
65 - McastRoute.Type.STATIC));
66 - }
67 -
68 - return translations;
69 - }
70 -}
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 -/**
18 - * IGMP implementation.
19 - */
20 -package org.onosproject.igmp;
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.