sangho
Committed by Gerrit Code Review

[ONOS-4213] Creates a OpenstackNetworking Config for common use

Change-Id: I241db20fc32788a405b260372eedc3dce2de73fd
Showing 13 changed files with 143 additions and 195 deletions
...@@ -20,12 +20,12 @@ import org.onosproject.net.config.Config; ...@@ -20,12 +20,12 @@ import org.onosproject.net.config.Config;
20 import org.onosproject.net.config.basics.BasicElementConfig; 20 import org.onosproject.net.config.basics.BasicElementConfig;
21 21
22 /** 22 /**
23 - * Handles configuration for OpenstackSwitching app. 23 + * Handles configuration for OpenstackInterface app.
24 */ 24 */
25 -public class OpenstackNetworkingConfig extends Config<ApplicationId> { 25 +public class OpenstackInterfaceConfig extends Config<ApplicationId> {
26 - public static final String NEUTRON_SERVER = "neutron_server"; 26 + public static final String NEUTRON_SERVER = "neutronServer";
27 - public static final String KEYSTONE_SERVER = "keystone_server"; 27 + public static final String KEYSTONE_SERVER = "keystoneServer";
28 - public static final String USER_NAME = "user_name"; 28 + public static final String USER_NAME = "userName";
29 public static final String PASSWORD = "password"; 29 public static final String PASSWORD = "password";
30 public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac"; 30 public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac";
31 31
......
...@@ -35,7 +35,7 @@ import org.onosproject.net.config.NetworkConfigListener; ...@@ -35,7 +35,7 @@ import org.onosproject.net.config.NetworkConfigListener;
35 import org.onosproject.net.config.NetworkConfigRegistry; 35 import org.onosproject.net.config.NetworkConfigRegistry;
36 import org.onosproject.openstackinterface.OpenstackInterfaceService; 36 import org.onosproject.openstackinterface.OpenstackInterfaceService;
37 import org.onosproject.openstackinterface.OpenstackNetwork; 37 import org.onosproject.openstackinterface.OpenstackNetwork;
38 -import org.onosproject.openstackinterface.OpenstackNetworkingConfig; 38 +import org.onosproject.openstackinterface.OpenstackInterfaceConfig;
39 import org.onosproject.openstackinterface.OpenstackPort; 39 import org.onosproject.openstackinterface.OpenstackPort;
40 import org.onosproject.openstackinterface.OpenstackRouter; 40 import org.onosproject.openstackinterface.OpenstackRouter;
41 import org.onosproject.openstackinterface.OpenstackSecurityGroup; 41 import org.onosproject.openstackinterface.OpenstackSecurityGroup;
...@@ -121,12 +121,12 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService { ...@@ -121,12 +121,12 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
121 Executors.newSingleThreadExecutor(groupedThreads("onos/openstackinterface", "config-event")); 121 Executors.newSingleThreadExecutor(groupedThreads("onos/openstackinterface", "config-event"));
122 122
123 private final Set<ConfigFactory> factories = ImmutableSet.of( 123 private final Set<ConfigFactory> factories = ImmutableSet.of(
124 - new ConfigFactory<ApplicationId, OpenstackNetworkingConfig>(APP_SUBJECT_FACTORY, 124 + new ConfigFactory<ApplicationId, OpenstackInterfaceConfig>(APP_SUBJECT_FACTORY,
125 - OpenstackNetworkingConfig.class, 125 + OpenstackInterfaceConfig.class,
126 "openstackinterface") { 126 "openstackinterface") {
127 @Override 127 @Override
128 - public OpenstackNetworkingConfig createConfig() { 128 + public OpenstackInterfaceConfig createConfig() {
129 - return new OpenstackNetworkingConfig(); 129 + return new OpenstackInterfaceConfig();
130 } 130 }
131 } 131 }
132 ); 132 );
...@@ -417,8 +417,8 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService { ...@@ -417,8 +417,8 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
417 private class InternalConfigListener implements NetworkConfigListener { 417 private class InternalConfigListener implements NetworkConfigListener {
418 418
419 public void configureNetwork() { 419 public void configureNetwork() {
420 - OpenstackNetworkingConfig cfg = 420 + OpenstackInterfaceConfig cfg =
421 - cfgService.getConfig(appId, OpenstackNetworkingConfig.class); 421 + cfgService.getConfig(appId, OpenstackInterfaceConfig.class);
422 if (cfg == null) { 422 if (cfg == null) {
423 log.error("There is no openstack server information in config."); 423 log.error("There is no openstack server information in config.");
424 return; 424 return;
...@@ -434,7 +434,7 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService { ...@@ -434,7 +434,7 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
434 public void event(NetworkConfigEvent event) { 434 public void event(NetworkConfigEvent event) {
435 if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED || 435 if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
436 event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) && 436 event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) &&
437 - event.configClass().equals(OpenstackNetworkingConfig.class)) { 437 + event.configClass().equals(OpenstackInterfaceConfig.class)) {
438 438
439 log.info("Network configuration changed"); 439 log.info("Network configuration changed");
440 networkEventExcutorService.execute(this::configureNetwork); 440 networkEventExcutorService.execute(this::configureNetwork);
......
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.openstacknetworking.routing; 16 +package org.onosproject.openstacknetworking;
17 17
18 import com.fasterxml.jackson.databind.JsonNode; 18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.google.common.collect.Maps; 19 import com.google.common.collect.Maps;
20 import org.onlab.packet.Ip4Address; 20 import org.onlab.packet.Ip4Address;
21 -import org.onosproject.core.ApplicationId;
22 import org.onosproject.net.DeviceId; 21 import org.onosproject.net.DeviceId;
23 import org.onosproject.net.config.Config; 22 import org.onosproject.net.config.Config;
24 import org.slf4j.Logger; 23 import org.slf4j.Logger;
...@@ -28,46 +27,24 @@ import java.util.Map; ...@@ -28,46 +27,24 @@ import java.util.Map;
28 import static org.slf4j.LoggerFactory.getLogger; 27 import static org.slf4j.LoggerFactory.getLogger;
29 28
30 /** 29 /**
31 - * Configuration object for OpenstackRouting service. 30 + * Network Config for OpenstackNetworking application.
31 + *
32 */ 32 */
33 -public class OpenstackRoutingConfig extends Config<ApplicationId> { 33 +public class OpenstackNetworkingConfig extends Config<String> {
34 +
34 protected final Logger log = getLogger(getClass()); 35 protected final Logger log = getLogger(getClass());
35 36
36 public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac"; 37 public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac";
37 public static final String GATEWAY_BRIDGE_ID = "gatewayBridgeId"; 38 public static final String GATEWAY_BRIDGE_ID = "gatewayBridgeId";
38 public static final String GATEWAY_EXTERNAL_INTERFACE_NAME = "gatewayExternalInterfaceName"; 39 public static final String GATEWAY_EXTERNAL_INTERFACE_NAME = "gatewayExternalInterfaceName";
39 public static final String GATEWAY_EXTERNAL_INTERFACE_MAC = "gatewayExternalInterfaceMac"; 40 public static final String GATEWAY_EXTERNAL_INTERFACE_MAC = "gatewayExternalInterfaceMac";
41 +
40 public static final String NODES = "nodes"; 42 public static final String NODES = "nodes";
41 public static final String DATAPLANE_IP = "dataPlaneIp"; 43 public static final String DATAPLANE_IP = "dataPlaneIp";
42 public static final String BRIDGE_ID = "bridgeId"; 44 public static final String BRIDGE_ID = "bridgeId";
43 45
44 46
45 /** 47 /**
46 - * Returns the data plane IP map of nodes read from network config.
47 - *
48 - * @return data plane IP map
49 - */
50 - public Map<DeviceId, Ip4Address> nodes() {
51 - Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
52 -
53 - JsonNode jsonNodes = object.get(NODES);
54 - if (jsonNodes == null) {
55 - log.error("There's no node information");
56 - return null;
57 - }
58 -
59 - jsonNodes.forEach(jsonNode -> {
60 - try {
61 - nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
62 - Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
63 - } catch (IllegalArgumentException | NullPointerException e) {
64 - log.error("Failed to read {}", e.toString());
65 - }
66 - });
67 - return nodeMap;
68 - }
69 -
70 - /**
71 * Returns physical router mac. 48 * Returns physical router mac.
72 * 49 *
73 * @return physical router mac 50 * @return physical router mac
...@@ -102,4 +79,30 @@ public class OpenstackRoutingConfig extends Config<ApplicationId> { ...@@ -102,4 +79,30 @@ public class OpenstackRoutingConfig extends Config<ApplicationId> {
102 public String gatewayExternalInterfaceMac() { 79 public String gatewayExternalInterfaceMac() {
103 return this.get(GATEWAY_EXTERNAL_INTERFACE_MAC, ""); 80 return this.get(GATEWAY_EXTERNAL_INTERFACE_MAC, "");
104 } 81 }
82 +
83 + /**
84 + * Returns the data plane IP map of nodes read from network config.
85 + *
86 + * @return data plane IP map
87 + */
88 + public Map<DeviceId, Ip4Address> nodes() {
89 + Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
90 +
91 + JsonNode jsonNodes = object.get(NODES);
92 + if (jsonNodes == null) {
93 + log.error("There's no node information");
94 + return null;
95 + }
96 +
97 + jsonNodes.forEach(jsonNode -> {
98 + try {
99 + nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
100 + Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
101 + } catch (IllegalArgumentException | NullPointerException e) {
102 + log.error("Failed to read {}", e.toString());
103 + }
104 + });
105 + return nodeMap;
106 + }
107 +
105 } 108 }
......
1 +/*
2 + * Copyright 2016 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.openstacknetworking;
17 +
18 +import org.onosproject.net.config.SubjectFactory;
19 +
20 +/**
21 + * SubjectFactory class for OpenstackNetworking configuration.
22 + *
23 + */
24 +public final class OpenstackSubjectFactories {
25 +
26 + private OpenstackSubjectFactories() {
27 +
28 + }
29 +
30 + public static final SubjectFactory<String> USER_DEFINED_SUBJECT_FACTORY =
31 + new SubjectFactory<String>(String.class, "userDefined") {
32 + @Override
33 + public String createSubject(String key) {
34 + return key;
35 + }
36 + };
37 +}
1 { 1 {
2 - "apps" : { 2 + "userDefined" : {
3 - "org.onosproject.openstackrouting" : { 3 + "openstacknetworking" : {
4 - "openstackrouting" : { 4 + "config" : {
5 - "physicalRouterMac" : "36:e3:f7:7b:cc:52", 5 + "physicalRouterMac" : "86:1e:e1:b1:85:bd",
6 "gatewayBridgeId" : "of:0000000000000003", 6 "gatewayBridgeId" : "of:0000000000000003",
7 "gatewayExternalInterfaceName" : "veth0", 7 "gatewayExternalInterfaceName" : "veth0",
8 - "gatewayExternalInterfaceMac" : "96:87:bc:64:99:ad", 8 + "gatewayExternalInterfaceMac" : "d2:b3:eb:36:bd:ae",
9 "nodes" : [ 9 "nodes" : [
10 { 10 {
11 - "dataPlaneIp" : "192.168.57.103", 11 + "dataPlaneIp" : "10.40.101.208",
12 "bridgeId" : "of:0000000000000001" 12 "bridgeId" : "of:0000000000000001"
13 }, 13 },
14 { 14 {
15 - "dataPlaneIp" : "192.168.57.104", 15 + "dataPlaneIp" : "10.40.101.227",
16 "bridgeId" : "of:0000000000000002" 16 "bridgeId" : "of:0000000000000002"
17 }, 17 },
18 { 18 {
19 - "dataPlaneIp" : "192.168.57.105", 19 + "dataPlaneIp" : "10.40.101.240",
20 "bridgeId" : "of:0000000000000003" 20 "bridgeId" : "of:0000000000000003"
21 } 21 }
22 ] 22 ]
23 } 23 }
24 - },
25 - "org.onosproject.openstackswitching" : {
26 - "openstackswitching" : {
27 - "nodes" : [
28 - {
29 - "dataPlaneIp" : "192.168.57.103",
30 - "bridgeId" : "of:0000000000000001"
31 - },
32 - {
33 - "dataPlaneIp" : "192.168.57.104",
34 - "bridgeId" : "of:0000000000000002"
35 - },
36 - {
37 - "dataPlaneIp" : "192.168.57.105",
38 - "bridgeId" : "of:0000000000000003"
39 - }
40 - ]
41 - }
42 - },
43 - "org.onosproject.openstacknode" : {
44 - "openstacknode" : {
45 - "nodes" : [
46 - {
47 - "hostname" : "compute-01",
48 - "ovsdbIp" : "192.168.56.121",
49 - "ovsdbPort" : "6640",
50 - "bridgeId" : "of:0000000000000001",
51 - "openstackNodeType" : "COMPUTENODE"
52 - },
53 - {
54 - "hostname" : "compute-02",
55 - "ovsdbIp" : "192.168.56.122",
56 - "ovsdbPort" : "6640",
57 - "bridgeId" : "of:0000000000000002",
58 - "openstackNodeType" : "COMPUTENODE"
59 - },
60 - {
61 - "hostname" : "network",
62 - "ovsdbIp" : "192.168.56.114",
63 - "ovsdbPort" : "6640",
64 - "bridgeId" : "of:0000000000000003",
65 - "openstackNodeType" : "GATEWAYNODE",
66 - "gatewayExternalInterfaceName" : "veth0",
67 - "gatewayExternalInterfaceMac" : "96:87:bc:64:99:ad"
68 - }
69 - ]
70 } 24 }
71 }, 25 },
26 + "apps" : {
72 "org.onosproject.openstackinterface" : { 27 "org.onosproject.openstackinterface" : {
73 "openstackinterface" : { 28 "openstackinterface" : {
74 - "neutron_server" : "http://192.168.56.118:9696/v2.0/", 29 + "neutronServer" : "http://10.40.101.209:9696/v2.0/",
75 - "keystone_server" : "http://192.168.56.118:5000/v2.0/", 30 + "keystoneServer" : "http://10.40.101.209:5000/v2.0/",
76 - "user_name" : "admin", 31 + "userName" : "admin",
77 - "password" : "rocks" 32 + "password" : "nova"
78 } 33 }
79 } 34 }
80 }, 35 },
...@@ -91,4 +46,3 @@ ...@@ -91,4 +46,3 @@
91 } 46 }
92 } 47 }
93 } 48 }
94 -
......
...@@ -37,6 +37,7 @@ import org.onosproject.net.packet.PacketPriority; ...@@ -37,6 +37,7 @@ import org.onosproject.net.packet.PacketPriority;
37 import org.onosproject.net.packet.PacketService; 37 import org.onosproject.net.packet.PacketService;
38 import org.onosproject.openstackinterface.OpenstackInterfaceService; 38 import org.onosproject.openstackinterface.OpenstackInterfaceService;
39 import org.onosproject.openstackinterface.OpenstackPort; 39 import org.onosproject.openstackinterface.OpenstackPort;
40 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
40 import org.onosproject.openstacknetworking.OpenstackPortInfo; 41 import org.onosproject.openstacknetworking.OpenstackPortInfo;
41 import org.onosproject.openstacknetworking.OpenstackSwitchingService; 42 import org.onosproject.openstacknetworking.OpenstackSwitchingService;
42 import org.slf4j.Logger; 43 import org.slf4j.Logger;
...@@ -61,7 +62,7 @@ public class OpenstackIcmpHandler { ...@@ -61,7 +62,7 @@ public class OpenstackIcmpHandler {
61 private final Map<String, OpenstackPortInfo> icmpInfoMap = Maps.newHashMap(); 62 private final Map<String, OpenstackPortInfo> icmpInfoMap = Maps.newHashMap();
62 private final OpenstackSwitchingService openstackSwitchingService; 63 private final OpenstackSwitchingService openstackSwitchingService;
63 private final OpenstackInterfaceService openstackService; 64 private final OpenstackInterfaceService openstackService;
64 - private final OpenstackRoutingConfig config; 65 + private final OpenstackNetworkingConfig config;
65 private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f"); 66 private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
66 private static final String NETWORK_ROUTER_INTERFACE = "network:router_interface"; 67 private static final String NETWORK_ROUTER_INTERFACE = "network:router_interface";
67 private static final String PORTNAME = "portName"; 68 private static final String PORTNAME = "portName";
...@@ -76,7 +77,7 @@ public class OpenstackIcmpHandler { ...@@ -76,7 +77,7 @@ public class OpenstackIcmpHandler {
76 * @param openstackSwitchingService openstackSwitching service 77 * @param openstackSwitchingService openstackSwitching service
77 */ 78 */
78 OpenstackIcmpHandler(PacketService packetService, DeviceService deviceService, 79 OpenstackIcmpHandler(PacketService packetService, DeviceService deviceService,
79 - OpenstackInterfaceService openstackService, OpenstackRoutingConfig config, 80 + OpenstackInterfaceService openstackService, OpenstackNetworkingConfig config,
80 OpenstackSwitchingService openstackSwitchingService) { 81 OpenstackSwitchingService openstackSwitchingService) {
81 this.packetService = packetService; 82 this.packetService = packetService;
82 this.deviceService = deviceService; 83 this.deviceService = deviceService;
......
...@@ -33,6 +33,7 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService; ...@@ -33,6 +33,7 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService;
33 import org.onosproject.openstackinterface.OpenstackNetwork; 33 import org.onosproject.openstackinterface.OpenstackNetwork;
34 import org.onosproject.openstackinterface.OpenstackPort; 34 import org.onosproject.openstackinterface.OpenstackPort;
35 import org.onosproject.openstackinterface.OpenstackRouter; 35 import org.onosproject.openstackinterface.OpenstackRouter;
36 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
36 import org.slf4j.Logger; 37 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory; 38 import org.slf4j.LoggerFactory;
38 39
...@@ -56,12 +57,12 @@ public class OpenstackPnatHandler implements Runnable { ...@@ -56,12 +57,12 @@ public class OpenstackPnatHandler implements Runnable {
56 private final int portNum; 57 private final int portNum;
57 private final OpenstackPort openstackPort; 58 private final OpenstackPort openstackPort;
58 private final Port port; 59 private final Port port;
59 - private OpenstackRoutingConfig config; 60 + private OpenstackNetworkingConfig config;
60 61
61 private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface"; 62 private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface";
62 63
63 OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context, 64 OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context,
64 - int portNum, OpenstackPort openstackPort, Port port, OpenstackRoutingConfig config) { 65 + int portNum, OpenstackPort openstackPort, Port port, OpenstackNetworkingConfig config) {
65 this.rulePopulator = checkNotNull(rulePopulator); 66 this.rulePopulator = checkNotNull(rulePopulator);
66 this.context = checkNotNull(context); 67 this.context = checkNotNull(context);
67 this.portNum = checkNotNull(portNum); 68 this.portNum = checkNotNull(portNum);
......
...@@ -33,6 +33,7 @@ import org.onosproject.net.packet.PacketPriority; ...@@ -33,6 +33,7 @@ import org.onosproject.net.packet.PacketPriority;
33 import org.onosproject.net.packet.PacketService; 33 import org.onosproject.net.packet.PacketService;
34 import org.onosproject.openstackinterface.OpenstackInterfaceService; 34 import org.onosproject.openstackinterface.OpenstackInterfaceService;
35 import org.onosproject.openstackinterface.OpenstackPort; 35 import org.onosproject.openstackinterface.OpenstackPort;
36 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
36 import org.slf4j.Logger; 37 import org.slf4j.Logger;
37 38
38 import java.nio.ByteBuffer; 39 import java.nio.ByteBuffer;
...@@ -49,7 +50,7 @@ public class OpenstackRoutingArpHandler { ...@@ -49,7 +50,7 @@ public class OpenstackRoutingArpHandler {
49 50
50 private final PacketService packetService; 51 private final PacketService packetService;
51 private final OpenstackInterfaceService openstackService; 52 private final OpenstackInterfaceService openstackService;
52 - private final OpenstackRoutingConfig config; 53 + private final OpenstackNetworkingConfig config;
53 private static final String NETWORK_ROUTER_GATEWAY = "network:router_gateway"; 54 private static final String NETWORK_ROUTER_GATEWAY = "network:router_gateway";
54 55
55 /** 56 /**
...@@ -60,7 +61,7 @@ public class OpenstackRoutingArpHandler { ...@@ -60,7 +61,7 @@ public class OpenstackRoutingArpHandler {
60 * @param config openstackRoutingConfig 61 * @param config openstackRoutingConfig
61 */ 62 */
62 OpenstackRoutingArpHandler(PacketService packetService, OpenstackInterfaceService openstackService, 63 OpenstackRoutingArpHandler(PacketService packetService, OpenstackInterfaceService openstackService,
63 - OpenstackRoutingConfig config) { 64 + OpenstackNetworkingConfig config) {
64 this.packetService = packetService; 65 this.packetService = packetService;
65 this.openstackService = checkNotNull(openstackService); 66 this.openstackService = checkNotNull(openstackService);
66 this.config = checkNotNull(config); 67 this.config = checkNotNull(config);
......
...@@ -37,7 +37,6 @@ import org.onosproject.net.config.NetworkConfigEvent; ...@@ -37,7 +37,6 @@ import org.onosproject.net.config.NetworkConfigEvent;
37 import org.onosproject.net.config.NetworkConfigListener; 37 import org.onosproject.net.config.NetworkConfigListener;
38 import org.onosproject.net.config.NetworkConfigRegistry; 38 import org.onosproject.net.config.NetworkConfigRegistry;
39 import org.onosproject.net.config.NetworkConfigService; 39 import org.onosproject.net.config.NetworkConfigService;
40 -import org.onosproject.net.config.basics.SubjectFactories;
41 import org.onosproject.net.device.DeviceService; 40 import org.onosproject.net.device.DeviceService;
42 import org.onosproject.net.driver.DriverService; 41 import org.onosproject.net.driver.DriverService;
43 import org.onosproject.net.flowobjective.FlowObjectiveService; 42 import org.onosproject.net.flowobjective.FlowObjectiveService;
...@@ -50,8 +49,10 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService; ...@@ -50,8 +49,10 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService;
50 import org.onosproject.openstackinterface.OpenstackPort; 49 import org.onosproject.openstackinterface.OpenstackPort;
51 import org.onosproject.openstackinterface.OpenstackRouter; 50 import org.onosproject.openstackinterface.OpenstackRouter;
52 import org.onosproject.openstackinterface.OpenstackRouterInterface; 51 import org.onosproject.openstackinterface.OpenstackRouterInterface;
52 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
53 import org.onosproject.openstacknetworking.OpenstackPortInfo; 53 import org.onosproject.openstacknetworking.OpenstackPortInfo;
54 import org.onosproject.openstacknetworking.OpenstackRoutingService; 54 import org.onosproject.openstacknetworking.OpenstackRoutingService;
55 +import org.onosproject.openstacknetworking.OpenstackSubjectFactories;
55 import org.onosproject.openstacknetworking.OpenstackSwitchingService; 56 import org.onosproject.openstacknetworking.OpenstackSwitchingService;
56 import org.onosproject.store.serializers.KryoNamespaces; 57 import org.onosproject.store.serializers.KryoNamespaces;
57 import org.onosproject.store.service.ConsistentMap; 58 import org.onosproject.store.service.ConsistentMap;
...@@ -124,16 +125,19 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -124,16 +125,19 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
124 private static final int PNAT_PORT_EXPIRE_TIME = 1200 * 1000; 125 private static final int PNAT_PORT_EXPIRE_TIME = 1200 * 1000;
125 private static final int TP_PORT_MINIMUM_NUM = 1024; 126 private static final int TP_PORT_MINIMUM_NUM = 1024;
126 private static final int TP_PORT_MAXIMUM_NUM = 65535; 127 private static final int TP_PORT_MAXIMUM_NUM = 65535;
128 +
127 private final ConfigFactory configFactory = 129 private final ConfigFactory configFactory =
128 - new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, OpenstackRoutingConfig.class, "openstackrouting") { 130 + new ConfigFactory(OpenstackSubjectFactories.USER_DEFINED_SUBJECT_FACTORY, OpenstackNetworkingConfig.class,
131 + "config") {
129 @Override 132 @Override
130 - public OpenstackRoutingConfig createConfig() { 133 + public OpenstackNetworkingConfig createConfig() {
131 - return new OpenstackRoutingConfig(); 134 + return new OpenstackNetworkingConfig();
132 } 135 }
133 }; 136 };
137 +
134 private final NetworkConfigListener configListener = new InternalConfigListener(); 138 private final NetworkConfigListener configListener = new InternalConfigListener();
135 139
136 - private OpenstackRoutingConfig config; 140 + private OpenstackNetworkingConfig config;
137 private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder() 141 private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder()
138 .register(KryoNamespaces.API) 142 .register(KryoNamespaces.API)
139 .register(KryoNamespaces.MISC) 143 .register(KryoNamespaces.MISC)
...@@ -167,8 +171,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -167,8 +171,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
167 configRegistry.registerConfigFactory(configFactory); 171 configRegistry.registerConfigFactory(configFactory);
168 configService.addListener(configListener); 172 configService.addListener(configListener);
169 173
170 - readConfiguration();
171 -
172 floatingIpMap = storageService.<String, OpenstackFloatingIP>consistentMapBuilder() 174 floatingIpMap = storageService.<String, OpenstackFloatingIP>consistentMapBuilder()
173 .withSerializer(Serializer.using(FLOATING_IP_SERIALIZER.build())) 175 .withSerializer(Serializer.using(FLOATING_IP_SERIALIZER.build()))
174 .withName(FLOATING_IP_MAP_NAME) 176 .withName(FLOATING_IP_MAP_NAME)
...@@ -180,6 +182,8 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -180,6 +182,8 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
180 .withApplicationId(appId) 182 .withApplicationId(appId)
181 .build(); 183 .build();
182 184
185 + readConfiguration();
186 +
183 log.info("onos-openstackrouting started"); 187 log.info("onos-openstackrouting started");
184 } 188 }
185 189
...@@ -488,7 +492,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -488,7 +492,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
488 } 492 }
489 493
490 private void readConfiguration() { 494 private void readConfiguration() {
491 - config = configService.getConfig(appId, OpenstackRoutingConfig.class); 495 + config = configService.getConfig("openstacknetworking", OpenstackNetworkingConfig.class);
492 if (config == null) { 496 if (config == null) {
493 log.error("No configuration found"); 497 log.error("No configuration found");
494 return; 498 return;
...@@ -499,7 +503,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -499,7 +503,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
499 checkNotNull(config.gatewayExternalInterfaceMac()); 503 checkNotNull(config.gatewayExternalInterfaceMac());
500 checkNotNull(config.gatewayExternalInterfaceName()); 504 checkNotNull(config.gatewayExternalInterfaceName());
501 505
502 - log.debug("Configured info: {}, {}, {}, {}", config.physicalRouterMac(), config.gatewayBridgeId(), 506 + log.warn("Configured info: {}, {}, {}, {}", config.physicalRouterMac(), config.gatewayBridgeId(),
503 config.gatewayExternalInterfaceMac(), config.gatewayExternalInterfaceName()); 507 config.gatewayExternalInterfaceMac(), config.gatewayExternalInterfaceName());
504 508
505 rulePopulator = new OpenstackRoutingRulePopulator(appId, 509 rulePopulator = new OpenstackRoutingRulePopulator(appId,
...@@ -512,6 +516,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -512,6 +516,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
512 openstackIcmpHandler.requestPacket(appId); 516 openstackIcmpHandler.requestPacket(appId);
513 openstackArpHandler.requestPacket(appId); 517 openstackArpHandler.requestPacket(appId);
514 reloadInitL3Rules(); 518 reloadInitL3Rules();
519 +
515 log.info("OpenstackRouting configured"); 520 log.info("OpenstackRouting configured");
516 } 521 }
517 522
...@@ -519,7 +524,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { ...@@ -519,7 +524,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
519 524
520 @Override 525 @Override
521 public void event(NetworkConfigEvent event) { 526 public void event(NetworkConfigEvent event) {
522 - if (!event.configClass().equals(OpenstackRoutingConfig.class)) { 527 + if (!event.configClass().equals(OpenstackNetworkingConfig.class)) {
523 return; 528 return;
524 } 529 }
525 530
......
...@@ -52,6 +52,7 @@ import org.onosproject.openstackinterface.OpenstackPort; ...@@ -52,6 +52,7 @@ import org.onosproject.openstackinterface.OpenstackPort;
52 import org.onosproject.openstackinterface.OpenstackRouterInterface; 52 import org.onosproject.openstackinterface.OpenstackRouterInterface;
53 import org.onosproject.openstackinterface.OpenstackSubnet; 53 import org.onosproject.openstackinterface.OpenstackSubnet;
54 import org.onosproject.openstackinterface.OpenstackFloatingIP; 54 import org.onosproject.openstackinterface.OpenstackFloatingIP;
55 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
55 import org.onosproject.openstacknetworking.OpenstackPortInfo; 56 import org.onosproject.openstacknetworking.OpenstackPortInfo;
56 import org.slf4j.Logger; 57 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory; 58 import org.slf4j.LoggerFactory;
...@@ -72,7 +73,7 @@ public class OpenstackRoutingRulePopulator { ...@@ -72,7 +73,7 @@ public class OpenstackRoutingRulePopulator {
72 private final OpenstackInterfaceService openstackService; 73 private final OpenstackInterfaceService openstackService;
73 private final DeviceService deviceService; 74 private final DeviceService deviceService;
74 private final DriverService driverService; 75 private final DriverService driverService;
75 - private final OpenstackRoutingConfig config; 76 + private final OpenstackNetworkingConfig config;
76 77
77 private static final String PORTNAME_PREFIX_TUNNEL = "vxlan"; 78 private static final String PORTNAME_PREFIX_TUNNEL = "vxlan";
78 private static final String PORTNAME = "portName"; 79 private static final String PORTNAME = "portName";
...@@ -106,7 +107,7 @@ public class OpenstackRoutingRulePopulator { ...@@ -106,7 +107,7 @@ public class OpenstackRoutingRulePopulator {
106 */ 107 */
107 public OpenstackRoutingRulePopulator(ApplicationId appId, OpenstackInterfaceService openstackService, 108 public OpenstackRoutingRulePopulator(ApplicationId appId, OpenstackInterfaceService openstackService,
108 FlowObjectiveService flowObjectiveService, DeviceService deviceService, 109 FlowObjectiveService flowObjectiveService, DeviceService deviceService,
109 - DriverService driverService, OpenstackRoutingConfig config) { 110 + DriverService driverService, OpenstackNetworkingConfig config) {
110 this.appId = appId; 111 this.appId = appId;
111 this.flowObjectiveService = flowObjectiveService; 112 this.flowObjectiveService = flowObjectiveService;
112 this.openstackService = checkNotNull(openstackService); 113 this.openstackService = checkNotNull(openstackService);
......
1 -/*
2 - * Copyright 2016 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.openstacknetworking.switching;
17 -
18 -import com.fasterxml.jackson.databind.JsonNode;
19 -import com.google.common.collect.Maps;
20 -import org.onlab.packet.Ip4Address;
21 -import org.onosproject.core.ApplicationId;
22 -import org.onosproject.net.DeviceId;
23 -import org.onosproject.net.config.Config;
24 -import org.slf4j.Logger;
25 -
26 -import java.util.Map;
27 -
28 -import static org.slf4j.LoggerFactory.getLogger;
29 -
30 -/**
31 - * Configuration object for OpenstackSwitching service.
32 - */
33 -public class OpenstackSwitchingConfig extends Config<ApplicationId> {
34 -
35 - protected final Logger log = getLogger(getClass());
36 -
37 - public static final String NODES = "nodes";
38 - public static final String DATAPLANE_IP = "dataPlaneIp";
39 - public static final String BRIDGE_ID = "bridgeId";
40 -
41 - /**
42 - * Returns the data plane IP map of nodes read from network config.
43 - *
44 - * @return data plane IP map
45 - */
46 - public Map<DeviceId, Ip4Address> nodes() {
47 - Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
48 -
49 - JsonNode jsonNodes = object.get(NODES);
50 - if (jsonNodes == null) {
51 - log.error("There's no node information");
52 - return null;
53 - }
54 -
55 - jsonNodes.forEach(jsonNode -> {
56 - try {
57 - nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
58 - Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
59 - } catch (IllegalArgumentException | NullPointerException e) {
60 - log.error("Failed to read {}", e.getMessage());
61 - }
62 - });
63 - return nodeMap;
64 - }
65 -}
...@@ -38,7 +38,6 @@ import org.onosproject.net.config.NetworkConfigEvent; ...@@ -38,7 +38,6 @@ import org.onosproject.net.config.NetworkConfigEvent;
38 import org.onosproject.net.config.NetworkConfigListener; 38 import org.onosproject.net.config.NetworkConfigListener;
39 import org.onosproject.net.config.NetworkConfigRegistry; 39 import org.onosproject.net.config.NetworkConfigRegistry;
40 import org.onosproject.net.config.NetworkConfigService; 40 import org.onosproject.net.config.NetworkConfigService;
41 -import org.onosproject.net.config.basics.SubjectFactories;
42 import org.onosproject.net.device.DeviceEvent; 41 import org.onosproject.net.device.DeviceEvent;
43 import org.onosproject.net.device.DeviceListener; 42 import org.onosproject.net.device.DeviceListener;
44 import org.onosproject.net.device.DeviceService; 43 import org.onosproject.net.device.DeviceService;
...@@ -57,6 +56,8 @@ import org.onosproject.openstackinterface.OpenstackPort; ...@@ -57,6 +56,8 @@ import org.onosproject.openstackinterface.OpenstackPort;
57 import org.onosproject.openstackinterface.OpenstackSecurityGroup; 56 import org.onosproject.openstackinterface.OpenstackSecurityGroup;
58 import org.onosproject.openstackinterface.OpenstackSubnet; 57 import org.onosproject.openstackinterface.OpenstackSubnet;
59 import org.onosproject.openstacknetworking.OpenstackPortInfo; 58 import org.onosproject.openstacknetworking.OpenstackPortInfo;
59 +import org.onosproject.openstacknetworking.OpenstackSubjectFactories;
60 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
60 import org.onosproject.openstacknetworking.OpenstackSwitchingService; 61 import org.onosproject.openstacknetworking.OpenstackSwitchingService;
61 import org.slf4j.Logger; 62 import org.slf4j.Logger;
62 import org.slf4j.LoggerFactory; 63 import org.slf4j.LoggerFactory;
...@@ -99,6 +100,9 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -99,6 +100,9 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
99 protected DriverService driverService; 100 protected DriverService driverService;
100 101
101 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 102 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
103 + protected NetworkConfigRegistry networkConfig;
104 +
105 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
102 protected OpenstackInterfaceService openstackService; 106 protected OpenstackInterfaceService openstackService;
103 107
104 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 108 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
...@@ -136,16 +140,16 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -136,16 +140,16 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
136 private Map<String, OpenstackSecurityGroup> securityGroupMap = Maps.newConcurrentMap(); 140 private Map<String, OpenstackSecurityGroup> securityGroupMap = Maps.newConcurrentMap();
137 141
138 private final ConfigFactory configFactory = 142 private final ConfigFactory configFactory =
139 - new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, 143 + new ConfigFactory(OpenstackSubjectFactories.USER_DEFINED_SUBJECT_FACTORY, OpenstackNetworkingConfig.class,
140 - OpenstackSwitchingConfig.class, "openstackswitching") { 144 + "config") {
141 @Override 145 @Override
142 - public OpenstackSwitchingConfig createConfig() { 146 + public OpenstackNetworkingConfig createConfig() {
143 - return new OpenstackSwitchingConfig(); 147 + return new OpenstackNetworkingConfig();
144 } 148 }
145 }; 149 };
146 private final NetworkConfigListener configListener = new InternalConfigListener(); 150 private final NetworkConfigListener configListener = new InternalConfigListener();
147 151
148 - private OpenstackSwitchingConfig config; 152 + private OpenstackNetworkingConfig config;
149 153
150 @Activate 154 @Activate
151 protected void activate() { 155 protected void activate() {
...@@ -158,6 +162,12 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -158,6 +162,12 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
158 configRegistry.registerConfigFactory(configFactory); 162 configRegistry.registerConfigFactory(configFactory);
159 configService.addListener(configListener); 163 configService.addListener(configListener);
160 164
165 + arpHandler = new OpenstackArpHandler(openstackService, packetService, hostService);
166 + sgRulePopulator = new OpenstackSecurityGroupRulePopulator(appId, openstackService, flowObjectiveService);
167 +
168 + networkConfig.registerConfigFactory(configFactory);
169 + networkConfig.addListener(configListener);
170 +
161 readConfiguration(); 171 readConfiguration();
162 172
163 log.info("Started"); 173 log.info("Started");
...@@ -484,7 +494,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -484,7 +494,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
484 } 494 }
485 495
486 private void readConfiguration() { 496 private void readConfiguration() {
487 - config = configService.getConfig(appId, OpenstackSwitchingConfig.class); 497 + config = configService.getConfig("openstacknetworking", OpenstackNetworkingConfig.class);
488 if (config == null) { 498 if (config == null) {
489 log.error("No configuration found"); 499 log.error("No configuration found");
490 return; 500 return;
...@@ -500,7 +510,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -500,7 +510,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
500 510
501 @Override 511 @Override
502 public void event(NetworkConfigEvent event) { 512 public void event(NetworkConfigEvent event) {
503 - if (!event.configClass().equals(OpenstackSwitchingConfig.class)) { 513 + if (!event.configClass().equals(OpenstackNetworkingConfig.class)) {
504 return; 514 return;
505 } 515 }
506 516
...@@ -508,7 +518,6 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService { ...@@ -508,7 +518,6 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
508 event.type().equals(NetworkConfigEvent.Type.CONFIG_UPDATED)) { 518 event.type().equals(NetworkConfigEvent.Type.CONFIG_UPDATED)) {
509 configEventExecutorService.execute(OpenstackSwitchingManager.this::readConfiguration); 519 configEventExecutorService.execute(OpenstackSwitchingManager.this::readConfiguration);
510 520
511 -
512 } 521 }
513 } 522 }
514 } 523 }
......
...@@ -43,6 +43,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective; ...@@ -43,6 +43,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
43 import org.onosproject.openstackinterface.OpenstackInterfaceService; 43 import org.onosproject.openstackinterface.OpenstackInterfaceService;
44 import org.onosproject.openstackinterface.OpenstackNetwork; 44 import org.onosproject.openstackinterface.OpenstackNetwork;
45 import org.onosproject.openstackinterface.OpenstackPort; 45 import org.onosproject.openstackinterface.OpenstackPort;
46 +import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
46 import org.onosproject.openstacknetworking.OpenstackPortInfo; 47 import org.onosproject.openstacknetworking.OpenstackPortInfo;
47 import org.slf4j.Logger; 48 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory; 49 import org.slf4j.LoggerFactory;
...@@ -65,7 +66,7 @@ public class OpenstackSwitchingRulePopulator { ...@@ -65,7 +66,7 @@ public class OpenstackSwitchingRulePopulator {
65 private DriverService driverService; 66 private DriverService driverService;
66 private DeviceService deviceService; 67 private DeviceService deviceService;
67 private ApplicationId appId; 68 private ApplicationId appId;
68 - private OpenstackSwitchingConfig config; 69 + private OpenstackNetworkingConfig config;
69 70
70 private Collection<OpenstackNetwork> openstackNetworkList; 71 private Collection<OpenstackNetwork> openstackNetworkList;
71 private Collection<OpenstackPort> openstackPortList; 72 private Collection<OpenstackPort> openstackPortList;
...@@ -85,7 +86,7 @@ public class OpenstackSwitchingRulePopulator { ...@@ -85,7 +86,7 @@ public class OpenstackSwitchingRulePopulator {
85 DeviceService deviceService, 86 DeviceService deviceService,
86 OpenstackInterfaceService openstackService, 87 OpenstackInterfaceService openstackService,
87 DriverService driverService, 88 DriverService driverService,
88 - OpenstackSwitchingConfig config) { 89 + OpenstackNetworkingConfig config) {
89 this.flowObjectiveService = flowObjectiveService; 90 this.flowObjectiveService = flowObjectiveService;
90 this.deviceService = deviceService; 91 this.deviceService = deviceService;
91 this.driverService = driverService; 92 this.driverService = driverService;
......