Initial development of Carrier Ethernet E-CORD
Change-Id: I57ca86dc1dd6a19636f3778d6f5030df33169144
diff --git a/local/bigswitch/pom.xml b/local/bigswitch/pom.xml
new file mode 100644
index 0000000..00baf3c
--- /dev/null
+++ b/local/bigswitch/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>bigswitch</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Big switch abstraction topology</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.bigswitch</onos.app.name>
+ <onos.app.title>ECORD-CE App</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <project.version>1.0.0</project.version>
+ <onos.version>1.10.3</onos.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ <version>3.0.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchEvent.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchEvent.java
new file mode 100644
index 0000000..6876ce1
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchEvent.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch;
+
+import com.google.common.collect.ImmutableList;
+import org.onosproject.event.AbstractEvent;
+import org.onosproject.net.device.PortDescription;
+
+import java.util.List;
+
+
+// TODO probably Event subject should contain Device info.
+// e.g., (DeviceId, PortDescription)
+public class BigSwitchEvent extends AbstractEvent<BigSwitchEvent.Type, PortDescription> {
+ private List<PortDescription> allPorts;
+
+ public enum Type {
+
+ /**
+ * Signifies the Big Switch abstraction is created.
+ */
+ DEVICE_CREATED,
+
+ /**
+ * Signifies the Big Switch abstraction is finished.
+ */
+ DEVICE_REMOVED,
+
+ /**
+ * Signifies a port was added to the big switch.
+ */
+ PORT_ADDED,
+ /**
+ * Signifies a port was removed from the big switch.
+ */
+ PORT_REMOVED,
+ /**
+ * Signifies a port was updated in the big switch.
+ */
+ PORT_UPDATED
+ }
+
+ /**
+ * Creates a new big switch event.
+ *
+ * @param type event type
+ * @param subject the port description
+ * @param allPorts list of all switch ports
+ */
+ public BigSwitchEvent(Type type, PortDescription subject, List<PortDescription> allPorts) {
+ super(type, subject);
+ this.allPorts = allPorts;
+ }
+
+ /**
+ * Creates a new big switch event.
+ *
+ * @param type event type
+ * @param subject the port description
+ * @param allPorts list of all switch ports
+ * @param time occurence time
+ */
+ public BigSwitchEvent(Type type, PortDescription subject, List<PortDescription> allPorts,
+ long time) {
+ super(type, subject, time);
+ this.allPorts = allPorts;
+ }
+
+ /**
+ * Returns list of ports known by this instance object.
+ *
+ * @return list of all ports
+ */
+ public List<PortDescription> allPorts() {
+ return ImmutableList.copyOf(allPorts);
+ }
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchListener.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchListener.java
new file mode 100644
index 0000000..5543553
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Component to inform about big switch updates.
+ */
+public interface BigSwitchListener extends EventListener<BigSwitchEvent> {
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
new file mode 100644
index 0000000..979cafb
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
@@ -0,0 +1,488 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+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.Modified;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.event.AbstractListenerManager;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.ConfigFactory;
+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.device.DefaultPortDescription;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.domain.DomainId;
+import org.onosproject.net.edge.EdgePortEvent;
+import org.onosproject.net.edge.EdgePortListener;
+import org.onosproject.net.edge.EdgePortService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.AtomicCounter;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
+import org.opencord.ce.api.models.CarrierEthernetNetworkInterface;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+import static org.onlab.util.Tools.get;
+import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
+import static org.opencord.ce.api.services.channel.Symbols.DOMAIN_ID;
+import static org.opencord.ce.api.services.channel.Symbols.MEF_PORT_TYPE;
+import static org.opencord.ce.local.bigswitch.MefPortsConfig.INTERLINK_ID;
+import static org.opencord.ce.local.bigswitch.MefPortsConfig.MEF_PORTS;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.opencord.ce.local.bigswitch.MefPortsConfig.MefPortConfig;
+
+/**
+ * Listens for edge and port changes in the underlying data path and
+ * exposes a big switch abstraction.
+ */
+@Component(immediate = true)
+@Service
+public class BigSwitchManager
+ extends AbstractListenerManager<BigSwitchEvent, BigSwitchListener>
+ implements BigSwitchService {
+ private static final Logger log = getLogger(BigSwitchManager.class);
+ private static final String APP_NAME = "org.opencord.ce.local.bigswitch";
+
+ public static final String REALIZED_BY = "bigswitch:realizedBy";
+ public static final String DEFAULT_DOMAIN_ID = "local-domain";
+
+ private static final String PORT_MAP = "ecord-port-map";
+ private static final String PORT_COUNTER = "ecord-port-counter";
+ private static final Serializer SERIALIZER = Serializer.using(KryoNamespaces.API);
+ private ApplicationId appId;
+ private final NetworkConfigListener configListener = new InternalConfigListener();
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry configRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected EdgePortService edgePortService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService networkConfigService;
+
+ @Property(name = DOMAIN_ID, value = DEFAULT_DOMAIN_ID, label = "Domain ID where this ONOS is running")
+ private String siteId = DEFAULT_DOMAIN_ID;
+
+ private static final String PROP_ENABLED = "enabled";
+ @Property(name = PROP_ENABLED, boolValue = true,
+ label = "If false, DEVICE_CREATED event is never triggered")
+ private boolean enabled = true;
+
+ private final ExecutorService executorService =
+ Executors.newSingleThreadExecutor();
+
+ // MEF ports given by configuration
+ private static List<MefPortConfig> mefPortConfigs;
+
+ /**
+ * Holds the physical port to virtual port number mapping.
+ */
+ private ConsistentMap<ConnectPoint, Long> portMap;
+
+ // Counter for virtual port numbers
+ private AtomicCounter portCounter;
+
+ // TODO listen to portMap event and populate Cache to properly deal with
+ // TODO distributed deployment.
+ /**
+ * History of physical port to virtual port number mapping.
+ * Intended to avoid virtual port number explosion.
+ */
+ private LoadingCache<ConnectPoint, Long> p2vMap;
+
+ // TODO: Add other listeners once we decide what an edge really is
+ private EdgePortListener edgeListener = new InternalEdgeListener();
+ private DeviceListener deviceListener = new InternalDeviceListener();
+
+ private final ConfigFactory<ApplicationId, MefPortsConfig> configFactory =
+ new ConfigFactory<ApplicationId, MefPortsConfig>(APP_SUBJECT_FACTORY,
+ MefPortsConfig.class, MEF_PORTS, true) {
+ @Override
+ public MefPortsConfig createConfig() {
+ return new MefPortsConfig();
+ }
+ };
+
+ @Activate
+ public void activate() {
+ appId = coreService.getAppId(APP_NAME);
+ configRegistry.registerConfigFactory(configFactory);
+ networkConfigService.addListener(configListener);
+ //deviceService = opticalView(deviceService);
+ portMap = storageService.<ConnectPoint, Long>consistentMapBuilder()
+ .withName(PORT_MAP)
+ .withSerializer(SERIALIZER)
+ .build();
+ portCounter = storageService.atomicCounterBuilder()
+ .withName(PORT_COUNTER)
+ .withMeteringDisabled()
+ .build()
+ .asAtomicCounter();
+ p2vMap = CacheBuilder.newBuilder()
+ .build(CacheLoader.from(portCounter::getAndIncrement));
+
+ eventDispatcher.addSink(BigSwitchEvent.class, listenerRegistry);
+ portCounter.compareAndSet(0, 1);
+ // edgePortService.addListener(edgeListener);
+ deviceService.addListener(deviceListener);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ networkConfigService.removeListener(configListener);
+ configRegistry.unregisterConfigFactory(configFactory);
+ //edgePortService.removeListener(edgeListener);
+ deviceService.removeListener(deviceListener);
+ log.info("Stopped");
+ }
+
+ @Modified
+ public void modified(ComponentContext context) {
+ Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
+
+ boolean newEnabled;
+ String newSiteId;
+
+ try {
+ String s = get(properties, PROP_ENABLED);
+ newEnabled = isNullOrEmpty(s) || Boolean.parseBoolean(s.trim());
+
+ s = get(properties, DOMAIN_ID);
+ newSiteId = s;
+
+ } catch (NumberFormatException e) {
+ log.warn("Component configuration had invalid values", e);
+
+ newEnabled = enabled;
+ newSiteId = siteId;
+ }
+
+ if (enabled && !newEnabled) {
+ disable();
+ } else if (!enabled && newEnabled) {
+ enable();
+ }
+ enabled = newEnabled;
+
+ // TODO: manage new site ID
+ siteId = newSiteId;
+ }
+
+ @Override
+ public List<PortDescription> getPorts() {
+ return portMap.keySet().stream()
+ .map(this::toVirtualPortDescription)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public PortNumber getPort(ConnectPoint port) {
+ // XXX error-check and seriously think about a better method definition.
+ Versioned<Long> portNo = portMap.get(port);
+ if (Versioned.valueOrNull(portNo) != null) {
+ return PortNumber.portNumber(portNo.value());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public Optional<ConnectPoint> connectPointFromVirtPort(PortNumber portNumber) {
+ return portMap.asJavaMap().entrySet()
+ .stream()
+ .filter(entry -> Objects.equals(entry.getValue(), portNumber.toLong()))
+ .map(Map.Entry::getKey)
+ .findFirst();
+ }
+
+ @Override
+ public DomainId siteId() {
+ return DomainId.domainId(siteId);
+ }
+
+ /**
+ * Convert connect point to port description.
+ *
+ * @param cp connect point of physical port
+ * @return port description of virtual big switch port
+ */
+ private PortDescription toVirtualPortDescription(ConnectPoint cp) {
+ Port p = deviceService.getPort(cp.deviceId(), cp.port());
+ if (p == null) {
+ return null;
+ }
+ // copy annotation
+ DefaultAnnotations.Builder annot = DefaultAnnotations.builder();
+ p.annotations().keys()
+ .forEach(k -> annot.set(k, p.annotations().value(k)));
+ annot.set(DOMAIN_ID, siteId);
+ // add annotation about underlying physical connect-point
+ Device device = deviceService.getDevice(cp.deviceId());
+ if (device.annotations().keys()
+ .contains(AnnotationKeys.LONGITUDE) && device.annotations().keys()
+ .contains(AnnotationKeys.LATITUDE)) {
+ annot.set(AnnotationKeys.LONGITUDE,
+ device.annotations().value(AnnotationKeys.LONGITUDE));
+ annot.set(AnnotationKeys.LATITUDE, device.annotations().value(AnnotationKeys.LATITUDE));
+ }
+
+ // this is not really efficient...
+ Optional<MefPortConfig> mefPortConfig =
+ mefPortConfigs.stream().filter(item -> item.cp().equals(cp)).findFirst();
+ if (mefPortConfig.isPresent()) {
+ annot.set(MEF_PORT_TYPE, mefPortConfig.get().mefType().toString());
+ if (!mefPortConfig.get().interlinkId().id().equals("internal")) {
+ annot.set(INTERLINK_ID, mefPortConfig.get().interlinkId().id());
+ }
+ } else {
+ annot.set(MEF_PORT_TYPE, CarrierEthernetNetworkInterface.Type.GENERIC.toString());
+ }
+
+ Long vPortNo = Versioned.valueOrNull(portMap.get(cp));
+ if (vPortNo == null) {
+ return null;
+ }
+ PortNumber portNumber = PortNumber.portNumber(vPortNo);
+
+ return new DefaultPortDescription(portNumber, p.isEnabled(), p.type(),
+ p.portSpeed(), annot.build());
+ }
+
+ private void buildPorts() {
+ /*
+ edgePortService.getEdgePoints()
+ .forEach(cp -> {
+ log.info("DEBUG: {}", cp.toString());
+ if (isPortRelevant(cp)) {
+ portMap.put(cp, getVirtualPortNumber(cp));
+ }
+ });
+ */
+ deviceService.getDevices().forEach(device ->
+ deviceService.getPorts(device.id()).forEach(port -> {
+ ConnectPoint cp = new ConnectPoint(device.id(), port.number());
+ if (isPortRelevant(cp)) {
+ portMap.put(cp, getVirtualPortNumber(cp));
+ }
+ }
+ ));
+ }
+
+ private Long getVirtualPortNumber(ConnectPoint cp) {
+ return p2vMap.getUnchecked(cp);
+ }
+
+ private void readConfig() {
+ mefPortConfigs = configRegistry.getConfig(appId, MefPortsConfig.class).mefPortConfigs();
+
+ if (enabled && mefPortConfigs != null) {
+ buildPorts();
+ log.info("Notifying Bigswitch presence..");
+ if (portMap.size() > 0) {
+ post(new BigSwitchEvent(BigSwitchEvent.Type.DEVICE_CREATED, null, getPorts()));
+ }
+ }
+ }
+
+ private void disable() {
+ // TODO
+ }
+
+ private void enable() {
+ if (mefPortConfigs != null && portMap.size() > 0) {
+ post(new BigSwitchEvent(BigSwitchEvent.Type.DEVICE_CREATED, null, getPorts()));
+ }
+ }
+
+
+ private class InternalEdgeListener implements EdgePortListener {
+ @Override
+ public boolean isRelevant(EdgePortEvent event) {
+ // Only listen for real devices
+ Device d = deviceService.getDevice(event.subject().deviceId());
+
+ return d != null && !d.type().equals(Device.Type.VIRTUAL) &&
+ isPortRelevant(event.subject());
+ }
+
+ @Override
+ public void event(EdgePortEvent event) {
+ log.info("Edge event {} {}", event.subject(), event.type());
+ BigSwitchEvent.Type bigSwitchEvent;
+
+ switch (event.type()) {
+ case EDGE_PORT_ADDED:
+ portMap.put(event.subject(), getVirtualPortNumber(event.subject()));
+ bigSwitchEvent = BigSwitchEvent.Type.PORT_ADDED;
+ break;
+ case EDGE_PORT_REMOVED:
+ portMap.remove(event.subject());
+ bigSwitchEvent = BigSwitchEvent.Type.PORT_REMOVED;
+ break;
+ default:
+ return;
+ }
+
+ if (mefPortConfigs != null) {
+ PortDescription descr;
+ descr = toVirtualPortDescription(event.subject());
+ if (descr != null) {
+ post(new BigSwitchEvent(bigSwitchEvent, descr, getPorts()));
+ }
+ }
+ }
+ }
+
+
+ private class InternalDeviceListener implements DeviceListener {
+ @Override
+ public boolean isRelevant(DeviceEvent event) {
+ // Only listen for real devices
+ return !event.subject().type().equals(Device.Type.VIRTUAL) &&
+ (event.type().equals(DeviceEvent.Type.PORT_ADDED) ||
+ event.type().equals(DeviceEvent.Type.PORT_UPDATED) ||
+ event.type().equals(DeviceEvent.Type.PORT_REMOVED));
+ }
+
+ @Override
+ public void event(DeviceEvent event) {
+ log.debug("Device event {} {} {}", event.subject(), event.port(), event.type());
+ ConnectPoint cp = new ConnectPoint(event.subject().id(), event.port().number());
+ if (!isPortRelevant(cp)) {
+ return;
+ }
+ BigSwitchEvent.Type bigSwitchEvent = null;
+
+ switch (event.type()) {
+ // Ignore most of these for now
+ case DEVICE_ADDED:
+ case DEVICE_AVAILABILITY_CHANGED:
+ case DEVICE_REMOVED:
+ case DEVICE_SUSPENDED:
+ case DEVICE_UPDATED:
+ case PORT_ADDED:
+ portMap.put(cp, getVirtualPortNumber(cp));
+ bigSwitchEvent = BigSwitchEvent.Type.PORT_ADDED;
+ break;
+ case PORT_REMOVED:
+ portMap.remove(cp, getVirtualPortNumber(cp));
+ bigSwitchEvent = BigSwitchEvent.Type.PORT_REMOVED;
+ break;
+ case PORT_STATS_UPDATED:
+ break;
+ case PORT_UPDATED:
+ bigSwitchEvent = BigSwitchEvent.Type.PORT_UPDATED;
+ // Update if state of existing edge changed
+ break;
+ default:
+ break;
+
+ }
+ if (bigSwitchEvent != null && portMap.containsKey(cp) && mefPortConfigs != null) {
+ PortDescription descr = toVirtualPortDescription(cp);
+ if (descr != null) {
+ post(new BigSwitchEvent(bigSwitchEvent,
+ descr, getPorts()));
+ }
+ }
+ }
+ }
+
+ private class InternalConfigListener implements NetworkConfigListener {
+
+ @Override
+ public void event(NetworkConfigEvent event) {
+ if (!event.configClass().equals(MefPortsConfig.class)) {
+ return;
+ }
+ switch (event.type()) {
+ case CONFIG_ADDED:
+ log.info("Network configuration added");
+ executorService.execute(BigSwitchManager.this::readConfig);
+ break;
+ case CONFIG_UPDATED:
+ log.info("Network configuration updated");
+ executorService.execute(BigSwitchManager.this::readConfig);
+ break;
+ case CONFIG_REMOVED:
+ // TODO
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private boolean isPortRelevant(ConnectPoint cp) {
+ if (mefPortConfigs == null) {
+ return false;
+ }
+ for (MefPortConfig portConfig : mefPortConfigs) {
+ if (portConfig.cp().equals(cp)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
new file mode 100644
index 0000000..47880ff
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch;
+
+
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.domain.DomainId;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Service to interact with big switch abstraction.
+ */
+public interface BigSwitchService extends ListenerService<BigSwitchEvent, BigSwitchListener> {
+ /**
+ * Gets list of big switch ports.
+ *
+ * @return list of port descriptions
+ */
+ List<PortDescription> getPorts();
+
+ /**
+ * Gets the big switch port mapped to the physical port.
+ *
+ * @param port the physical port
+ * @return virtual port number
+ */
+ PortNumber getPort(ConnectPoint port);
+
+
+ /**
+ * Gets the local connect point mapped to the specified virtual port number.
+ * @param portNumber virtual port number
+ * @return optional local-site connect point
+ */
+ Optional<ConnectPoint> connectPointFromVirtPort(PortNumber portNumber);
+
+ /**
+ * Returns the local site/domain ID of this biw switch.
+ *
+ * @return domain/site ID
+ */
+ DomainId siteId();
+}
+
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/MefPortsConfig.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/MefPortsConfig.java
new file mode 100644
index 0000000..a88f8e6
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/MefPortsConfig.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.config.Config;
+import org.opencord.ce.api.models.CarrierEthernetNetworkInterface;
+import org.opencord.ce.api.services.virtualprovider.LinkId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.opencord.ce.api.services.channel.Symbols.MEF_PORT_TYPE;
+import static org.opencord.ce.api.models.CarrierEthernetNetworkInterface.Type;
+
+/**
+ * See config-samples/ecord-local-config.json.
+ */
+public class MefPortsConfig extends Config<ApplicationId> {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+ public static final String MEF_PORTS = "mefPorts";
+ public static final String CONNECT_POINT = "connectPoint";
+ public static final String INTERLINK_ID = "interlinkId";
+
+ public List<MefPortConfig> mefPortConfigs() {
+ List<MefPortConfig> mefPortConfigs = new ArrayList<>();
+ array.forEach(item -> mefPortConfigs.add(new MefPortConfig(
+ ConnectPoint.deviceConnectPoint(item.path(CONNECT_POINT).asText()),
+ CarrierEthernetNetworkInterface.Type.valueOf(item.path(MEF_PORT_TYPE).asText()),
+ LinkId.linkId(item.path(INTERLINK_ID).isMissingNode() ? "internal" :
+ item.path(INTERLINK_ID).asText())
+ )));
+ return mefPortConfigs;
+ }
+
+ public static class MefPortConfig {
+ private ConnectPoint cp;
+ private CarrierEthernetNetworkInterface.Type mefType;
+ private LinkId interlinkId;
+
+ public MefPortConfig(ConnectPoint cp, Type mefType,
+ LinkId interlinkId) {
+ this.cp = cp;
+ this.mefType = mefType;
+ this.interlinkId = interlinkId;
+ }
+
+ public ConnectPoint cp() {
+ return cp;
+ }
+
+ public Type mefType() {
+ return mefType;
+ }
+
+ public LinkId interlinkId() {
+ return interlinkId;
+ }
+ }
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/BigSwitchPortsCommand.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/BigSwitchPortsCommand.java
new file mode 100644
index 0000000..1838055
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/BigSwitchPortsCommand.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.opencord.ce.local.bigswitch.BigSwitchService;
+
+/**
+ * Command to list the ports of the bigswitch.
+ */
+@Command(scope = "onos", name = "bigswitch-ports",
+ description = "Lists the bigswitch ports")
+public class BigSwitchPortsCommand extends AbstractShellCommand {
+
+ @Override
+ public void execute() {
+ BigSwitchService bigSwitchService = get(BigSwitchService.class);
+
+ bigSwitchService.getPorts().forEach(
+ portDescription -> print(portDescription.toString())
+ );
+ }
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/ConnectPointFromVirtPortCmd.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/ConnectPointFromVirtPortCmd.java
new file mode 100644
index 0000000..cec3225
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/ConnectPointFromVirtPortCmd.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017-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.ce.local.bigswitch.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.PortNumber;
+import org.opencord.ce.local.bigswitch.BigSwitchService;
+
+/**
+ * Returns the connect point associated to the specified port number of the bigswitch.
+ */
+@Command(scope = "onos", name = "bigswitch-port", description = "Returns the connect point" +
+ "associated with the specified virtual port of the bigswitch")
+public class ConnectPointFromVirtPortCmd extends AbstractShellCommand {
+
+ @Argument(index = 1, name = "port",
+ description = "Virtual bigswitch port",
+ required = true, multiValued = false)
+ String port = "0";
+
+
+ @Override
+ public void execute() {
+ BigSwitchService bigSwitchService = get(BigSwitchService.class);
+ print(bigSwitchService.connectPointFromVirtPort(PortNumber.fromString(port)).toString());
+
+ }
+}
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/package-info.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/package-info.java
new file mode 100644
index 0000000..f99e72b
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * CLI command to explore the bigswitch ports.
+ */
+package org.opencord.ce.local.bigswitch.cli;
\ No newline at end of file
diff --git a/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/package-info.java b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/package-info.java
new file mode 100644
index 0000000..06205cb
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Big switch abstraction package.
+ */
+package org.opencord.ce.local.bigswitch;
\ No newline at end of file
diff --git a/local/bigswitch/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/local/bigswitch/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..2a50a6a
--- /dev/null
+++ b/local/bigswitch/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright 2017-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.
+ -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.opencord.ce.local.bigswitch.cli.BigSwitchPortsCommand"/>
+ </command>
+ <command>
+ <action class="org.opencord.ce.local.bigswitch.cli.ConnectPointFromVirtPortCmd"/>
+ </command>
+ </command-bundle>
+</blueprint>
diff --git a/local/ce-central-office/pom.xml b/local/ce-central-office/pom.xml
new file mode 100644
index 0000000..d8536e7
--- /dev/null
+++ b/local/ce-central-office/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>co</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Central Office app for Carrier Ethernet Service</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.co</onos.app.name>
+ <onos.version>1.10.0</onos.version>
+ <onos.app.title>ECORD Central-Office Fabric config</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
diff --git a/local/ce-central-office/src/main/java/org/opencord/ce/local/co/package-info.java b/local/ce-central-office/src/main/java/org/opencord/ce/local/co/package-info.java
new file mode 100644
index 0000000..f4af694
--- /dev/null
+++ b/local/ce-central-office/src/main/java/org/opencord/ce/local/co/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Central Office CE app.
+ */
+package org.opencord.ce.local.co;
\ No newline at end of file
diff --git a/local/ce-transport/pom.xml b/local/ce-transport/pom.xml
new file mode 100644
index 0000000..edf24d8
--- /dev/null
+++ b/local/ce-transport/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>transport</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Transport network provisioner of Carrier Ethernet Service</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.transport</onos.app.name>
+ <onos.version>1.10.0</onos.version>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
diff --git a/local/ce-transport/src/main/java/org/opencord/ce/local/transport/package-info.java b/local/ce-transport/src/main/java/org/opencord/ce/local/transport/package-info.java
new file mode 100644
index 0000000..e58fb39
--- /dev/null
+++ b/local/ce-transport/src/main/java/org/opencord/ce/local/transport/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Transport network for Carrier Ethernet package.
+ */
+package org.opencord.ce.local.transport;
\ No newline at end of file
diff --git a/local/ce-vee/pom.xml b/local/ce-vee/pom.xml
new file mode 100644
index 0000000..8a416d4
--- /dev/null
+++ b/local/ce-vee/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>vee</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Virtual ethernet edge service for CORD</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.vee</onos.app.name>
+ <onos.app.title>ECORD-CE App</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>bigswitch</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>
diff --git a/local/ce-vee/src/main/java/org/opencord/ce/local/vee/VeeManager.java b/local/ce-vee/src/main/java/org/opencord/ce/local/vee/VeeManager.java
new file mode 100644
index 0000000..daf5614
--- /dev/null
+++ b/local/ce-vee/src/main/java/org/opencord/ce/local/vee/VeeManager.java
@@ -0,0 +1,730 @@
+/*
+ * Copyright 2017-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.ce.local.vee;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+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.apache.felix.scr.annotations.Service;
+import org.onlab.packet.EthType;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.VlanId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.Path;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverService;
+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.FlowRuleService;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.flow.instructions.Instruction;
+import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.flow.instructions.L2ModificationInstruction;
+import org.onosproject.net.flowobjective.DefaultFilteringObjective;
+import org.onosproject.net.flowobjective.DefaultForwardingObjective;
+import org.onosproject.net.flowobjective.DefaultNextObjective;
+import org.onosproject.net.flowobjective.FilteringObjective;
+import org.onosproject.net.flowobjective.FlowObjectiveService;
+import org.onosproject.net.flowobjective.ForwardingObjective;
+import org.onosproject.net.flowobjective.NextObjective;
+import org.onosproject.net.flowobjective.Objective;
+import org.onosproject.net.link.LinkService;
+import org.onosproject.net.meter.Band;
+import org.onosproject.net.meter.DefaultBand;
+import org.onosproject.net.meter.DefaultMeterRequest;
+import org.onosproject.net.meter.Meter;
+import org.onosproject.net.meter.MeterId;
+import org.onosproject.net.meter.MeterRequest;
+import org.onosproject.net.meter.MeterService;
+import org.onosproject.net.topology.PathService;
+import org.opencord.ce.api.models.CarrierEthernetEnni;
+import org.opencord.ce.api.models.CarrierEthernetForwardingConstruct;
+import org.opencord.ce.api.models.CarrierEthernetGenericNi;
+import org.opencord.ce.api.models.CarrierEthernetInni;
+import org.opencord.ce.api.models.CarrierEthernetNetworkInterface;
+import org.opencord.ce.api.models.CarrierEthernetUni;
+import org.opencord.ce.api.models.EvcConnId;
+import org.opencord.ce.api.services.MetroNetworkVirtualNodeService;
+
+import org.opencord.ce.local.bigswitch.BigSwitchService;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.opencord.ce.api.models.CarrierEthernetNetworkInterface.Type;
+import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
+
+/**
+ * Class used to control Ethernet Edge nodes according to the OpenFlow (1.3 and above) protocol.
+ */
+@Component(immediate = true)
+@Service(value = MetroNetworkVirtualNodeService.class)
+public class VeeManager implements MetroNetworkVirtualNodeService {
+ private static final int PRIORITY = 50000;
+ public static final String APP_NAME = "org.opencord.ce.local.vee";
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected FlowRuleService flowRuleService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MeterService meterService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected FlowObjectiveService flowObjectiveService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkService linkService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected BigSwitchService bigSwitchService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected PathService pathService;
+
+ // FIXME slightly better way to detect OF-DPA issues
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DriverService drivers;
+
+ private final Logger log = getLogger(getClass());
+
+ private ApplicationId appId;
+
+ // FIXME: We don't need to store the submitted meters as we can get them from the service
+ private Map<EvcConnId, Set<Pair<DeviceId, MeterId>>> fcMeterMap =
+ new ConcurrentHashMap<>();
+ // Store submitted flow objects as the service does not allow query operations
+ private final Map<EvcConnId, LinkedList<Pair<DeviceId, Objective>>> flowObjectiveMap =
+ new ConcurrentHashMap<>();
+
+ private final Map<EvcConnId, DeviceId> eeDeviceMap = new ConcurrentHashMap<>();
+
+ @Activate
+ protected void activate() {
+ appId = coreService.registerApplication(APP_NAME);
+
+ // TODO: start packet intercept for untagged traffic?
+ log.info("Started");
+
+ // testCentec();
+ }
+
+ @Deactivate
+ protected void deactivate() {
+
+ log.info("Stopped");
+ }
+
+
+ @Override
+ public void setNodeForwarding(CarrierEthernetForwardingConstruct fc, CarrierEthernetNetworkInterface ingressNi,
+ Set<CarrierEthernetNetworkInterface> egressNiSet) {
+
+ log.info("DEBUG: setForwarding method called..");
+ if (ingressNi == null || egressNiSet.isEmpty()) {
+ log.error("There needs to be at least one ingress and one egress NI to set forwarding.");
+ return;
+ }
+
+ flowObjectiveMap.putIfAbsent(fc.id(), new LinkedList<>());
+
+ CarrierEthernetNetworkInterface realIngressNi;
+ Optional<ConnectPoint> optCp =
+ bigSwitchService.connectPointFromVirtPort(ingressNi.cp().port());
+ if (optCp.isPresent()) {
+ realIngressNi = buildLocalNi(optCp.get(), ingressNi);
+ } else {
+ log.warn("Virtual ingress interface does not map to a local connect point");
+ return;
+ }
+
+ // real <-> virtual
+ final Map<ConnectPoint, CarrierEthernetNetworkInterface> realEgressNi = new HashMap<>();
+ egressNiSet.forEach(egressNi -> {
+ Optional<ConnectPoint> opt =
+ bigSwitchService.connectPointFromVirtPort(egressNi.cp().port());
+ opt.ifPresent(connectPoint -> realEgressNi.put(connectPoint, egressNi));
+ });
+
+ // it is necessary to identify the number of egress devices in order to build the
+ // flow rules
+ Set<DeviceId> egressDevices = new HashSet<>();
+ realEgressNi.keySet().forEach(cp -> egressDevices.add(cp.deviceId()));
+
+ //for how it is made the CE app, egressNiSet contains only one item, but...
+ egressDevices.forEach(deviceId -> {
+ // group the egress NI per device
+ Set<CarrierEthernetNetworkInterface> perDeviceEgressNiSet = new HashSet<>();
+ realEgressNi.keySet().forEach(cp -> {
+ if (cp.deviceId().equals(deviceId)) {
+ perDeviceEgressNiSet.add(buildLocalNi(cp, realEgressNi.get(cp)));
+ }
+ });
+ // if the egress device ID is equal to the ingress --> install rules
+ if (deviceId.equals(realIngressNi.cp().deviceId())) {
+ createFlowObjectives(fc, realIngressNi,
+ perDeviceEgressNiSet);
+ } else {
+ Set<Path> paths = pathService.getPaths(realIngressNi.cp().deviceId(),
+ deviceId);
+ Path path;
+ // TODO: Select path in more sophisticated way and return null if any of the constraints cannot be met
+ path = paths.iterator().hasNext() ? paths.iterator().next() : null;
+ if (path == null) {
+ return;
+ }
+ // for each NI, add edge links ()
+ perDeviceEgressNiSet.forEach(egressNi -> {
+ List<Link> links = new ArrayList<>();
+ links.add(createEdgeLink(realIngressNi.cp(), true));
+ links.addAll(path.links());
+ links.add(createEdgeLink(egressNi.cp(), false));
+
+ HashMap<CarrierEthernetNetworkInterface, HashSet<CarrierEthernetNetworkInterface>>
+ ingressEgressNiMap = new HashMap<>();
+ populateIngressEgressNiMap(realIngressNi, egressNi, links, ingressEgressNiMap);
+ // Establish connectivity using the ingressEgressNiMap
+ ingressEgressNiMap.keySet().forEach(srcNi ->
+ createFlowObjectives(fc, srcNi, ingressEgressNiMap.get(srcNi)));
+ });
+ }
+ });
+ }
+
+ private void populateIngressEgressNiMap(CarrierEthernetNetworkInterface srcNi,
+ CarrierEthernetNetworkInterface dstNi,
+ List<Link> linkList,
+ HashMap<CarrierEthernetNetworkInterface,
+ HashSet<CarrierEthernetNetworkInterface>> ingressEgressNiMap
+ ) {
+ // FIXME: Fix the method - avoid generating GENERIC NIs if not needed
+ // Add the src and destination NIs as well as the associated Generic NIs
+ ingressEgressNiMap.putIfAbsent(srcNi, new HashSet<>());
+ // Add last hop entry only if srcNi, dstNi aren't on same device (in which case srcNi, ingressNi would coincide)
+ if (!srcNi.cp().deviceId().equals(dstNi.cp().deviceId())) {
+ // If srcNi, dstNi are not on the same device, create mappings to/from new GENERIC NIs
+ ingressEgressNiMap.get(srcNi).add(new CarrierEthernetGenericNi(linkList.get(1).src(), null));
+ CarrierEthernetGenericNi ingressNi =
+ new CarrierEthernetGenericNi(linkList.get(linkList.size() - 2).dst(), null);
+ ingressEgressNiMap.putIfAbsent(ingressNi, new HashSet<>());
+ ingressEgressNiMap.get(ingressNi).add(dstNi);
+ } else {
+ // If srcNi, dstNi are on the same device, this is the only mapping that will be created
+ ingressEgressNiMap.get(srcNi).add(dstNi);
+ }
+
+ // Go through the links and create/add the intermediate NIs
+ for (int i = 1; i < linkList.size() - 2; i++) {
+ CarrierEthernetGenericNi ingressNi = new CarrierEthernetGenericNi(linkList.get(i).dst(), null);
+ ingressEgressNiMap.putIfAbsent(ingressNi, new HashSet<>());
+ ingressEgressNiMap.get(ingressNi).add(new CarrierEthernetGenericNi(linkList.get(i + 1).src(), null));
+ }
+ }
+
+ private CarrierEthernetNetworkInterface buildLocalNi(ConnectPoint localCp, CarrierEthernetNetworkInterface
+ virtualNi) {
+ CarrierEthernetNetworkInterface ni;
+ switch (virtualNi.type()) {
+ case UNI:
+ CarrierEthernetUni tmpUni = (CarrierEthernetUni) virtualNi;
+ ni = CarrierEthernetUni.builder()
+ .cp(localCp)
+ .role(tmpUni.role())
+ .ceVlanId(tmpUni.ceVlanId())
+ .bwp(tmpUni.bwp())
+ .build();
+ break;
+ case ENNI:
+ CarrierEthernetEnni tmpEnni = (CarrierEthernetEnni) virtualNi;
+ ni = CarrierEthernetEnni.builder()
+ .cp(localCp)
+ .role(tmpEnni.role())
+ .sVlanId(tmpEnni.sVlanId())
+ .build();
+ break;
+ case INNI:
+ CarrierEthernetInni tmpInni = (CarrierEthernetInni) virtualNi;
+ ni = CarrierEthernetInni.builder()
+ .cp(localCp)
+ .role(tmpInni.role())
+ .sVlanId(tmpInni.sVlanId())
+ .build();
+ break;
+ case GENERIC:
+ ni = new CarrierEthernetGenericNi(localCp, null);
+ break;
+ default:
+ return null;
+ }
+ return ni;
+
+ }
+
+ /**
+ * Creates and submits FlowObjectives into the device vesting the role of Ethernet Edge.
+ *
+ * @param fc the FC representation
+ * @param ingressNi the ingress network interface
+ * @param egressNiSet the set of egress NIs
+ */
+ private void createFlowObjectives(CarrierEthernetForwardingConstruct fc, CarrierEthernetNetworkInterface ingressNi,
+ Set<CarrierEthernetNetworkInterface> egressNiSet) {
+ DeviceId deviceId = ingressNi.cp().deviceId();
+ PortNumber portNumber = ingressNi.cp().port();
+
+ /////////////////////////////////////////
+ // Prepare and submit filtering objective
+ /////////////////////////////////////////
+
+ FilteringObjective.Builder filterObjBuilder = DefaultFilteringObjective.builder()
+ .permit().fromApp(appId)
+ .withPriority(PRIORITY)
+ .withKey(Criteria.matchInPort(portNumber));
+
+ TrafficTreatment.Builder filterTreatmentBuilder = DefaultTrafficTreatment.builder();
+ // In general, nodes would match on the VLAN tag assigned to the EVC/FC
+ Criterion filterVlanIdCriterion = Criteria.matchVlanId(fc.vlanId());
+
+ if ((ingressNi.type().equals(CarrierEthernetNetworkInterface.Type.INNI))
+ || (ingressNi.type().equals(CarrierEthernetNetworkInterface.Type.ENNI))) {
+ // TODO: Check TPID? Also: Is is possible to receive untagged pkts at an INNI/ENNI?
+ // Source node of an FC should match on S-TAG if it's an INNI/ENNI
+ filterVlanIdCriterion = Criteria.matchVlanId(ingressNi.sVlanId());
+ // Translate S-TAG to the one used in the current FC
+ filterTreatmentBuilder.setVlanId(fc.vlanId());
+ } else if (ingressNi.type().equals(CarrierEthernetNetworkInterface.Type.UNI)) {
+ // Source node of an FC should match on CE-VLAN ID (if present) if it's a UNI
+ filterVlanIdCriterion = Criteria.matchVlanId(ingressNi.ceVlanId());
+ // Obtain related Meter (if it exists) and add it in the treatment in case it may be used
+ if (fcMeterMap.get(fc.id()) != null && !fcMeterMap.get(fc.id()).isEmpty()) {
+ fcMeterMap.get(fc.id()).forEach(devMeterPair -> {
+ if (devMeterPair.getLeft().equals(deviceId)) {
+ filterTreatmentBuilder.meter(devMeterPair.getRight());
+ }
+ });
+ }
+ // If a CE-VLAN-ID exists on the incoming packet then push an S-TAG of current FC on top
+ // otherwise push it on as a C-tag
+ if (ingressNi.ceVlanId() != null && ingressNi.ceVlanId() != VlanId.NONE) {
+ filterTreatmentBuilder.pushVlan(EthType.EtherType.QINQ.ethType()).setVlanId(fc.vlanId());
+ } else {
+ filterTreatmentBuilder.pushVlan().setVlanId(fc.vlanId());
+ }
+ }
+
+ filterObjBuilder.addCondition(filterVlanIdCriterion);
+
+
+
+ // Do not add meta if there are no instructions (i.e. if not first)
+ if (!(ingressNi.type().equals(Type.GENERIC))) {
+ filterObjBuilder.withMeta(filterTreatmentBuilder.build());
+ }
+
+ flowObjectiveService.filter(deviceId, filterObjBuilder.add());
+ flowObjectiveMap.get(fc.id()).addFirst(Pair.of(deviceId, filterObjBuilder.add()));
+
+ ////////////////////////////////////////////////////
+ // Prepare and submit next and forwarding objectives
+ ////////////////////////////////////////////////////
+
+ TrafficSelector.Builder fwdSelectorBuilder = DefaultTrafficSelector.builder()
+ .matchVlanId(fc.vlanId())
+ .matchInPort(portNumber);
+
+ if (isOfDpa(deviceId)) {
+ // workaround for OF-DPA
+ fwdSelectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
+ }
+
+ TrafficSelector fwdSelector = fwdSelectorBuilder.build();
+
+ Integer nextId = flowObjectiveService.allocateNextId();
+
+ NextObjective.Type nextType = egressNiSet.size() == 1 ?
+ NextObjective.Type.SIMPLE : NextObjective.Type.BROADCAST;
+
+ // Setting higher priority to fwd/next objectives to bypass filter in case of match conflict in OVS switches
+ NextObjective.Builder nextObjectiveBuider = DefaultNextObjective.builder()
+ .fromApp(appId)
+ .makePermanent()
+ .withType(nextType)
+ .withPriority(PRIORITY + 1)
+ .withMeta(fwdSelector)
+ .withId(nextId);
+
+ egressNiSet.forEach(egressNi -> {
+ // TODO: Check if ingressNi and egressNi are on the same device?
+ TrafficTreatment.Builder nextTreatmentBuilder = DefaultTrafficTreatment.builder();
+ // If last NI in FC is not UNI,
+ // keep the existing S-TAG - it will be translated at the entrance of the next FC
+ if (egressNi.type().equals(CarrierEthernetNetworkInterface.Type.UNI)) {
+ nextTreatmentBuilder.popVlan();
+ }
+ Instruction outInstruction = Instructions.createOutput(egressNi.cp().port());
+ nextTreatmentBuilder.add(outInstruction);
+ nextObjectiveBuider.addTreatment(nextTreatmentBuilder.build());
+ });
+
+ NextObjective nextObjective = nextObjectiveBuider.add();
+
+ // Setting higher priority to fwd/next objectives to bypass filter in case of match conflict in OVS switches
+ ForwardingObjective forwardingObjective = DefaultForwardingObjective.builder()
+ .fromApp(appId)
+ .makePermanent()
+ .withFlag(ForwardingObjective.Flag.VERSATILE)
+ .withPriority(PRIORITY + 1)
+ .withSelector(fwdSelector)
+ .nextStep(nextId)
+ .add();
+
+ flowObjectiveService.next(ingressNi.cp().deviceId(), nextObjective);
+ // Add all NextObjectives at the end of the list so that they will be removed last
+ flowObjectiveMap.get(fc.id()).addLast(Pair.of(ingressNi.cp().deviceId(), nextObjective));
+
+ flowObjectiveService.forward(ingressNi.cp().deviceId(), forwardingObjective);
+ flowObjectiveMap.get(fc.id()).addFirst(Pair.of(ingressNi.cp().deviceId(), forwardingObjective));
+ }
+
+ @Override
+ public void createBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ log.info("Creating BW profile...{}", uni.toString());
+ // Create meters and add them to global MeterId map
+ Set<Pair<DeviceId, MeterId>> meters;
+
+ DeviceId deviceId = getEEDevice(fc, uni);
+
+ if (fcMeterMap.containsKey(fc.id())) {
+ meters = fcMeterMap.get(fc.id());
+ } else {
+ meters = new HashSet<>();
+ if (deviceId == null) {
+ // no meters
+ return;
+ }
+ }
+ meters.addAll(submitMeters(fc, uni, deviceId));
+ fcMeterMap.put(fc.id(), meters);
+ }
+
+ private boolean isOfDpa(DeviceId deviceId) {
+ Driver driver = drivers.getDriver(deviceId);
+ return driver != null &&
+ driver.swVersion().contains("OF-DPA");
+ }
+
+ // Maybe we still need this method to later modify the QoS profile of an FC
+ @Override
+ public void applyBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ log.info("Applying BW profile...");
+
+ DeviceId deviceId = eeDeviceMap.get(fc.id());
+ if (deviceId == null) {
+ log.warn("Trying to apply bandwidth profile rules" +
+ "to not existing device/meters map");
+ return;
+ }
+
+ // Do not apply meters to NETCONF-controlled switches here since they should have been applied in the pipeline
+ // FIXME: Is there a better way to check this?
+ if (deviceId.uri().getScheme().equals("netconf")) {
+ return;
+ }
+
+ // Do not apply meters to OFDPA 2.0 switches since they are not currently supported
+ if (isOfDpa(deviceId)) {
+ return;
+ }
+
+ // Get installed flows with the same appId/deviceId with IN_PORT = UNI port which push the FC vlanId
+ List<FlowRule> flowRuleList =
+ StreamSupport.stream(flowRuleService.getFlowEntries(deviceId).spliterator(), false)
+ .filter(flowRule -> flowRule.appId() == appId.id())
+ .collect(Collectors.toList());
+ //&& getPushedVlanFromTreatment(flowRule.treatment()).equals(fc.vlanId()))
+
+
+ // Apply meters to flows
+ for (FlowRule flowRule : flowRuleList) {
+ // Need to add to the flow the meters associated with the same device
+ Set<Pair<DeviceId, MeterId>> deviceMeterIdSet = new HashSet<>();
+
+ if (fcMeterMap.get(fc.id()) != null && !fcMeterMap.get(fc.id()).isEmpty()) {
+ fcMeterMap.get(fc.id()).forEach(devMeterPair -> {
+ if (devMeterPair.getLeft().equals(flowRule.deviceId())) {
+ deviceMeterIdSet.add(devMeterPair);
+ }
+ });
+ }
+ // Modify and submit flow rule only if there are meters to add
+ if (!deviceMeterIdSet.isEmpty()) {
+ log.info("Applying metered flow rules...");
+ FlowRule newFlowRule = addMetersToFlowRule(flowRule, deviceMeterIdSet);
+ flowRuleService.applyFlowRules(newFlowRule);
+ }
+ }
+ }
+
+ private VlanId getPushedVlanFromTreatment(TrafficTreatment treatment) {
+ boolean pushVlan = false;
+ VlanId pushedVlan = null;
+ for (Instruction instruction : treatment.allInstructions()) {
+ if (instruction.type().equals(Instruction.Type.L2MODIFICATION)) {
+ L2ModificationInstruction l2ModInstr = (L2ModificationInstruction) instruction;
+ if (l2ModInstr.subtype().equals(L2ModificationInstruction.L2SubType.VLAN_PUSH)) {
+ pushVlan = true;
+ } else if (l2ModInstr.subtype().equals(L2ModificationInstruction.L2SubType.VLAN_ID) && pushVlan) {
+ pushedVlan = ((L2ModificationInstruction.ModVlanIdInstruction) instruction).vlanId();
+ }
+ }
+ }
+ return pushedVlan != null ? pushedVlan : VlanId.NONE;
+ }
+
+
+ /**
+ * Creates and submits a meter with the required bands for a UNI.
+ *
+ * @param uni the UNI descriptor
+ * @return set of meter ids of the meters created
+ */
+ private Set<Pair<DeviceId, MeterId>> submitMeters(CarrierEthernetForwardingConstruct fc,
+ CarrierEthernetUni uni, DeviceId deviceId) {
+ Set<Pair<DeviceId, MeterId>> meters = new HashSet<>();
+
+ uni.bwps().forEach(bwp -> {
+ log.info("bwp: {}", bwp.toString());
+
+ // KB_PER_SECOND
+ long longCir = (long) (bwp.cir().bps() / 8000);
+ long longEir = (long) (bwp.eir().bps() / 8000);
+ log.info("longCir: {}", longCir);
+ log.info("longEir: {}", longEir);
+
+ MeterRequest.Builder meterRequestBuilder;
+ Meter meter;
+ Band.Builder bandBuilder;
+
+ Set<Band> bandSet = new HashSet<>();
+
+ // If EIR is zero do not create the REMARK meter
+ /* === Centec v350 supports only DROP type! ===
+ if (longEir != 0) {
+ log.info("Enter here..");
+ // Mark frames that exceed CIR as Best Effort
+ bandBuilder = DefaultBand.builder()
+ .ofType(Band.Type.REMARK)
+ .withRate(longCir)
+ .dropPrecedence((short) 0);
+
+ if (bwp.cbs() != 0) {
+ bandBuilder.burstSize(bwp.cbs());
+ }
+
+ bandSet.add(bandBuilder.build());
+ }
+ */
+
+ // If CIR is zero do not create the DROP meter
+ if (longCir != 0) {
+ // Drop all frames that exceed CIR + EIR
+ bandBuilder = DefaultBand.builder()
+ .ofType(Band.Type.DROP)
+ .withRate(longCir + longEir);
+
+ if (bwp.cbs() != 0 || bwp.ebs() != 0) {
+ // FIXME: Use CBS and EBS correctly according to MEF specs
+ bandBuilder.burstSize(bwp.cbs() + bwp.ebs());
+ }
+
+ bandSet.add(bandBuilder.build());
+ }
+
+ // Create meter only if at least one band was created
+ if (!bandSet.isEmpty()) {
+ meterRequestBuilder = DefaultMeterRequest.builder()
+ .forDevice(deviceId)
+ .fromApp(appId)
+ .withUnit(Meter.Unit.KB_PER_SEC)
+ .withBands(bandSet);
+
+ if (bwp.cbs() != 0 || bwp.ebs() != 0) {
+ meterRequestBuilder.burst();
+ }
+
+ // Submit meter request and store
+ meter = meterService.submit(meterRequestBuilder.add());
+ // FIXME: use correct device id
+ log.info("Adding meter...{}", meter.toString());
+
+ meters.add(new ImmutablePair<>(deviceId, meter.id()));
+ }
+ });
+
+ return meters;
+ }
+
+ private FlowRule addMetersToFlowRule(FlowRule flowRule, Set<Pair<DeviceId, MeterId>> deviceMeterIdSet) {
+
+ TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment
+ .builder(flowRule.treatment());
+
+ deviceMeterIdSet.forEach(deviceMeterPair ->
+ tBuilder.meter(deviceMeterPair.getRight()));
+
+ return createFlowRule(flowRule.deviceId(), flowRule.priority(),
+ flowRule.selector(), tBuilder.build(), flowRule.tableId());
+ }
+
+ @Override
+ public void removeBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ removeMeters(fc, uni);
+ }
+
+ /**
+ * Removes the meters associated with a specific UNI of an FC.
+ *
+ * @param fc the forwarding construct
+ * @param uni the UNI descriptor
+ * */
+ private void removeMeters(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+
+ if (!fcMeterMap.containsKey(fc.id())) {
+ return;
+ }
+
+ Set<Pair<DeviceId, MeterId>> ids = fcMeterMap.get(fc.id());
+
+ // Rebuild meter request based on existing meter, withdraw the request, and remove it from our internal storage
+ ids.stream()
+ .map(id -> meterService.getMeter(id.getLeft(), id.getRight()))
+ .filter(Objects::nonNull)
+ .forEach(meter -> {
+ MeterRequest.Builder request = DefaultMeterRequest.builder()
+ .fromApp(meter.appId())
+ .forDevice(meter.deviceId())
+ .withUnit(meter.unit())
+ .withBands(meter.bands());
+ if (uni.bwp().cbs() != 0 || uni.bwp().ebs() != 0) {
+ request.burst();
+ }
+ meterService.withdraw(request.remove(), meter.id());
+
+ ids.remove(new ImmutablePair<>(meter.deviceId(), meter.id()));
+ });
+ }
+
+ /**
+ * Removes all flow objectives installed by the application which are associated with a specific FC.
+ *
+ * @param fcId ForwardingConcrtuct object
+ */
+ @Override
+ public void removeAllForwardingResources(EvcConnId fcId) {
+ // Note: A Flow Rule cannot be shared by multiple FCs due to different VLAN or CE-VLAN ID match.
+ List<Pair<DeviceId, Objective>> flowObjectives = flowObjectiveMap.remove(fcId);
+ // NextObjectives will be removed after all other Objectives
+ // TODO: filter also on elements of pair
+ flowObjectives.stream()
+ .filter(Objects::nonNull)
+ .forEach(pair ->
+ flowObjectiveService.apply(pair.getLeft(), pair.getRight().copy().remove()));
+ }
+
+ private FlowRule createFlowRule(DeviceId deviceId, int priority,
+ TrafficSelector selector, TrafficTreatment treatment, int tableId) {
+ return DefaultFlowRule.builder()
+ .fromApp(appId)
+ .forDevice(deviceId)
+ .makePermanent()
+ .withPriority(priority)
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .forTable(tableId)
+ .build();
+ }
+
+ /**
+ * !! Caution !! This method is strictly tied to the expected topology
+ * view of this {@link MetroNetworkVirtualNodeService} implementation.
+ * The UNI is expected to be in the CPE and meters implementation in the EE.
+ * The CPE node shall be connected only
+ * with the EE device (exception are multi path home gateway).
+ *
+ * @param fc forwarding construct
+ * @param uni User to Network Interface
+ * @return the EE device ID
+ */
+ private DeviceId getEEDevice(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni)
+ throws IllegalStateException {
+ CarrierEthernetNetworkInterface realUni;
+ Optional<ConnectPoint> optCp =
+ bigSwitchService.connectPointFromVirtPort(uni.cp().port());
+ if (optCp.isPresent()) {
+ realUni = buildLocalNi(optCp.get(), uni);
+ } else {
+ log.info("Virtual ingress interface does not map to a local connect point");
+ throw new IllegalStateException("Virtual UNI interface does not map to a local connect point");
+ }
+ if (eeDeviceMap.get(fc.id()) != null) {
+ return eeDeviceMap.get(fc.id());
+ }
+ // find the (only) egress link of the UNI device
+ Optional<Link> optLink = linkService.getDeviceEgressLinks(realUni.cp().deviceId())
+ .stream().findFirst();
+ if (optLink.isPresent()) {
+
+ // the link destination should be our target EE device
+ DeviceId deviceId = optLink.get().dst().deviceId();
+ log.info("Adding EE device {} in memory...", deviceId.toString());
+ eeDeviceMap.put(fc.id(), deviceId);
+ return deviceId;
+ } else {
+ log.info("No EE device found for meters...uni: {}", realUni.cp().toString());
+ // in this case there is no EE upstream and so no meter will be installed
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/local/ce-vee/src/main/java/org/opencord/ce/local/vee/package-info.java b/local/ce-vee/src/main/java/org/opencord/ce/local/vee/package-info.java
new file mode 100644
index 0000000..184f05a
--- /dev/null
+++ b/local/ce-vee/src/main/java/org/opencord/ce/local/vee/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Virtual Ethernet Edge implementation.
+ */
+package org.opencord.ce.local.vee;
\ No newline at end of file
diff --git a/local/common-component/app.xml b/local/common-component/app.xml
new file mode 100644
index 0000000..eea948b
--- /dev/null
+++ b/local/common-component/app.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2017-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.
+ -->
+<app name="org.opencord.ce.local.app" origin="ON.Lab" version="${project.version}"
+ category="Utility" url="http://opencord.org" title="Enterprise CORD"
+ featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
+ features="${project.artifactId}">
+ <description>${project.description}</description>
+ <artifact>mvn:${project.groupId}/bigswitch/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/local-channel/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/vee/${project.version}</artifact>
+</app>
diff --git a/local/common-component/features.xml b/local/common-component/features.xml
new file mode 100644
index 0000000..6c5c6c3
--- /dev/null
+++ b/local/common-component/features.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ ~ Copyright 2017-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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <bundle>mvn:${project.groupId}/bigswitch/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/local-channel/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/vee/${project.version}</bundle>
+ </feature>
+</features>
\ No newline at end of file
diff --git a/local/common-component/pom.xml b/local/common-component/pom.xml
new file mode 100644
index 0000000..336be69
--- /dev/null
+++ b/local/common-component/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ecord-local-app</artifactId>
+ <packaging>pom</packaging>
+
+ <description>java application bundling the bigswitch abstraction
+ and the http channel component
+ </description>
+
+ <properties>
+ <project.version>1.0.0</project.version>
+ <onos.app.name>org.opencord.ce.local.app</onos.app.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>bigswitch</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local-channel</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>vee</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/local/config-samples/co1-config.json b/local/config-samples/co1-config.json
new file mode 100644
index 0000000..1a1b169
--- /dev/null
+++ b/local/config-samples/co1-config.json
@@ -0,0 +1,29 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.10:830/1"
+ },
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.10:830/0",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "clusterIps" : [
+ "10.128.14.1"
+ ],
+ "port" : "8181",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
diff --git a/local/config-samples/co1-withEE-config.json b/local/config-samples/co1-withEE-config.json
new file mode 100644
index 0000000..2109145
--- /dev/null
+++ b/local/config-samples/co1-withEE-config.json
@@ -0,0 +1,43 @@
+{
+ "links": {
+ "netconf:10.0.0.10:830/0-of:0000001e08095936/49" : {
+ "basic" : {
+ "type" : "DIRECT"
+ }
+ },
+ "of:0000001e08095936/49-netconf:10.0.0.10:830/0" : {
+ "basic" : {
+ "type" : "DIRECT"
+ }
+ }
+ },
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.10:830/0"
+ },
+ {
+ "mefPortType" : "INNI",
+ "connectPoint" : "of:0000001e08095936/51",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "clusterIps" : [
+ "10.128.14.1"
+ ],
+ "port" : "8181",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
+
+
diff --git a/local/config-samples/co2-config.json b/local/config-samples/co2-config.json
new file mode 100644
index 0000000..4567139
--- /dev/null
+++ b/local/config-samples/co2-config.json
@@ -0,0 +1,29 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.20:830/1"
+ },
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.20:830/0",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "clusterIps" : [
+ "10.128.14.1"
+ ],
+ "port" : "8181",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
diff --git a/local/config-samples/co2-withEE-config.json b/local/config-samples/co2-withEE-config.json
new file mode 100644
index 0000000..8cc3fb9
--- /dev/null
+++ b/local/config-samples/co2-withEE-config.json
@@ -0,0 +1,43 @@
+{
+ "links": {
+ "netconf:10.0.0.20:830/0-of:0000001e08095936/50" : {
+ "basic" : {
+ "type" : "DIRECT"
+ }
+ },
+ "of:0000001e08095936/50-netconf:10.0.0.20:830/0" : {
+ "basic" : {
+ "type" : "DIRECT"
+ }
+ }
+ },
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.20:830/0"
+ },
+ {
+ "mefPortType" : "INNI",
+ "connectPoint" : "of:0000001e08095936/49",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "clusterIps" : [
+ "10.128.14.1"
+ ],
+ "port" : "8181",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
+
+
diff --git a/local/config-samples/co3-config.json b/local/config-samples/co3-config.json
new file mode 100644
index 0000000..e2bcb4f
--- /dev/null
+++ b/local/config-samples/co3-config.json
@@ -0,0 +1,28 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.30:830/0"
+ },
+ {
+ "mefPortType" : "GENERIC",
+ "connectPoint" : "netconf:10.0.0.30:830/1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "clusterIps" : [
+ "10.128.14.1"
+ ],
+ "port" : "8181",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
diff --git a/local/http-channel/pom.xml b/local/http-channel/pom.xml
new file mode 100644
index 0000000..e6a367e
--- /dev/null
+++ b/local/http-channel/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>local-channel</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Http communication channel between hierarchic ONOS controllers</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.channel.http</onos.app.name>
+ <web.context>/ecord</web.context>
+ <onos.app.title>ECORD-CE App</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <project.version>1.0.0</project.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>bigswitch</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_wab>src/main/webapp/</_wab>
+ <Bundle-SymbolicName>
+ ${project.groupId}.${project.artifactId}
+ </Bundle-SymbolicName>
+ <Import-Package>
+ *,org.glassfish.jersey.servlet
+ </Import-Package>
+ <Web-ContextPath>${web.context}</Web-ContextPath>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
\ No newline at end of file
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/ConnectionConfig.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/ConnectionConfig.java
new file mode 100644
index 0000000..a98365b
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/ConnectionConfig.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017-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.ce.local.channel.client;
+
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.domain.DomainId;
+import org.opencord.ce.api.services.channel.EndPoint;
+
+import java.util.Set;
+
+/**
+ * Configuration class for this bundle.
+ * Currently this configuration is simply the connection endpoint of the global ONOS.
+ *
+ * Look at config-samples/ecord-local-config.json for a sample configuration
+ */
+public class ConnectionConfig extends Config<ApplicationId> {
+
+ private static final String PORT = "port";
+ private static final String DOMAIN_IPS = "clusterIps";
+ private static final String USERNAME = "username";
+ private static final String PASSWD = "password";
+ private static final String TOPIC = "topic";
+
+ public EndPoint global() {
+ Set<IpAddress> ipAddresses = Sets.newHashSet();
+ object.path(DOMAIN_IPS).forEach(ipAddress -> ipAddresses.add(
+ IpAddress.valueOf(ipAddress.asText())
+ ));
+ int port = object.path(PORT).asInt();
+
+ String username = object.path(USERNAME).asText();
+ String password = object.path(PASSWD).asText();
+
+ String topic = object.path(TOPIC).asText();
+
+ return new EndPoint(DomainId.domainId("global"), ipAddresses, port,
+ username, password, topic);
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/DomainMasterIpDiscoveryTask.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/DomainMasterIpDiscoveryTask.java
new file mode 100644
index 0000000..e93625a
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/DomainMasterIpDiscoveryTask.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2017-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.ce.local.channel.client;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.jboss.netty.util.Timeout;
+import org.jboss.netty.util.TimerTask;
+import org.onlab.packet.IpAddress;
+import org.onlab.util.Timer;
+import org.opencord.ce.api.services.channel.EndPoint;
+import org.slf4j.Logger;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.opencord.ce.api.services.channel.Symbols.BASE_URL;
+import static org.opencord.ce.api.services.channel.Symbols.COLON;
+import static org.opencord.ce.api.services.channel.Symbols.DOUBLESLASH;
+import static org.opencord.ce.api.services.channel.Symbols.HTTP;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER_IP;
+import static org.opencord.ce.api.services.channel.Symbols.OK;
+import static org.opencord.ce.api.services.channel.Symbols.RESULT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Executed periodically to find the leader node of a domain.
+ * Stops when the ip is found
+ */
+public class DomainMasterIpDiscoveryTask implements TimerTask {
+
+ private final Logger log = getLogger(getClass());
+
+ private Timeout timeout;
+ private volatile boolean isStopped;
+ private EndPoint endPoint;
+ private Client client;
+ private String localSiteId;
+
+ private ObjectMapper mapper;
+
+ public DomainMasterIpDiscoveryTask(EndPoint endPoint, Client client,
+ ObjectMapper mapper, String localSiteId) {
+ this.endPoint = endPoint;
+ this.client = client;
+ this.mapper = mapper;
+ this.localSiteId = localSiteId;
+
+ isStopped = true;
+ start();
+
+ }
+
+ public synchronized void stop() {
+ if (!isStopped) {
+ isStopped = true;
+ timeout.cancel();
+ } else {
+ log.warn("IpDiscovery stopped multiple times?");
+ }
+ }
+
+ public synchronized void start() {
+ if (isStopped) {
+ isStopped = false;
+ timeout = Timer.getTimer().newTimeout(this, 0, SECONDS);
+ } else {
+ log.warn("IpDiscovery started multiple times?");
+ }
+ }
+
+ public synchronized boolean isStopped() {
+ return isStopped || timeout.isCancelled();
+ }
+
+ @Override
+ public void run(Timeout t) {
+ if (isStopped()) {
+ return;
+ }
+ for (IpAddress ipAddress : endPoint.ipAddresses()) {
+ String url = HTTP + COLON + DOUBLESLASH + ipAddress.toString() + COLON +
+ endPoint.port() + BASE_URL + "/global" + MASTER + "/" + localSiteId;
+ log.info("GET: " + url);
+ WebTarget wt = client.target(url);
+ Response response = wt.request(MediaType.APPLICATION_JSON)
+ .get();
+ log.info("DEBUG response: " + response.toString());
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+
+ continue;
+ }
+ String stringBody = response.readEntity(String.class);
+ try {
+ ObjectNode responseBody = (ObjectNode) mapper.readTree(stringBody);
+ if (responseBody.path(RESULT).asText().equals(OK)) {
+ IpAddress masterIpAdress = IpAddress.valueOf(responseBody.path(MASTER_IP).asText());
+ HttpClientInstance.INSTANCE.setMasterIp(endPoint, masterIpAdress);
+ this.stop();
+ return;
+ }
+ } catch (IOException ex) {
+ log.info("getLocalMasterIp() IOException, try next endpoint ip");
+ }
+ }
+
+ if (!isStopped()) {
+ timeout = Timer.getTimer().newTimeout(this, 3, SECONDS);
+ }
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
new file mode 100644
index 0000000..99f0d3c
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2017-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.ce.local.channel.client;
+
+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.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.config.ConfigFactory;
+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.PortDescription;
+import org.opencord.ce.api.services.channel.EndPoint;
+import org.opencord.ce.local.bigswitch.BigSwitchEvent;
+import org.opencord.ce.local.bigswitch.BigSwitchListener;
+import org.opencord.ce.local.bigswitch.BigSwitchService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * Component that reacts to the BigSwitch events by notifying the global ONOS orchestrator.
+ */
+// TODO: better name
+@Component(immediate = true)
+public class HttpClientComponent {
+ private static final String APP_NAME = "org.opencord.ce.local.channel.http";
+
+ // temporary
+ private static final String TOPIC_ONE = "ecord-domains-topic-one";
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+ private ApplicationId appId;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LeadershipService leadershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry configRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService configService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected BigSwitchService bigSwitchService;
+
+ private EndPoint globalOnos;
+
+ private final ExecutorService eventExecutor =
+ Executors.newSingleThreadExecutor();
+
+ private final ConfigFactory<ApplicationId, ConnectionConfig> configFactory =
+ new ConfigFactory<ApplicationId, ConnectionConfig>(SubjectFactories.APP_SUBJECT_FACTORY,
+ ConnectionConfig.class, "global") {
+ @Override
+ public ConnectionConfig createConfig() {
+ return new ConnectionConfig();
+ }
+ };
+
+ private final NetworkConfigListener configListener = new InternalConfigListener();
+ private final BigSwitchListener bigSwitchListener = new InternalBigSwitchListener();
+
+ @Activate
+ public void activate() {
+ log.info("Started");
+
+ appId = coreService.registerApplication(APP_NAME);
+ leadershipService.runForLeadership(TOPIC_ONE);
+ configRegistry.registerConfigFactory(configFactory);
+ configService.addListener(configListener);
+ bigSwitchService.addListener(bigSwitchListener);
+ HttpClientInstance.INSTANCE.configure(clusterService, leadershipService);
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+
+ leadershipService.withdraw(TOPIC_ONE);
+ bigSwitchService.removeListener(bigSwitchListener);
+ configService.removeListener(configListener);
+ configRegistry.unregisterConfigFactory(configFactory);
+ HttpClientInstance.INSTANCE.stopNetworkTasks();
+ }
+
+ private void readConfig() {
+ globalOnos = configRegistry.getConfig(appId, ConnectionConfig.class)
+ .global();
+ if (globalOnos == null) {
+ log.error("Configuration failure");
+ return;
+ }
+ HttpClientInstance.INSTANCE.setGlobalOnos(globalOnos);
+ }
+
+ private class InternalBigSwitchListener implements BigSwitchListener {
+
+ @Override
+ public void event(BigSwitchEvent event) {
+ log.info(event.toString());
+ switch (event.type()) {
+ case DEVICE_CREATED:
+ log.info("DEBUG: DEV_CREATED event");
+ HttpClientInstance.INSTANCE.notifyBigSwitch();
+ case PORT_ADDED:
+ case PORT_UPDATED:
+ case PORT_REMOVED:
+ // the subject is port last updated / added port
+ // but we are not interested in it now
+ List<PortDescription> ports = event.allPorts();
+ HttpClientInstance.INSTANCE.notifyBigSwitchPorts(ports);
+ break;
+ case DEVICE_REMOVED:
+ // TODO
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private class InternalConfigListener implements NetworkConfigListener {
+
+ @Override
+ public void event(NetworkConfigEvent event) {
+ if (!event.configClass().equals(ConnectionConfig.class)) {
+ return;
+ }
+ switch (event.type()) {
+ case CONFIG_ADDED:
+ log.info("Network configuration added");
+ eventExecutor.execute(HttpClientComponent.this::readConfig);
+ break;
+ case CONFIG_UPDATED:
+ log.info("Network configuration updated");
+ eventExecutor.execute(HttpClientComponent.this::readConfig);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientInstance.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientInstance.java
new file mode 100644
index 0000000..0d831d9
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientInstance.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2017-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.ce.local.channel.client;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.packet.ChassisId;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.rest.AbstractWebResource;
+import org.opencord.ce.api.services.channel.EndPoint;
+import org.opencord.ce.api.services.channel.RequestCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.opencord.ce.api.services.channel.Symbols.BASE_URL;
+import static org.opencord.ce.api.services.channel.Symbols.COLON;
+import static org.opencord.ce.api.services.channel.Symbols.DELETE;
+import static org.opencord.ce.api.services.channel.Symbols.DOUBLESLASH;
+import static org.opencord.ce.api.services.channel.Symbols.GET;
+import static org.opencord.ce.api.services.channel.Symbols.HTTP;
+import static org.opencord.ce.api.services.channel.Symbols.POST;
+
+/**
+ * HTTP client instance used to communicate
+ * to the global ONOS events related to the big switch topology abstraction.
+ */
+public enum HttpClientInstance {
+ INSTANCE;
+ private final Logger log =
+ LoggerFactory.getLogger(HttpClientInstance.class);
+ private static final Object MONITOR = new Object();
+
+ private static final int STATUS_OK = Response.Status.OK.getStatusCode();
+ private static final int STATUS_REQ_UNPROCESSABLE = Response.Status.NOT_ACCEPTABLE.getStatusCode();
+
+ private final AbstractWebResource codecContext = new AbstractWebResource();
+ private final Client client = ClientBuilder.newClient();
+
+ private ClusterService clusterService;
+ private LeadershipService leadershipService;
+ private EndPoint globalOnos;
+ private IpAddress currentRemoteMasterIp;
+ private DomainMasterIpDiscoveryTask globalMasterIpDiscoveryTask;
+
+ private final ExecutorService networkExecutor =
+ newSingleThreadExecutor();
+
+ public void configure(ClusterService clusterService, LeadershipService leadershipService) {
+ this.clusterService = clusterService;
+ this.leadershipService = leadershipService;
+ }
+
+ protected void setGlobalOnos(EndPoint globalOnos) {
+ synchronized (MONITOR) {
+ this.globalOnos = globalOnos;
+ }
+ // TODO: add leadership listeners to react to changes
+ if (isLeader(globalOnos.topic())) {
+ globalMasterIpDiscoveryTask =
+ new DomainMasterIpDiscoveryTask(globalOnos, client, codecContext.mapper(),
+ clusterService.getLocalNode().id().id());
+ } else {
+ log.info("I am NOT the leader for the communication with the global");
+ }
+ }
+
+ protected void setMasterIp(EndPoint endPoint, IpAddress ipAddress) {
+ synchronized (MONITOR) {
+ currentRemoteMasterIp = ipAddress;
+ MONITOR.notify();
+ }
+ }
+
+ private boolean isLeader(String topic) {
+ return leadershipService.getLeader(topic).id()
+ .equals(clusterService.getLocalNode().id().id());
+ }
+
+ private boolean checkReply(Response response) {
+ if (response != null) {
+ return checkStatusCode(response.getStatus());
+ }
+ log.error("Null reply from end point");
+ return false;
+ }
+
+ private boolean checkStatusCode(int statusCode) {
+ if (statusCode == STATUS_OK) {
+ return true;
+ } else {
+ log.error("Failed request, HTTP error code : "
+ + statusCode);
+ return false;
+ }
+ }
+
+ public void stopNetworkTasks() {
+ globalMasterIpDiscoveryTask.stop();
+ }
+
+ public void notifyBigSwitch() {
+ String siteId = clusterService.getLocalNode().id().id();
+ String deviceId = "domain:" + siteId;
+ String resource = "/" + siteId + "/" + deviceId;
+ ObjectNode body = codecContext.mapper().createObjectNode();
+ // body is empty for now
+ networkExecutor.execute(new NetworkTask(POST, resource, body.toString(), new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+
+ }
+
+ @Override
+ public void onError(Response response) {
+
+ }
+ }));
+ }
+
+ public void notifyBigSwitchPorts(List<PortDescription> ports) {
+ String siteId = clusterService.getLocalNode().id().id();
+ JsonCodec<Port> portCodec = codecContext.codec(Port.class);
+ ArrayNode body = codecContext.mapper().createArrayNode();
+ DeviceId deviceId = DeviceId.deviceId("domain:" + siteId);
+ ports.forEach(portDescription ->
+ body.add(portCodec.encode(new DefaultPort(new DummyDevice(deviceId), portDescription.portNumber(),
+ portDescription.isEnabled(), portDescription.type(),
+ portDescription.portSpeed(), portDescription.annotations()), codecContext)));
+ String resource = "/" + siteId + "/" + deviceId + "/ports";
+ networkExecutor.execute(new NetworkTask(POST, resource, body.toString(), new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+
+ }
+
+ @Override
+ public void onError(Response response) {
+
+ }
+ }));
+
+ }
+
+ private class NetworkTask implements Runnable {
+ private String method;
+ private String resource;
+ private String body;
+ private RequestCallback callback;
+
+ NetworkTask(String method, String resource, String body,
+ RequestCallback callback) {
+ this.method = method;
+ this.resource = resource;
+ this.body = body;
+ this.callback = callback;
+ }
+ @Override
+ public void run() {
+ synchronized (MONITOR) {
+ while (globalOnos == null || currentRemoteMasterIp == null) {
+ try {
+ log.info("wait() global-ONOS endpoint");
+ MONITOR.wait();
+ } catch (InterruptedException ie) {
+ log.info("Interrupted exception: " + ie.getMessage());
+ }
+ }
+ }
+ String url = HTTP + COLON + DOUBLESLASH + currentRemoteMasterIp + COLON +
+ globalOnos.port() + BASE_URL + "/global/topology" + resource;
+
+ log.info("Sending data via http: url: {}\n body: {}", url, body);
+
+ WebTarget webTarget = client.target(url);
+ Response response;
+ switch (method) {
+ case POST:
+ response = webTarget.request(MediaType.APPLICATION_JSON)
+ .post(Entity.entity(body, MediaType.APPLICATION_JSON));
+ break;
+ case DELETE:
+ response = webTarget.request(MediaType.APPLICATION_JSON).delete();
+ break;
+ case GET:
+ default:
+ response = webTarget.request(MediaType.APPLICATION_JSON).get();
+ break;
+ }
+
+ if (!checkReply(response)) {
+ callback.onError(response);
+ } else {
+ callback.onSuccess(response);
+ }
+ }
+ }
+
+ /**
+ * Dummy Device which only holds DeviceId.
+ */
+ private static final class DummyDevice extends DefaultDevice {
+ /**
+ * Constructs Dummy Device which only holds DeviceId.
+ *
+ * @param did device Id
+ */
+ public DummyDevice(DeviceId did) {
+ super(new ProviderId(did.uri().getScheme(), "PortCodec"), did,
+ Type.SWITCH, "dummy", "0", "0", "0", new ChassisId(),
+ DefaultAnnotations.EMPTY);
+ }
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/TestTopology.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/TestTopology.java
new file mode 100644
index 0000000..725a3db
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/TestTopology.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2017-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.ce.local.channel.client;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.packet.ChassisId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceProvider;
+import org.onosproject.net.device.DeviceProviderRegistry;
+import org.onosproject.net.device.DeviceProviderService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.link.DefaultLinkDescription;
+import org.onosproject.net.link.LinkDescription;
+import org.onosproject.net.link.LinkProvider;
+import org.onosproject.net.link.LinkProviderRegistry;
+import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Inject fake topology elements.
+ */
+//@Component(immediate = true)
+public class TestTopology implements DeviceProvider,
+ LinkProvider {
+ public static final String PROVIDER_NAME = "org.opencord.ce.local.test";
+ public static final ProviderId PROVIDER_ID = new ProviderId("test", PROVIDER_NAME);
+ private static final String UNKNOWN = "unknown";
+
+ private final Logger log = getLogger(getClass());
+ public static final String TEST_DEV_PREFIX = "test:0000";
+ public static final int NUM = 1;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceProviderRegistry deviceProviderRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkProviderRegistry linkProviderRegistry;
+
+ protected DeviceProviderService deviceProviderService;
+ protected LinkProviderService linkProviderService;
+
+ @Override
+ public ProviderId id() {
+ return PROVIDER_ID;
+ }
+
+ @Activate
+ public void activate() {
+ coreService.registerApplication(PROVIDER_NAME);
+ deviceProviderService = deviceProviderRegistry.register(this);
+ linkProviderService = linkProviderRegistry.register(this);
+
+ new Thread(this::buildFakeNetwork).start();
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ deviceProviderRegistry.unregister(this);
+ linkProviderRegistry.unregister(this);
+ log.info("Stopped");
+ }
+
+ @Override
+ public void triggerProbe(DeviceId deviceId){
+
+ }
+
+ @Override
+ public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
+
+ }
+
+ @Override
+ public boolean isReachable(DeviceId deviceId) {
+ return true;
+ }
+
+ @Override
+ public void changePortState(DeviceId deviceId, PortNumber portNumber,
+ boolean enable) {
+
+ }
+
+ private void buildFakeNetwork() {
+ ChassisId chassisId = new ChassisId();
+ SparseAnnotations annotations = DefaultAnnotations.builder()
+ .set("no-lldp", "any")
+ .set("test", "test")
+ .build();
+ int i;
+ int j;
+ for (i = 1; i <= NUM; i++) {
+ DeviceId deviceId = DeviceId.deviceId(TEST_DEV_PREFIX + i);
+ DeviceDescription deviceDescription = new DefaultDeviceDescription(
+ deviceId.uri(),
+ Device.Type.SWITCH,
+ UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
+ chassisId, annotations);
+ deviceProviderService.deviceConnected(deviceId, deviceDescription);
+ List<PortDescription> ports = new ArrayList<>();
+ for (j = 1; j <= NUM; j++) {
+ ports.add(new DefaultPortDescription(PortNumber.portNumber(j),
+ true, Port.Type.FIBER, 10000,
+ annotations));
+
+ }
+ deviceProviderService.updatePorts(deviceId, ports);
+
+ String macString = randomMCAddress();
+ log.info("MacString: {}", macString);
+/*
+ HostDescription hostDescription = new DefaultHostDescription(MacAddress.valueOf(macString),
+ VlanId.NONE,
+ new HostLocation(deviceId, PortNumber.portNumber(1), 0),
+ annotations);
+ hostProviderService.hostDetected(hostId, hostDescription, true);
+ */
+ }
+
+ long seed = (long) ThreadLocalRandom.current().nextDouble();
+ Random rand = new Random(seed);
+ for (i = 1; i <= NUM; i++) {
+ for (j = i + 1; j <= NUM; j++) {
+
+
+ if (rand.nextDouble() > 0.5) {
+ continue;
+ }
+
+ LinkDescription linkDescription = new DefaultLinkDescription(
+ ConnectPoint.deviceConnectPoint(TEST_DEV_PREFIX + i + "/" + j),
+ ConnectPoint.deviceConnectPoint(TEST_DEV_PREFIX + j + "/" + (i + 1)),
+ Link.Type.DIRECT,
+ true,
+ annotations
+ );
+ LinkDescription linkDescription1 = new DefaultLinkDescription(
+ ConnectPoint.deviceConnectPoint(TEST_DEV_PREFIX + j + "/" + (i + 1)),
+ ConnectPoint.deviceConnectPoint(TEST_DEV_PREFIX + i + "/" + j),
+ Link.Type.DIRECT,
+ true,
+ annotations
+ );
+ linkProviderService.linkDetected(linkDescription);
+ linkProviderService.linkDetected(linkDescription1);
+ }
+ }
+ }
+ private String randomMCAddress() {
+ Random rand = new Random();
+ byte[] macAddr = new byte[6];
+ rand.nextBytes(macAddr);
+
+ macAddr[0] = (byte) (macAddr[0] & (byte) 254); //zeroing last 2
+ // bytes to make it unicast and locally adminstrated
+ StringBuilder sb = new StringBuilder(18);
+ for (byte b : macAddr) {
+
+ if (sb.length() > 0) {
+ sb.append(":");
+ }
+ sb.append(String.format("%02x", b));
+ }
+ return sb.toString();
+ }
+
+
+
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/package-info.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/package-info.java
new file mode 100644
index 0000000..93ee03f
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Implementation of the client-side communication channel APIs.
+ */
+package org.opencord.ce.local.channel.client;
\ No newline at end of file
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/DomainMasterIpResource.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/DomainMasterIpResource.java
new file mode 100644
index 0000000..4f906c6
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/DomainMasterIpResource.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017-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.ce.local.channel.server;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.opencord.ce.api.services.channel.Symbols.MASTER_API_NO_IP_BODY;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER_IP;
+import static org.opencord.ce.api.services.channel.Symbols.OK;
+import static org.opencord.ce.api.services.channel.Symbols.RESULT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Gets the ip of the instance leader of the communication with the specified
+ * domainId.
+ */
+@Path("master")
+public class DomainMasterIpResource extends AbstractWebResource {
+ private final Logger log = getLogger(getClass());
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getMasterIp() {
+ log.info("Global domain asks who is the master for him");
+
+ //IpAddress ip = get(ConnectionService.class).getLocalMasterIp(id);
+
+ // testing
+ IpAddress ip = get(ClusterService.class).getLocalNode().ip();
+ if (ip != null) {
+ ObjectNode body = mapper().createObjectNode();
+ body.put(RESULT, OK);
+ body.put(MASTER_IP, ip.toString());
+
+ return ok(body.toString()).build();
+ } else {
+ return ok(MASTER_API_NO_IP_BODY).build();
+ }
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/EcordLocalRestApp.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/EcordLocalRestApp.java
new file mode 100644
index 0000000..810fa2d
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/EcordLocalRestApp.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017-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.ce.local.channel.server;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+
+/**
+ * Loader class for web resource APIs.
+ */
+public class EcordLocalRestApp extends AbstractWebApplication {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(MetroNetworkResource.class, DomainMasterIpResource.class);
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java
new file mode 100644
index 0000000..281315a
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2017-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.ce.local.channel.server;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.rest.AbstractWebResource;
+import org.opencord.ce.api.models.CarrierEthernetForwardingConstruct;
+import org.opencord.ce.api.models.CarrierEthernetNetworkInterface;
+import org.opencord.ce.api.models.CarrierEthernetUni;
+import org.opencord.ce.api.models.EvcConnId;
+import org.opencord.ce.api.services.MetroNetworkVirtualNodeService;
+import org.slf4j.Logger;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Web resource for {@link MetroNetworkVirtualNodeService}
+ * APIs.
+ */
+@Path("carrierethernet")
+public class MetroNetworkResource extends AbstractWebResource {
+ private final Logger log = getLogger(getClass());
+ private static final String FC = "fc";
+ private static final String SRC_NI = "srcNi";
+ private static final String DST_NI_LIST = "dstNiList";
+ private static final String UNI = "uni";
+
+ private JsonCodec<CarrierEthernetForwardingConstruct> fcCodec =
+ codec(CarrierEthernetForwardingConstruct.class);
+ private JsonCodec<CarrierEthernetNetworkInterface> niCodec =
+ codec(CarrierEthernetNetworkInterface.class);
+
+ @Path("ForwardingConstruct")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @POST
+ public Response setNodeForwarding(InputStream stream) {
+ try {
+ JsonNode responseBody = mapper().readTree(stream);
+ log.info(responseBody.toString());
+ MetroNetworkVirtualNodeService localNodeService =
+ get(MetroNetworkVirtualNodeService.class);
+
+ CarrierEthernetForwardingConstruct fc =
+ fcCodec.decode((ObjectNode) responseBody.path(FC), this);
+ CarrierEthernetNetworkInterface srcNi =
+ niCodec.decode((ObjectNode) responseBody.path(SRC_NI), this);
+ Set<CarrierEthernetNetworkInterface> dstNiSet = new HashSet<>();
+ responseBody.path(DST_NI_LIST).forEach(jsonDstNi ->
+ dstNiSet.add(niCodec.decode((ObjectNode) jsonDstNi, this)));
+
+ localNodeService.setNodeForwarding(fc, srcNi, dstNiSet);
+ return Response.status(200).build();
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+ }
+
+ @Path("createBwp")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @POST
+ public Response createBandwidthProfileResources(InputStream stream) {
+ try {
+ MetroNetworkVirtualNodeService localNodeService =
+ get(MetroNetworkVirtualNodeService.class);
+
+ JsonNode responseBody = mapper().readTree(stream);
+ log.info(responseBody.toString());
+
+ CarrierEthernetForwardingConstruct fc =
+ fcCodec.decode((ObjectNode) responseBody.path(FC), this);
+ CarrierEthernetUni uni = (CarrierEthernetUni)
+ niCodec.decode((ObjectNode) responseBody.path(UNI), this);
+ localNodeService.createBandwidthProfileResources(fc, uni);
+ return Response.status(200).build();
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+ }
+
+ @Path("applyBwp")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @POST
+ public Response applyBandwidthProfileResources(InputStream stream) {
+ try {
+ MetroNetworkVirtualNodeService localNodeService =
+ get(MetroNetworkVirtualNodeService.class);
+
+ JsonNode responseBody = mapper().readTree(stream);
+ log.info(responseBody.toString());
+
+ CarrierEthernetForwardingConstruct fc =
+ fcCodec.decode((ObjectNode) responseBody.path(FC), this);
+ CarrierEthernetUni uni = (CarrierEthernetUni)
+ niCodec.decode((ObjectNode) responseBody.path(UNI), this);
+
+ localNodeService.applyBandwidthProfileResources(fc, uni);
+ return Response.status(200).build();
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+ }
+
+ @Path("deleteBwp")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @POST
+ public Response removeBandwidthProfileResources(InputStream stream) {
+ try {
+ MetroNetworkVirtualNodeService localNodeService =
+ get(MetroNetworkVirtualNodeService.class);
+
+ JsonNode responseBody = mapper().readTree(stream);
+ log.info(responseBody.toString());
+
+ CarrierEthernetForwardingConstruct fc =
+ fcCodec.decode((ObjectNode) responseBody.path(FC), this);
+
+ CarrierEthernetUni uni = (CarrierEthernetUni)
+ niCodec.decode((ObjectNode) responseBody.path(UNI), this);
+
+ localNodeService.applyBandwidthProfileResources(fc, uni);
+ return Response.status(200).build();
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+ }
+
+ @Path("deleteFcResources/{fcId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @GET
+ public Response removeAllForwardingResources(@PathParam("{fcId}") String fcId) {
+ EvcConnId evcId = EvcConnId.of(fcId);
+ MetroNetworkVirtualNodeService localNodeService =
+ get(MetroNetworkVirtualNodeService.class);
+
+ localNodeService.removeAllForwardingResources(evcId);
+ return Response.status(200).build();
+ }
+}
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/package-info.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/package-info.java
new file mode 100644
index 0000000..ab612ed
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Implementation of the server-side communication channel APIs.
+ */
+package org.opencord.ce.local.channel.server;
\ No newline at end of file
diff --git a/local/http-channel/src/main/webapp/WEB-INF/web.xml b/local/http-channel/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..32cc06c
--- /dev/null
+++ b/local/http-channel/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>ICONA REST API v1.0</display-name>
+
+ <servlet>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.opencord.ce.local.channel.server.EcordLocalRestApp</param-value>
+ </init-param>
+ <load-on-startup>10</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAX-RS Service</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/local/pom.xml b/local/pom.xml
new file mode 100644
index 0000000..c91f1b8
--- /dev/null
+++ b/local/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord</groupId>
+ <artifactId>ce</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0</version>
+ <packaging>pom</packaging>
+
+ <description>Local components of the Carrier Ethernet Metro application</description>
+
+ <properties>
+ <onos.version>1.10.3</onos.version>
+ <onos.app.title>ECORD Carrier Ethernet local site component</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ </properties>
+
+ <modules>
+ <module>bigswitch</module>
+ <module>http-channel</module>
+ <module>ce-transport</module>
+ <module>ce-vee</module>
+ <module>ce-central-office</module>
+ <module>common-component</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>ce-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases><enabled>false</enabled></releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+</project>