Remove CORD config dependency from SR
SR now offers a clean way to config OLT control and data plane traffic.
For OLT data traffic, we can use vlanTagged config.
For OLT control traffic, we can use vlanUntagged/vlanNative + host config.
Change-Id: Icf7d345374d572711798a55b5a2349ad1f5d1fc9
diff --git a/BUCK b/BUCK
index 2c26e54..865cd75 100644
--- a/BUCK
+++ b/BUCK
@@ -2,7 +2,6 @@
'//lib:CORE_DEPS',
'//lib:org.apache.karaf.shell.console',
'//lib:javax.ws.rs-api',
- '//lib:cord-config',
'//cli:onos-cli',
'//core/store/serializers:onos-core-serializers',
'//incubator/api:onos-incubator-api',
@@ -12,7 +11,6 @@
BUNDLES = [
'//apps/segmentrouting:onos-apps-segmentrouting',
'//apps/routing-api:onos-apps-routing-api',
- '//lib:cord-config'
]
TEST_DEPS = [
diff --git a/app.xml b/app.xml
index 7af44fb..b7ee384 100644
--- a/app.xml
+++ b/app.xml
@@ -20,6 +20,4 @@
features="${project.artifactId}" apps="">
<description>${project.description}</description>
<artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
- <!-- TODO: Replace this with variable -->
- <artifact>mvn:org.onosproject/cord-config/1.0-b1</artifact>
</app>
diff --git a/features.xml b/features.xml
index 6684345..416afe5 100644
--- a/features.xml
+++ b/features.xml
@@ -19,7 +19,5 @@
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
- <!-- TODO: Replace this with variable -->
- <bundle>mvn:org.onosproject/cord-config/1.0-b1</bundle>
</feature>
</features>
diff --git a/pom.xml b/pom.xml
index ddd72ce..521288e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,12 +65,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>cord-config</artifactId>
- <!-- TODO: Replace this with variable -->
- <version>1.0-b1</version>
- </dependency>
- <dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
diff --git a/src/main/java/org/onosproject/segmentrouting/CordConfigHandler.java b/src/main/java/org/onosproject/segmentrouting/CordConfigHandler.java
deleted file mode 100644
index 34f5d1e..0000000
--- a/src/main/java/org/onosproject/segmentrouting/CordConfigHandler.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2016-present 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.segmentrouting;
-
-import com.google.common.collect.ImmutableSet;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultHost;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.HostLocation;
-import org.onosproject.net.provider.ProviderId;
-import org.opencord.cordconfig.CordConfigEvent;
-import org.opencord.cordconfig.access.AccessAgentData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Optional;
-
-/**
- * Handles access agent config event which is required for CORD integration.
- */
-public class CordConfigHandler {
- private static Logger log = LoggerFactory.getLogger(CordConfigHandler.class);
- private final SegmentRoutingManager srManager;
-
- /**
- * Constructs the CordConfigHandler.
- *
- * @param srManager Segment Routing manager
- */
- public CordConfigHandler(SegmentRoutingManager srManager) {
- this.srManager = srManager;
- }
-
- /**
- * Read initial access agent config for given device.
- *
- * @param deviceId ID of the device to be initialized
- */
- public void init(DeviceId deviceId) {
- // Try to read access agent config
- Optional<AccessAgentData> accessAgent =
- srManager.cordConfigService.getAccessAgent(deviceId);
-
- if (!accessAgent.isPresent()) {
- log.debug("No access agent config on {}. Skip.", deviceId);
- return;
- }
-
- processAccessAgentAdded(accessAgent.get());
- }
-
- // TODO javadoc
- protected void processAccessAgentAddedEvent(CordConfigEvent event) {
- log.debug("processAccessAgentAdded: {}, {}", event.subject(), event.prevSubject());
- processAccessAgentAdded((AccessAgentData) event.subject());
- }
-
- protected void processAccessAgentUpdatedEvent(CordConfigEvent event) {
- log.debug("processAccessAgentUpdated: {}, {}", event.subject(), event.prevSubject());
- processAccessAgentRemoved((AccessAgentData) event.prevSubject());
- processAccessAgentAdded((AccessAgentData) event.subject());
- }
-
- protected void processAccessAgentRemovedEvent(CordConfigEvent event) {
- log.debug("processAccessAgentRemoved: {}, {}", event.subject(), event.prevSubject());
- processAccessAgentRemoved((AccessAgentData) event.prevSubject());
- }
-
- protected void processAccessAgentAdded(AccessAgentData accessAgentData) {
- if (!srManager.mastershipService.isLocalMaster(accessAgentData.deviceId())) {
- log.debug("Not the master of {}. Abort.", accessAgentData.deviceId());
- return;
- }
-
- // Do not proceed if vtn location is missing
- if (!accessAgentData.getVtnLocation().isPresent()) {
- log.warn("accessAgentData does not contain vtn location. Abort.");
- return;
- }
-
- MacAddress agentMac = accessAgentData.getAgentMac();
- ConnectPoint agentLocation = accessAgentData.getVtnLocation().get();
-
- // Do not proceed if agent port doesn't have subnet configured
- Ip4Prefix agentSubnet = srManager.deviceConfiguration
- .getPortIPv4Subnet(agentLocation.deviceId(), agentLocation.port());
- if (agentSubnet == null) {
- log.warn("Agent port does not have subnet configuration. Abort.");
- return;
- }
-
- // Add host information for agent
- log.info("push host info for agent {}", agentMac);
- srManager.hostHandler.processHostAdded(createHost(agentMac, agentLocation));
-
- accessAgentData.getOltMacInfo().forEach((connectPoint, macAddress) -> {
- // Do not proceed if olt port has subnet configured
- Ip4Prefix oltSubnet = srManager.deviceConfiguration
- .getPortIPv4Subnet(connectPoint.deviceId(), connectPoint.port());
- if (oltSubnet != null) {
- log.warn("OLT port has subnet configuration. Abort.");
- return;
- }
-
- // Add olt to the subnet of agent
- log.info("push subnet for olt {}", agentSubnet);
- srManager.deviceConfiguration.addSubnet(connectPoint, agentSubnet);
- srManager.routingRulePopulator.populateVlanMacFilters(connectPoint.deviceId());
-
- // Add host information for olt
- log.info("push host info for olt {}", macAddress);
- srManager.hostHandler.processHostAdded(createHost(macAddress, connectPoint));
- });
- }
-
- protected void processAccessAgentRemoved(AccessAgentData accessAgentData) {
- if (!srManager.mastershipService.isLocalMaster(accessAgentData.deviceId())) {
- log.debug("Not the master of {}. Abort.", accessAgentData.deviceId());
- return;
- }
-
- // Do not proceed if vtn location is missing
- if (!accessAgentData.getVtnLocation().isPresent()) {
- log.warn("accessAgentData does not contain vtn location. Abort.");
- return;
- }
-
- MacAddress agentMac = accessAgentData.getAgentMac();
- ConnectPoint agentLocation = accessAgentData.getVtnLocation().get();
-
- // Do not proceed if olt port doesn't have subnet configured
- Ip4Prefix agentSubnet = srManager.deviceConfiguration
- .getPortIPv4Subnet(agentLocation.deviceId(), agentLocation.port());
- if (agentSubnet == null) {
- log.warn("Agent port does not have subnet configuration. Abort.");
- return;
- }
-
- // Remove host information for agent
- log.info("delete host info for agent {}", agentMac);
- srManager.hostHandler.processHostRemoved(createHost(agentMac, agentLocation));
-
- accessAgentData.getOltMacInfo().forEach((connectPoint, macAddress) -> {
- // Do not proceed if agent port doesn't have subnet configured
- Ip4Prefix oltSubnet = srManager.deviceConfiguration
- .getPortIPv4Subnet(connectPoint.deviceId(), connectPoint.port());
- if (oltSubnet == null) {
- log.warn("OLT port does not have subnet configuration. Abort.");
- return;
- }
-
- // Remove host information for olt
- log.info("delete host info for olt {}", macAddress);
- srManager.hostHandler.processHostRemoved(createHost(macAddress, connectPoint));
-
- // Remove olt to the subnet of agent
- log.info("delete subnet for olt {}", agentSubnet);
- srManager.deviceConfiguration.removeSubnet(connectPoint, agentSubnet);
- srManager.routingRulePopulator.populateVlanMacFilters(connectPoint.deviceId());
- });
- }
-
- private Host createHost(MacAddress macAddress, ConnectPoint location) {
- return new DefaultHost(
- new ProviderId("host", "org.onosproject.segmentrouting"),
- HostId.hostId(macAddress),
- macAddress,
- VlanId.NONE,
- new HostLocation(location, System.currentTimeMillis()),
- ImmutableSet.of());
- }
-}
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 5b05187..c783081 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -94,9 +94,6 @@
import org.onosproject.store.service.EventuallyConsistentMapBuilder;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.WallClockTimestamp;
-import org.opencord.cordconfig.CordConfigEvent;
-import org.opencord.cordconfig.CordConfigListener;
-import org.opencord.cordconfig.CordConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -164,9 +161,6 @@
TopologyService topologyService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- CordConfigService cordConfigService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
RouteService routeService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -192,7 +186,6 @@
XConnectHandler xConnectHandler = null;
private McastHandler mcastHandler = null;
HostHandler hostHandler = null;
- private CordConfigHandler cordConfigHandler = null;
private RouteHandler routeHandler = null;
private SegmentRoutingNeighbourDispatcher neighbourHandler = null;
private L2TunnelHandler l2TunnelHandler = null;
@@ -200,7 +193,6 @@
private final InternalHostListener hostListener = new InternalHostListener();
private final InternalConfigListener cfgListener = new InternalConfigListener(this);
private final InternalMcastListener mcastListener = new InternalMcastListener();
- private final InternalCordConfigListener cordConfigListener = new InternalCordConfigListener();
private final InternalRouteEventListener routeListener = new InternalRouteEventListener();
private ScheduledExecutorService executorService = Executors
@@ -367,7 +359,6 @@
xConnectHandler = new XConnectHandler(this);
mcastHandler = new McastHandler(this);
hostHandler = new HostHandler(this);
- cordConfigHandler = new CordConfigHandler(this);
routeHandler = new RouteHandler(this);
neighbourHandler = new SegmentRoutingNeighbourDispatcher(this);
l2TunnelHandler = new L2TunnelHandler(this);
@@ -383,7 +374,6 @@
linkService.addListener(linkListener);
deviceService.addListener(deviceListener);
multicastRouteService.addListener(mcastListener);
- cordConfigService.addListener(cordConfigListener);
cfgListener.configureNetwork();
@@ -422,7 +412,6 @@
linkService.removeListener(linkListener);
deviceService.removeListener(deviceListener);
multicastRouteService.removeListener(mcastListener);
- cordConfigService.removeListener(cordConfigListener);
routeService.removeListener(routeListener);
neighbourResolutionService.unregisterNeighbourHandlers(appId);
@@ -995,7 +984,6 @@
defaultRoutingHandler.populatePortAddressingRules(deviceId);
hostHandler.init(deviceId);
xConnectHandler.init(deviceId);
- cordConfigHandler.init(deviceId);
DefaultGroupHandler groupHandler = groupHandlerMap.get(deviceId);
groupHandler.createGroupsFromVlanConfig();
routingRulePopulator.populateSubnetBroadcastRule(deviceId);
@@ -1266,28 +1254,6 @@
}
}
- private class InternalCordConfigListener implements CordConfigListener {
- @Override
- public void event(CordConfigEvent event) {
- switch (event.type()) {
- case ACCESS_AGENT_ADDED:
- cordConfigHandler.processAccessAgentAddedEvent(event);
- break;
- case ACCESS_AGENT_UPDATED:
- cordConfigHandler.processAccessAgentUpdatedEvent(event);
- break;
- case ACCESS_AGENT_REMOVED:
- cordConfigHandler.processAccessAgentRemovedEvent(event);
- break;
- case ACCESS_DEVICE_ADDED:
- case ACCESS_DEVICE_UPDATED:
- case ACCESS_DEVICE_REMOVED:
- default:
- break;
- }
- }
- }
-
private class InternalRouteEventListener implements RouteListener {
@Override
public void event(RouteEvent event) {