CORD-129 Support access agent in VTN
- Add ACCESS_AGENT type instance based on the access agent location
- Populate flow rules to provider L2 connectivity with OLTs
- Don't check "tap" port name prefix considering container instance
- Changed table name ACCESS_TYPE to ACCESS, DST_IP to DST
Change-Id: I3854f94d371243cde3b1ca1ecfbfb68ef53e0759
diff --git a/src/main/java/org/opencord/cordvtn/api/Constants.java b/src/main/java/org/opencord/cordvtn/api/Constants.java
index bee5734..9fd3b2c 100644
--- a/src/main/java/org/opencord/cordvtn/api/Constants.java
+++ b/src/main/java/org/opencord/cordvtn/api/Constants.java
@@ -15,6 +15,7 @@
*/
package org.opencord.cordvtn.api;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.TpPort;
/**
@@ -34,8 +35,10 @@
public static final String DEFAULT_TUNNEL = "vxlan";
public static final String INTEGRATION_BRIDGE = "br-int";
- public static final String VPORT_PREFIX = "tap";
+ public static final String NOT_APPLICABLE = "N/A";
public static final int OF_PORT = 6653;
public static final TpPort OVSDB_PORT = TpPort.tpPort(6640);
+ public static final Ip4Address DEFAULT_DNS = Ip4Address.valueOf("8.8.8.8");
+ public static final int DHCP_INFINITE_LEASE = -1;
}
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnArpProxy.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnArpProxy.java
index 1697f1a..d1dfdd2 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnArpProxy.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnArpProxy.java
@@ -52,6 +52,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.xosclient.api.VtnServiceApi.NetworkType.PRIVATE;
+import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.ACCESS_AGENT;
import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.MANAGEMENT;
import static org.slf4j.LoggerFactory.getLogger;
@@ -338,6 +339,12 @@
@Override
public void instanceDetected(Instance instance) {
+ // TODO remove this when XOS provides access agent information
+ // and handle it the same way wit the other instances
+ if (instance.serviceType() == ACCESS_AGENT) {
+ return;
+ }
+
VtnService service = getVtnService(instance.serviceId());
if (service == null) {
return;
@@ -353,6 +360,12 @@
@Override
public void instanceRemoved(Instance instance) {
+ // TODO remove this when XOS provides access agent information
+ // and handle it the same way wit the other instances
+ if (instance.serviceType() == ACCESS_AGENT) {
+ return;
+ }
+
VtnService service = getVtnService(instance.serviceId());
if (service == null) {
return;
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
index 1926f03..82bb0a9 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
@@ -431,7 +431,8 @@
// adds existing instances to the host list
deviceService.getPorts(node.integrationBridgeId()).stream()
- .filter(port -> portName(port).startsWith(VPORT_PREFIX) &&
+ .filter(port -> !node.systemIfaces().contains(portName(port)) &&
+ !port.number().equals(PortNumber.LOCAL) &&
port.isEnabled())
.forEach(port -> instanceService.addInstance(connectPoint(port)));
@@ -752,14 +753,12 @@
log.info("Port {} is added to {}", portName, node.hostname());
- if (portName.startsWith(VPORT_PREFIX)) {
- if (isNodeStateComplete(node)) {
- instanceService.addInstance(connectPoint(port));
- } else {
- log.warn("VM is detected on incomplete node, ignore it.", portName);
- }
- } else if (node.systemIfaces().contains(portName)) {
+ if (node.systemIfaces().contains(portName)) {
setNodeState(node, getNodeState(node));
+ } else if (isNodeStateComplete(node)) {
+ instanceService.addInstance(connectPoint(port));
+ } else {
+ log.warn("Instance is detected on incomplete node, ignore it.", portName);
}
}
@@ -780,14 +779,12 @@
log.info("Port {} is removed from {}", portName, node.hostname());
- if (portName.startsWith(VPORT_PREFIX)) {
- if (isNodeStateComplete(node)) {
- instanceService.removeInstance(connectPoint(port));
- } else {
- log.warn("VM is vanished from incomplete node, ignore it.", portName);
- }
- } else if (node.systemIfaces().contains(portName)) {
+ if (node.systemIfaces().contains(portName)) {
setNodeState(node, NodeState.INCOMPLETE);
+ } else if (isNodeStateComplete(node)) {
+ instanceService.removeInstance(connectPoint(port));
+ } else {
+ log.warn("VM is vanished from incomplete node, ignore it.", portName);
}
}
}
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
index 4e01d2b..0bea32e 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
@@ -79,9 +79,9 @@
// tables
public static final int TABLE_ZERO = 0;
public static final int TABLE_IN_PORT = 1;
- public static final int TABLE_ACCESS_TYPE = 2;
+ public static final int TABLE_ACCESS = 2;
public static final int TABLE_IN_SERVICE = 3;
- public static final int TABLE_DST_IP = 4;
+ public static final int TABLE_DST = 4;
public static final int TABLE_TUNNEL_IN = 5;
public static final int TABLE_VLAN = 6;
@@ -320,7 +320,7 @@
.build();
treatment = DefaultTrafficTreatment.builder()
- .transition(CordVtnPipeline.TABLE_DST_IP)
+ .transition(CordVtnPipeline.TABLE_DST)
.build();
flowRule = DefaultFlowRule.builder()
@@ -406,7 +406,7 @@
.build();
treatment = DefaultTrafficTreatment.builder()
- .transition(TABLE_DST_IP)
+ .transition(TABLE_DST)
.build();
flowRule = DefaultFlowRule.builder()
@@ -427,7 +427,7 @@
.build();
treatment = DefaultTrafficTreatment.builder()
- .transition(TABLE_DST_IP)
+ .transition(TABLE_DST)
.build();
flowRule = DefaultFlowRule.builder()
@@ -458,7 +458,7 @@
.withTreatment(treatment)
.withPriority(PRIORITY_ZERO)
.forDevice(deviceId)
- .forTable(TABLE_ACCESS_TYPE)
+ .forTable(TABLE_ACCESS)
.makePermanent()
.build();
diff --git a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
index eaebb69..c22982b 100644
--- a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
@@ -27,6 +27,7 @@
import org.onlab.packet.Ethernet;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
+import org.onosproject.xosclient.api.VtnServiceApi;
import org.opencord.cordvtn.api.CordVtnNode;
import org.opencord.cordvtn.api.DependencyService;
import org.opencord.cordvtn.api.Instance;
@@ -124,6 +125,12 @@
@Override
public void instanceDetected(Instance instance) {
+ // TODO remove this when XOS provides access agent information
+ // and handle it the same way wit the other instances
+ if (instance.serviceType() == VtnServiceApi.ServiceType.ACCESS_AGENT) {
+ return;
+ }
+
VtnService service = getVtnService(instance.serviceId());
if (service == null) {
return;
@@ -140,6 +147,12 @@
@Override
public void instanceRemoved(Instance instance) {
+ // TODO remove this when XOS provides access agent information
+ // and handle it the same way wit the other instances
+ if (instance.serviceType() == VtnServiceApi.ServiceType.ACCESS_AGENT) {
+ return;
+ }
+
VtnService service = getVtnService(instance.serviceId());
if (service == null) {
return;
@@ -259,7 +272,7 @@
.withTreatment(treatment)
.withPriority(PRIORITY_HIGH)
.forDevice(outGroup.getKey())
- .forTable(TABLE_ACCESS_TYPE)
+ .forTable(TABLE_ACCESS)
.makePermanent()
.build();
@@ -275,7 +288,7 @@
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .transition(TABLE_DST_IP)
+ .transition(TABLE_DST)
.build();
nodeManager.completeNodes().stream().forEach(node -> {
@@ -286,7 +299,7 @@
.withTreatment(treatment)
.withPriority(PRIORITY_DEFAULT)
.forDevice(deviceId)
- .forTable(TABLE_ACCESS_TYPE)
+ .forTable(TABLE_ACCESS)
.makePermanent()
.build();
diff --git a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
index 2f73eee..b02fb52 100644
--- a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
@@ -25,6 +25,8 @@
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
+import org.opencord.cordconfig.CordConfigService;
+import org.opencord.cordconfig.access.AccessAgentData;
import org.opencord.cordvtn.api.CordVtnConfig;
import org.opencord.cordvtn.api.Instance;
import org.onosproject.core.ApplicationId;
@@ -63,6 +65,7 @@
import org.slf4j.Logger;
import java.util.Date;
+import java.util.Optional;
import java.util.concurrent.ExecutorService;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -70,6 +73,7 @@
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.dhcp.IpAssignment.AssignmentStatus.Option_RangeNotEnforced;
import static org.onosproject.net.AnnotationKeys.PORT_NAME;
+import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.ACCESS_AGENT;
import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.MANAGEMENT;
import static org.opencord.cordvtn.api.Constants.*;
import static org.slf4j.LoggerFactory.getLogger;
@@ -84,9 +88,6 @@
protected final Logger log = getLogger(getClass());
- private static final Ip4Address DEFAULT_DNS = Ip4Address.valueOf("8.8.8.8");
- private static final int DHCP_INFINITE_LEASE = -1;
-
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -108,8 +109,14 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected XosClientService xosClient;
+ // TODO get access agent container information from XOS
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CordConfigService cordConfig;
+
+ private static final Class<CordVtnConfig> CONFIG_CLASS = CordVtnConfig.class;
private final ConfigFactory configFactory =
- new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, CordVtnConfig.class, "cordvtn") {
+ new ConfigFactory<ApplicationId, CordVtnConfig>(
+ SubjectFactories.APP_SUBJECT_FACTORY, CONFIG_CLASS, "cordvtn") {
@Override
public CordVtnConfig createConfig() {
return new CordVtnConfig();
@@ -117,7 +124,7 @@
};
private final ExecutorService eventExecutor =
- newSingleThreadExecutor(groupedThreads("onos/cordvtn-instance", "event-handler", log));
+ newSingleThreadExecutor(groupedThreads(this.getClass().getSimpleName(), "event-handler"));
private final NetworkConfigListener configListener = new InternalConfigListener();
private ApplicationId appId;
@@ -170,6 +177,13 @@
return;
}
+ // TODO remove this when XOS provides access agent information
+ // and handle it the same way wit the other instances
+ if (isAccessAgent(connectPoint)) {
+ addAccessAgentInstance(connectPoint);
+ return;
+ }
+
VtnPort vtnPort = getVtnPort(port.annotations().value(PORT_NAME));
if (vtnPort == null) {
return;
@@ -281,8 +295,37 @@
return vtnPort;
}
+ // TODO remove this when XOS provides access agent information
+ private boolean isAccessAgent(ConnectPoint connectPoint) {
+ Optional<AccessAgentData> agent = cordConfig.getAccessAgent(connectPoint.deviceId());
+ if (!agent.isPresent() || !agent.get().getVtnLocation().isPresent()) {
+ return false;
+ }
+ return agent.get().getVtnLocation().get().port().equals(connectPoint.port());
+ }
+
+ // TODO remove this when XOS provides access agent information
+ private void addAccessAgentInstance(ConnectPoint connectPoint) {
+ AccessAgentData agent = cordConfig.getAccessAgent(connectPoint.deviceId()).get();
+ DefaultAnnotations.Builder annotations = DefaultAnnotations.builder()
+ .set(Instance.SERVICE_TYPE, ACCESS_AGENT.name())
+ .set(Instance.SERVICE_ID, NOT_APPLICABLE)
+ .set(Instance.PORT_ID, NOT_APPLICABLE)
+ .set(Instance.CREATE_TIME, String.valueOf(System.currentTimeMillis()));
+
+ HostDescription hostDesc = new DefaultHostDescription(
+ agent.getAgentMac(),
+ VlanId.NONE,
+ new HostLocation(connectPoint, System.currentTimeMillis()),
+ Sets.newHashSet(),
+ annotations.build());
+
+ HostId hostId = HostId.hostId(agent.getAgentMac());
+ hostProvider.hostDetected(hostId, hostDesc, false);
+ }
+
private void readConfiguration() {
- CordVtnConfig config = configRegistry.getConfig(appId, CordVtnConfig.class);
+ CordVtnConfig config = configRegistry.getConfig(appId, CONFIG_CLASS);
if (config == null) {
log.debug("No configuration found");
return;
@@ -297,13 +340,13 @@
@Override
public void event(NetworkConfigEvent event) {
- if (!event.configClass().equals(CordVtnConfig.class)) {
+ if (!event.configClass().equals(CONFIG_CLASS)) {
return;
}
switch (event.type()) {
- case CONFIG_ADDED:
case CONFIG_UPDATED:
+ case CONFIG_ADDED:
readConfiguration();
break;
default:
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/AccessAgentInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/AccessAgentInstanceHandler.java
new file mode 100644
index 0000000..b2de2c3
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/AccessAgentInstanceHandler.java
@@ -0,0 +1,116 @@
+/*
+ * 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.opencord.cordvtn.impl.handler;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.opencord.cordvtn.impl.AbstractInstanceHandler;
+import org.opencord.cordvtn.api.Instance;
+import org.opencord.cordvtn.api.InstanceHandler;
+import org.opencord.cordvtn.impl.CordVtnNodeManager;
+import org.opencord.cordvtn.impl.CordVtnPipeline;
+
+import java.util.Optional;
+
+import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.ACCESS_AGENT;
+
+/**
+ * Provides network connectivity for access agent instances.
+ */
+@Component(immediate = true)
+public class AccessAgentInstanceHandler extends AbstractInstanceHandler implements InstanceHandler {
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CordVtnPipeline pipeline;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CordVtnNodeManager nodeManager;
+
+ @Activate
+ protected void activate() {
+ serviceType = Optional.of(ACCESS_AGENT);
+ super.activate();
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ super.deactivate();
+ }
+
+ @Override
+ public void instanceDetected(Instance instance) {
+ log.info("Access agent instance detected {}", instance);
+ accessAgentRules(instance, true);
+ }
+
+ @Override
+ public void instanceRemoved(Instance instance) {
+ log.info("Access agent instance removed {}", instance);
+ accessAgentRules(instance, false);
+ }
+
+ private void accessAgentRules(Instance instance, boolean install) {
+ TrafficSelector selector = DefaultTrafficSelector.builder()
+ .matchEthDst(instance.mac())
+ .build();
+
+ TrafficTreatment treatment = DefaultTrafficTreatment.builder()
+ .setOutput(instance.portNumber())
+ .build();
+
+ FlowRule flowRule = DefaultFlowRule.builder()
+ .fromApp(appId)
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
+ .forDevice(instance.deviceId())
+ .forTable(CordVtnPipeline.TABLE_DST)
+ .makePermanent()
+ .build();
+
+ pipeline.processFlowRule(install, flowRule);
+
+ selector = DefaultTrafficSelector.builder()
+ .matchInPort(instance.portNumber())
+ .build();
+
+ treatment = DefaultTrafficTreatment.builder()
+ .setOutput(nodeManager.dataPort(instance.deviceId()))
+ .build();
+
+ flowRule = DefaultFlowRule.builder()
+ .fromApp(appId)
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
+ .forDevice(instance.deviceId())
+ .forTable(CordVtnPipeline.TABLE_IN_PORT)
+ .makePermanent()
+ .build();
+
+ pipeline.processFlowRule(install, flowRule);
+ }
+}
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
index a4ca067..0036578 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
@@ -115,7 +115,7 @@
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .transition(CordVtnPipeline.TABLE_ACCESS_TYPE)
+ .transition(CordVtnPipeline.TABLE_ACCESS)
.build();
FlowRule flowRule = DefaultFlowRule.builder()
@@ -170,7 +170,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(instance.deviceId())
- .forTable(CordVtnPipeline.TABLE_DST_IP)
+ .forTable(CordVtnPipeline.TABLE_DST)
.makePermanent()
.build();
@@ -200,7 +200,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(node.integrationBridgeId())
- .forTable(CordVtnPipeline.TABLE_DST_IP)
+ .forTable(CordVtnPipeline.TABLE_DST)
.makePermanent()
.build();
@@ -239,7 +239,7 @@
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .transition(CordVtnPipeline.TABLE_DST_IP)
+ .transition(CordVtnPipeline.TABLE_DST)
.build();
@@ -250,7 +250,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(node.integrationBridgeId())
- .forTable(CordVtnPipeline.TABLE_ACCESS_TYPE)
+ .forTable(CordVtnPipeline.TABLE_ACCESS)
.makePermanent()
.build();
@@ -275,7 +275,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_LOW)
.forDevice(node.integrationBridgeId())
- .forTable(CordVtnPipeline.TABLE_ACCESS_TYPE)
+ .forTable(CordVtnPipeline.TABLE_ACCESS)
.makePermanent()
.build();
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/ManagementInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/ManagementInstanceHandler.java
index f369df1..7e0285e 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/ManagementInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/ManagementInstanceHandler.java
@@ -123,7 +123,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(instance.deviceId())
- .forTable(CordVtnPipeline.TABLE_DST_IP)
+ .forTable(CordVtnPipeline.TABLE_DST)
.makePermanent()
.build();
@@ -173,7 +173,7 @@
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(instance.deviceId())
- .forTable(CordVtnPipeline.TABLE_DST_IP)
+ .forTable(CordVtnPipeline.TABLE_DST)
.makePermanent()
.build();
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/OltAgentInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/OltAgentInstanceHandler.java
deleted file mode 100644
index e6dd406..0000000
--- a/src/main/java/org/opencord/cordvtn/impl/handler/OltAgentInstanceHandler.java
+++ /dev/null
@@ -1,116 +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.opencord.cordvtn.impl.handler;
-
-import com.google.common.collect.Maps;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-
-import org.opencord.cordvtn.impl.AbstractInstanceHandler;
-import org.opencord.cordvtn.api.CordVtnConfig;
-import org.opencord.cordvtn.api.Instance;
-import org.opencord.cordvtn.api.InstanceHandler;
-import org.onosproject.net.DeviceId;
-
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.opencord.cordconfig.access.AccessAgentConfig;
-import org.opencord.cordconfig.access.AccessAgentData;
-
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.onosproject.xosclient.api.VtnServiceApi.ServiceType.ACCESS_AGENT;
-
-/**
- * Provides network connectivity for OLT agent instances.
- */
-@Component(immediate = true)
-public class OltAgentInstanceHandler extends AbstractInstanceHandler implements InstanceHandler {
-
- private static final Class<AccessAgentConfig> CONFIG_CLASS = AccessAgentConfig.class;
- private ConfigFactory<DeviceId, AccessAgentConfig> configFactory =
- new ConfigFactory<DeviceId, AccessAgentConfig>(
- SubjectFactories.DEVICE_SUBJECT_FACTORY, CONFIG_CLASS, "accessAgent") {
- @Override
- public AccessAgentConfig createConfig() {
- return new AccessAgentConfig();
- }
- };
-
- private Map<DeviceId, AccessAgentData> oltAgentData = Maps.newConcurrentMap();
-
- @Activate
- protected void activate() {
- serviceType = Optional.of(ACCESS_AGENT);
- configListener = new InternalConfigListener();
- super.activate();
-
- configRegistry.registerConfigFactory(configFactory);
- }
-
- @Deactivate
- protected void deactivate() {
- super.deactivate();
- }
-
- @Override
- public void instanceDetected(Instance instance) {
- log.info("OLT agent instance detected {}", instance);
- // TODO implement
- }
-
- @Override
- public void instanceRemoved(Instance instance) {
- log.info("OLT agent instance removed {}", instance);
- // TODO implement
- }
-
- private void readAccessAgentConfig() {
-
- Set<DeviceId> deviceSubjects = configRegistry.getSubjects(DeviceId.class, CONFIG_CLASS);
- deviceSubjects.stream().forEach(subject -> {
- AccessAgentConfig config = configRegistry.getConfig(subject, CONFIG_CLASS);
- if (config != null) {
- oltAgentData.put(subject, config.getAgent());
- }
- });
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
-
- switch (event.type()) {
- case CONFIG_UPDATED:
- case CONFIG_ADDED:
- if (event.configClass().equals(CordVtnConfig.class)) {
- readConfiguration();
- } else if (event.configClass().equals(CONFIG_CLASS)) {
- readAccessAgentConfig();
- }
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
index 648c341..298d60a 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
@@ -297,7 +297,7 @@
.withTreatment(downstreamTreatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
.forDevice(vsgVm.deviceId())
- .forTable(CordVtnPipeline.TABLE_DST_IP)
+ .forTable(CordVtnPipeline.TABLE_DST)
.makePermanent()
.build();