sangho
Committed by Gerrit Code Review

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

Change-Id: I241db20fc32788a405b260372eedc3dce2de73fd
Showing 13 changed files with 158 additions and 210 deletions
......@@ -20,12 +20,12 @@ import org.onosproject.net.config.Config;
import org.onosproject.net.config.basics.BasicElementConfig;
/**
* Handles configuration for OpenstackSwitching app.
* Handles configuration for OpenstackInterface app.
*/
public class OpenstackNetworkingConfig extends Config<ApplicationId> {
public static final String NEUTRON_SERVER = "neutron_server";
public static final String KEYSTONE_SERVER = "keystone_server";
public static final String USER_NAME = "user_name";
public class OpenstackInterfaceConfig extends Config<ApplicationId> {
public static final String NEUTRON_SERVER = "neutronServer";
public static final String KEYSTONE_SERVER = "keystoneServer";
public static final String USER_NAME = "userName";
public static final String PASSWORD = "password";
public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac";
......
......@@ -35,7 +35,7 @@ import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackNetwork;
import org.onosproject.openstackinterface.OpenstackNetworkingConfig;
import org.onosproject.openstackinterface.OpenstackInterfaceConfig;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstackinterface.OpenstackRouter;
import org.onosproject.openstackinterface.OpenstackSecurityGroup;
......@@ -121,12 +121,12 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
Executors.newSingleThreadExecutor(groupedThreads("onos/openstackinterface", "config-event"));
private final Set<ConfigFactory> factories = ImmutableSet.of(
new ConfigFactory<ApplicationId, OpenstackNetworkingConfig>(APP_SUBJECT_FACTORY,
OpenstackNetworkingConfig.class,
new ConfigFactory<ApplicationId, OpenstackInterfaceConfig>(APP_SUBJECT_FACTORY,
OpenstackInterfaceConfig.class,
"openstackinterface") {
@Override
public OpenstackNetworkingConfig createConfig() {
return new OpenstackNetworkingConfig();
public OpenstackInterfaceConfig createConfig() {
return new OpenstackInterfaceConfig();
}
}
);
......@@ -417,8 +417,8 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
private class InternalConfigListener implements NetworkConfigListener {
public void configureNetwork() {
OpenstackNetworkingConfig cfg =
cfgService.getConfig(appId, OpenstackNetworkingConfig.class);
OpenstackInterfaceConfig cfg =
cfgService.getConfig(appId, OpenstackInterfaceConfig.class);
if (cfg == null) {
log.error("There is no openstack server information in config.");
return;
......@@ -434,7 +434,7 @@ public class OpenstackInterfaceManager implements OpenstackInterfaceService {
public void event(NetworkConfigEvent event) {
if (((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) &&
event.configClass().equals(OpenstackNetworkingConfig.class)) {
event.configClass().equals(OpenstackInterfaceConfig.class)) {
log.info("Network configuration changed");
networkEventExcutorService.execute(this::configureNetwork);
......
......@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openstacknetworking.routing;
package org.onosproject.openstacknetworking;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Maps;
import org.onlab.packet.Ip4Address;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.config.Config;
import org.slf4j.Logger;
......@@ -28,46 +27,24 @@ import java.util.Map;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Configuration object for OpenstackRouting service.
* Network Config for OpenstackNetworking application.
*
*/
public class OpenstackRoutingConfig extends Config<ApplicationId> {
public class OpenstackNetworkingConfig extends Config<String> {
protected final Logger log = getLogger(getClass());
public static final String PHYSICAL_ROUTER_MAC = "physicalRouterMac";
public static final String GATEWAY_BRIDGE_ID = "gatewayBridgeId";
public static final String GATEWAY_EXTERNAL_INTERFACE_NAME = "gatewayExternalInterfaceName";
public static final String GATEWAY_EXTERNAL_INTERFACE_MAC = "gatewayExternalInterfaceMac";
public static final String NODES = "nodes";
public static final String DATAPLANE_IP = "dataPlaneIp";
public static final String BRIDGE_ID = "bridgeId";
/**
* Returns the data plane IP map of nodes read from network config.
*
* @return data plane IP map
*/
public Map<DeviceId, Ip4Address> nodes() {
Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
JsonNode jsonNodes = object.get(NODES);
if (jsonNodes == null) {
log.error("There's no node information");
return null;
}
jsonNodes.forEach(jsonNode -> {
try {
nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
} catch (IllegalArgumentException | NullPointerException e) {
log.error("Failed to read {}", e.toString());
}
});
return nodeMap;
}
/**
* Returns physical router mac.
*
* @return physical router mac
......@@ -102,4 +79,30 @@ public class OpenstackRoutingConfig extends Config<ApplicationId> {
public String gatewayExternalInterfaceMac() {
return this.get(GATEWAY_EXTERNAL_INTERFACE_MAC, "");
}
/**
* Returns the data plane IP map of nodes read from network config.
*
* @return data plane IP map
*/
public Map<DeviceId, Ip4Address> nodes() {
Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
JsonNode jsonNodes = object.get(NODES);
if (jsonNodes == null) {
log.error("There's no node information");
return null;
}
jsonNodes.forEach(jsonNode -> {
try {
nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
} catch (IllegalArgumentException | NullPointerException e) {
log.error("Failed to read {}", e.toString());
}
});
return nodeMap;
}
}
......
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openstacknetworking;
import org.onosproject.net.config.SubjectFactory;
/**
* SubjectFactory class for OpenstackNetworking configuration.
*
*/
public final class OpenstackSubjectFactories {
private OpenstackSubjectFactories() {
}
public static final SubjectFactory<String> USER_DEFINED_SUBJECT_FACTORY =
new SubjectFactory<String>(String.class, "userDefined") {
@Override
public String createSubject(String key) {
return key;
}
};
}
{
"apps" : {
"org.onosproject.openstackrouting" : {
"openstackrouting" : {
"physicalRouterMac" : "36:e3:f7:7b:cc:52",
"userDefined" : {
"openstacknetworking" : {
"config" : {
"physicalRouterMac" : "86:1e:e1:b1:85:bd",
"gatewayBridgeId" : "of:0000000000000003",
"gatewayExternalInterfaceName" : "veth0",
"gatewayExternalInterfaceMac" : "96:87:bc:64:99:ad",
"gatewayExternalInterfaceMac" : "d2:b3:eb:36:bd:ae",
"nodes" : [
{
"dataPlaneIp" : "192.168.57.103",
"dataPlaneIp" : "10.40.101.208",
"bridgeId" : "of:0000000000000001"
},
{
"dataPlaneIp" : "192.168.57.104",
"dataPlaneIp" : "10.40.101.227",
"bridgeId" : "of:0000000000000002"
},
{
"dataPlaneIp" : "192.168.57.105",
"dataPlaneIp" : "10.40.101.240",
"bridgeId" : "of:0000000000000003"
}
]
}
},
"org.onosproject.openstackswitching" : {
"openstackswitching" : {
"nodes" : [
{
"dataPlaneIp" : "192.168.57.103",
"bridgeId" : "of:0000000000000001"
},
{
"dataPlaneIp" : "192.168.57.104",
"bridgeId" : "of:0000000000000002"
},
{
"dataPlaneIp" : "192.168.57.105",
"bridgeId" : "of:0000000000000003"
}
]
}
},
"org.onosproject.openstacknode" : {
"openstacknode" : {
"nodes" : [
{
"hostname" : "compute-01",
"ovsdbIp" : "192.168.56.121",
"ovsdbPort" : "6640",
"bridgeId" : "of:0000000000000001",
"openstackNodeType" : "COMPUTENODE"
},
{
"hostname" : "compute-02",
"ovsdbIp" : "192.168.56.122",
"ovsdbPort" : "6640",
"bridgeId" : "of:0000000000000002",
"openstackNodeType" : "COMPUTENODE"
},
{
"hostname" : "network",
"ovsdbIp" : "192.168.56.114",
"ovsdbPort" : "6640",
"bridgeId" : "of:0000000000000003",
"openstackNodeType" : "GATEWAYNODE",
"gatewayExternalInterfaceName" : "veth0",
"gatewayExternalInterfaceMac" : "96:87:bc:64:99:ad"
}
]
}
},
"org.onosproject.openstackinterface" : {
"openstackinterface" : {
"neutron_server" : "http://192.168.56.118:9696/v2.0/",
"keystone_server" : "http://192.168.56.118:5000/v2.0/",
"user_name" : "admin",
"password" : "rocks"
}
}
},
"devices" : {
"of:0000000000000001" : {
"basic" : {
"driver" : "sona"
}
"apps" : {
"org.onosproject.openstackinterface" : {
"openstackinterface" : {
"neutronServer" : "http://10.40.101.209:9696/v2.0/",
"keystoneServer" : "http://10.40.101.209:5000/v2.0/",
"userName" : "admin",
"password" : "nova"
}
}
},
"of:0000000000000002" : {
"basic" : {
"driver" : "sona"
}
"devices" : {
"of:0000000000000001" : {
"basic" : {
"driver" : "sona"
}
},
"of:0000000000000002" : {
"basic" : {
"driver" : "sona"
}
}
}
}
}
......
......@@ -37,6 +37,7 @@ import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketService;
import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.onosproject.openstacknetworking.OpenstackPortInfo;
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
import org.slf4j.Logger;
......@@ -61,7 +62,7 @@ public class OpenstackIcmpHandler {
private final Map<String, OpenstackPortInfo> icmpInfoMap = Maps.newHashMap();
private final OpenstackSwitchingService openstackSwitchingService;
private final OpenstackInterfaceService openstackService;
private final OpenstackRoutingConfig config;
private final OpenstackNetworkingConfig config;
private static final MacAddress GATEWAY_MAC = MacAddress.valueOf("1f:1f:1f:1f:1f:1f");
private static final String NETWORK_ROUTER_INTERFACE = "network:router_interface";
private static final String PORTNAME = "portName";
......@@ -76,7 +77,7 @@ public class OpenstackIcmpHandler {
* @param openstackSwitchingService openstackSwitching service
*/
OpenstackIcmpHandler(PacketService packetService, DeviceService deviceService,
OpenstackInterfaceService openstackService, OpenstackRoutingConfig config,
OpenstackInterfaceService openstackService, OpenstackNetworkingConfig config,
OpenstackSwitchingService openstackSwitchingService) {
this.packetService = packetService;
this.deviceService = deviceService;
......
......@@ -33,6 +33,7 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackNetwork;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstackinterface.OpenstackRouter;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -56,12 +57,12 @@ public class OpenstackPnatHandler implements Runnable {
private final int portNum;
private final OpenstackPort openstackPort;
private final Port port;
private OpenstackRoutingConfig config;
private OpenstackNetworkingConfig config;
private static final String DEVICE_OWNER_ROUTER_INTERFACE = "network:router_interface";
OpenstackPnatHandler(OpenstackRoutingRulePopulator rulePopulator, PacketContext context,
int portNum, OpenstackPort openstackPort, Port port, OpenstackRoutingConfig config) {
int portNum, OpenstackPort openstackPort, Port port, OpenstackNetworkingConfig config) {
this.rulePopulator = checkNotNull(rulePopulator);
this.context = checkNotNull(context);
this.portNum = checkNotNull(portNum);
......
......@@ -33,6 +33,7 @@ import org.onosproject.net.packet.PacketPriority;
import org.onosproject.net.packet.PacketService;
import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.slf4j.Logger;
import java.nio.ByteBuffer;
......@@ -49,7 +50,7 @@ public class OpenstackRoutingArpHandler {
private final PacketService packetService;
private final OpenstackInterfaceService openstackService;
private final OpenstackRoutingConfig config;
private final OpenstackNetworkingConfig config;
private static final String NETWORK_ROUTER_GATEWAY = "network:router_gateway";
/**
......@@ -60,7 +61,7 @@ public class OpenstackRoutingArpHandler {
* @param config openstackRoutingConfig
*/
OpenstackRoutingArpHandler(PacketService packetService, OpenstackInterfaceService openstackService,
OpenstackRoutingConfig config) {
OpenstackNetworkingConfig config) {
this.packetService = packetService;
this.openstackService = checkNotNull(openstackService);
this.config = checkNotNull(config);
......
......@@ -37,7 +37,6 @@ import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flowobjective.FlowObjectiveService;
......@@ -50,8 +49,10 @@ import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstackinterface.OpenstackRouter;
import org.onosproject.openstackinterface.OpenstackRouterInterface;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.onosproject.openstacknetworking.OpenstackPortInfo;
import org.onosproject.openstacknetworking.OpenstackRoutingService;
import org.onosproject.openstacknetworking.OpenstackSubjectFactories;
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
......@@ -124,16 +125,19 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
private static final int PNAT_PORT_EXPIRE_TIME = 1200 * 1000;
private static final int TP_PORT_MINIMUM_NUM = 1024;
private static final int TP_PORT_MAXIMUM_NUM = 65535;
private final ConfigFactory configFactory =
new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, OpenstackRoutingConfig.class, "openstackrouting") {
new ConfigFactory(OpenstackSubjectFactories.USER_DEFINED_SUBJECT_FACTORY, OpenstackNetworkingConfig.class,
"config") {
@Override
public OpenstackRoutingConfig createConfig() {
return new OpenstackRoutingConfig();
public OpenstackNetworkingConfig createConfig() {
return new OpenstackNetworkingConfig();
}
};
private final NetworkConfigListener configListener = new InternalConfigListener();
private OpenstackRoutingConfig config;
private OpenstackNetworkingConfig config;
private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(KryoNamespaces.MISC)
......@@ -167,8 +171,6 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
configRegistry.registerConfigFactory(configFactory);
configService.addListener(configListener);
readConfiguration();
floatingIpMap = storageService.<String, OpenstackFloatingIP>consistentMapBuilder()
.withSerializer(Serializer.using(FLOATING_IP_SERIALIZER.build()))
.withName(FLOATING_IP_MAP_NAME)
......@@ -180,6 +182,8 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
.withApplicationId(appId)
.build();
readConfiguration();
log.info("onos-openstackrouting started");
}
......@@ -488,7 +492,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
}
private void readConfiguration() {
config = configService.getConfig(appId, OpenstackRoutingConfig.class);
config = configService.getConfig("openstacknetworking", OpenstackNetworkingConfig.class);
if (config == null) {
log.error("No configuration found");
return;
......@@ -499,7 +503,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
checkNotNull(config.gatewayExternalInterfaceMac());
checkNotNull(config.gatewayExternalInterfaceName());
log.debug("Configured info: {}, {}, {}, {}", config.physicalRouterMac(), config.gatewayBridgeId(),
log.warn("Configured info: {}, {}, {}, {}", config.physicalRouterMac(), config.gatewayBridgeId(),
config.gatewayExternalInterfaceMac(), config.gatewayExternalInterfaceName());
rulePopulator = new OpenstackRoutingRulePopulator(appId,
......@@ -512,6 +516,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
openstackIcmpHandler.requestPacket(appId);
openstackArpHandler.requestPacket(appId);
reloadInitL3Rules();
log.info("OpenstackRouting configured");
}
......@@ -519,7 +524,7 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
@Override
public void event(NetworkConfigEvent event) {
if (!event.configClass().equals(OpenstackRoutingConfig.class)) {
if (!event.configClass().equals(OpenstackNetworkingConfig.class)) {
return;
}
......
......@@ -52,6 +52,7 @@ import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstackinterface.OpenstackRouterInterface;
import org.onosproject.openstackinterface.OpenstackSubnet;
import org.onosproject.openstackinterface.OpenstackFloatingIP;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.onosproject.openstacknetworking.OpenstackPortInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -72,7 +73,7 @@ public class OpenstackRoutingRulePopulator {
private final OpenstackInterfaceService openstackService;
private final DeviceService deviceService;
private final DriverService driverService;
private final OpenstackRoutingConfig config;
private final OpenstackNetworkingConfig config;
private static final String PORTNAME_PREFIX_TUNNEL = "vxlan";
private static final String PORTNAME = "portName";
......@@ -106,7 +107,7 @@ public class OpenstackRoutingRulePopulator {
*/
public OpenstackRoutingRulePopulator(ApplicationId appId, OpenstackInterfaceService openstackService,
FlowObjectiveService flowObjectiveService, DeviceService deviceService,
DriverService driverService, OpenstackRoutingConfig config) {
DriverService driverService, OpenstackNetworkingConfig config) {
this.appId = appId;
this.flowObjectiveService = flowObjectiveService;
this.openstackService = checkNotNull(openstackService);
......
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.openstacknetworking.switching;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Maps;
import org.onlab.packet.Ip4Address;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.config.Config;
import org.slf4j.Logger;
import java.util.Map;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Configuration object for OpenstackSwitching service.
*/
public class OpenstackSwitchingConfig extends Config<ApplicationId> {
protected final Logger log = getLogger(getClass());
public static final String NODES = "nodes";
public static final String DATAPLANE_IP = "dataPlaneIp";
public static final String BRIDGE_ID = "bridgeId";
/**
* Returns the data plane IP map of nodes read from network config.
*
* @return data plane IP map
*/
public Map<DeviceId, Ip4Address> nodes() {
Map<DeviceId, Ip4Address> nodeMap = Maps.newHashMap();
JsonNode jsonNodes = object.get(NODES);
if (jsonNodes == null) {
log.error("There's no node information");
return null;
}
jsonNodes.forEach(jsonNode -> {
try {
nodeMap.putIfAbsent(DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()),
Ip4Address.valueOf(jsonNode.path(DATAPLANE_IP).asText()));
} catch (IllegalArgumentException | NullPointerException e) {
log.error("Failed to read {}", e.getMessage());
}
});
return nodeMap;
}
}
......@@ -38,7 +38,6 @@ import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
......@@ -57,6 +56,8 @@ import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstackinterface.OpenstackSecurityGroup;
import org.onosproject.openstackinterface.OpenstackSubnet;
import org.onosproject.openstacknetworking.OpenstackPortInfo;
import org.onosproject.openstacknetworking.OpenstackSubjectFactories;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.onosproject.openstacknetworking.OpenstackSwitchingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -99,6 +100,9 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
protected DriverService driverService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigRegistry networkConfig;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenstackInterfaceService openstackService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......@@ -136,16 +140,16 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
private Map<String, OpenstackSecurityGroup> securityGroupMap = Maps.newConcurrentMap();
private final ConfigFactory configFactory =
new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY,
OpenstackSwitchingConfig.class, "openstackswitching") {
new ConfigFactory(OpenstackSubjectFactories.USER_DEFINED_SUBJECT_FACTORY, OpenstackNetworkingConfig.class,
"config") {
@Override
public OpenstackSwitchingConfig createConfig() {
return new OpenstackSwitchingConfig();
public OpenstackNetworkingConfig createConfig() {
return new OpenstackNetworkingConfig();
}
};
private final NetworkConfigListener configListener = new InternalConfigListener();
private OpenstackSwitchingConfig config;
private OpenstackNetworkingConfig config;
@Activate
protected void activate() {
......@@ -158,6 +162,12 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
configRegistry.registerConfigFactory(configFactory);
configService.addListener(configListener);
arpHandler = new OpenstackArpHandler(openstackService, packetService, hostService);
sgRulePopulator = new OpenstackSecurityGroupRulePopulator(appId, openstackService, flowObjectiveService);
networkConfig.registerConfigFactory(configFactory);
networkConfig.addListener(configListener);
readConfiguration();
log.info("Started");
......@@ -484,7 +494,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
}
private void readConfiguration() {
config = configService.getConfig(appId, OpenstackSwitchingConfig.class);
config = configService.getConfig("openstacknetworking", OpenstackNetworkingConfig.class);
if (config == null) {
log.error("No configuration found");
return;
......@@ -500,7 +510,7 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
@Override
public void event(NetworkConfigEvent event) {
if (!event.configClass().equals(OpenstackSwitchingConfig.class)) {
if (!event.configClass().equals(OpenstackNetworkingConfig.class)) {
return;
}
......@@ -508,7 +518,6 @@ public class OpenstackSwitchingManager implements OpenstackSwitchingService {
event.type().equals(NetworkConfigEvent.Type.CONFIG_UPDATED)) {
configEventExecutorService.execute(OpenstackSwitchingManager.this::readConfiguration);
}
}
}
......
......@@ -43,6 +43,7 @@ import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.openstackinterface.OpenstackInterfaceService;
import org.onosproject.openstackinterface.OpenstackNetwork;
import org.onosproject.openstackinterface.OpenstackPort;
import org.onosproject.openstacknetworking.OpenstackNetworkingConfig;
import org.onosproject.openstacknetworking.OpenstackPortInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -65,7 +66,7 @@ public class OpenstackSwitchingRulePopulator {
private DriverService driverService;
private DeviceService deviceService;
private ApplicationId appId;
private OpenstackSwitchingConfig config;
private OpenstackNetworkingConfig config;
private Collection<OpenstackNetwork> openstackNetworkList;
private Collection<OpenstackPort> openstackPortList;
......@@ -85,7 +86,7 @@ public class OpenstackSwitchingRulePopulator {
DeviceService deviceService,
OpenstackInterfaceService openstackService,
DriverService driverService,
OpenstackSwitchingConfig config) {
OpenstackNetworkingConfig config) {
this.flowObjectiveService = flowObjectiveService;
this.deviceService = deviceService;
this.driverService = driverService;
......