Porting CE app to 4.1
Change-Id: Ic3280ce797f6225773ade789d9793ae445f9f525
diff --git a/local/bigswitch/pom.xml b/local/bigswitch/pom.xml
new file mode 100644
index 0000000..f11c4a6
--- /dev/null
+++ b/local/bigswitch/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</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>E-CORD Carrier Ethernet bigswitch abstraction</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <onos.version>1.10.6</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>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </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..54fac26
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchEvent.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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..2738916
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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..4629295
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchManager.java
@@ -0,0 +1,409 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.base.Strings;
+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.cfg.ComponentConfigService;
+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.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 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.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.opencord.ce.local.bigswitch.MefPortsConfig.MefPortConfig;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * 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 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 ComponentConfigService componentConfigService;
+
+ @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 StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService networkConfigService;
+
+ private static final String DOMAIN_ID = "domainId";
+ @Property(name = DOMAIN_ID, value = DEFAULT_DOMAIN_ID, label = "Domain ID where this ONOS is running")
+ private String domainId = DEFAULT_DOMAIN_ID;
+
+ 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 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.registerApplication(APP_NAME);
+ componentConfigService.registerProperties(getClass());
+ configRegistry.registerConfigFactory(configFactory);
+ networkConfigService.addListener(configListener);
+ 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);
+ deviceService.addListener(deviceListener);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ networkConfigService.removeListener(configListener);
+ configRegistry.unregisterConfigFactory(configFactory);
+ deviceService.removeListener(deviceListener);
+ componentConfigService.unregisterProperties(getClass(), false);
+ log.info("Stopped");
+ }
+
+ @Modified
+ public void modified(ComponentContext context) {
+ Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
+
+ String d = get(properties, DOMAIN_ID);
+ if (!Strings.isNullOrEmpty(d)) {
+ // TODO: signal new domain id to global
+ domainId = d;
+ }
+
+ log.info("Domain ID set to {}", domainId());
+ }
+
+ @Override
+ public List<PortDescription> getPorts() {
+ return portMap.keySet().stream()
+ .map(this::toVirtualPortDescription)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public PortNumber getPort(ConnectPoint port) {
+ // FIXME: 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 domainId() {
+ return DomainId.domainId(domainId);
+ }
+
+ /**
+ * 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, domainId);
+ // 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 (mefPortConfigs != null) {
+ buildPorts();
+ log.info("Notifying Bigswitch presence..");
+ if (portMap.size() > 0) {
+ post(new BigSwitchEvent(BigSwitchEvent.Type.DEVICE_CREATED, null, 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..02f82de
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/BigSwitchService.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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 domain ID of this bigswitch.
+ *
+ * @return domain ID
+ */
+ DomainId domainId();
+}
+
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..3932acb
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/MefPortsConfig.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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..22af7db
--- /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 Foundation
+ *
+ * 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..b94fec5
--- /dev/null
+++ b/local/bigswitch/src/main/java/org/opencord/ce/local/bigswitch/cli/ConnectPointFromVirtPortCmd.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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..194fb9f
--- /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 Foundation
+ *
+ * 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..ca91d6a
--- /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 Foundation
+ *
+ * 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..2db5ad1
--- /dev/null
+++ b/local/bigswitch/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-fabric/features.xml b/local/ce-fabric/features.xml
new file mode 100644
index 0000000..83ba135
--- /dev/null
+++ b/local/ce-fabric/features.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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:com.google.code.gson/gson/2.6.2</bundle>
+ </feature>
+</features>
diff --git a/local/ce-fabric/pom.xml b/local/ce-fabric/pom.xml
new file mode 100644
index 0000000..0e3bb75
--- /dev/null
+++ b/local/ce-fabric/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>fabric</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>CORD application for Carrier Ethernet Service</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.fabric</onos.app.name>
+ <onos.version>1.10.6</onos.version>
+ <onos.app.title>E-CORD Central Office fabric config</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <onos.app.requires>org.opencord.ce.local.bigswitch</onos.app.requires>
+ <onos.app.requires>org.opencord.ce.local.channel.http</onos.app.requires>
+ </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>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>bigswitch</artifactId>
+ <version>${parent.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <version>${onos.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <version>2.25.1</version>
+ </dependency>
+ </dependencies>
+
+ <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-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricConfig.java b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricConfig.java
new file mode 100644
index 0000000..2d8a9c1
--- /dev/null
+++ b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricConfig.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.fabric;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.Config;
+
+/**
+ * Configuration for single switch CORD fabric manager for Carrier Ethernet services.
+ */
+public class CarrierEthernetFabricConfig extends Config<ApplicationId> {
+ private static final int DEFAULT_PORT = 8181;
+ private static final String DEFAULT_USERNAME = "onos";
+ private static final String DEFAULT_PASSWORD = "rocks";
+
+ private static final String PUBLIC_IP = "publicIp";
+ private static final String PORT = "port";
+ private static final String USERNAME = "username";
+ private static final String PASSWORD = "password";
+ private static final String DEVICE_ID = "deviceId";
+
+ @Override
+ public boolean isValid() {
+ return hasOnlyFields(PUBLIC_IP, PORT, USERNAME, PASSWORD, DEVICE_ID) &&
+ publicIp() != null &&
+ deviceId() != null;
+ }
+
+ public IpAddress publicIp() {
+ String ip = get(PUBLIC_IP, null);
+ try {
+ return IpAddress.valueOf(ip);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public Integer port() {
+ String port = get(PORT, String.valueOf(DEFAULT_PORT));
+ try {
+ return Integer.valueOf(port);
+ } catch (NumberFormatException e) {
+ return DEFAULT_PORT;
+ }
+ }
+
+ public String username() {
+ return get(USERNAME, String.valueOf(DEFAULT_USERNAME));
+ }
+
+ public String password() {
+ return get(PASSWORD, String.valueOf(DEFAULT_PASSWORD));
+ }
+
+ public DeviceId deviceId() {
+ String did = get(DEVICE_ID, null);
+ try {
+ return DeviceId.deviceId(did);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+}
diff --git a/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricManager.java b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricManager.java
new file mode 100644
index 0000000..249031b
--- /dev/null
+++ b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/CarrierEthernetFabricManager.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.fabric;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+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.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+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.opencord.ce.local.bigswitch.BigSwitchService;
+import org.slf4j.Logger;
+
+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.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Manages a single switch CORD fabric for Carrier Ethernet services.
+ *
+ * Receives forwarding constructs from global orchestrator,
+ * and generates VLAN cross connect configuration for the
+ * ONOS fabric controller.
+ *
+ * No resources are allocated so only the node forwarding API is implemented.
+ */
+@Component(immediate = true)
+@Service
+public class CarrierEthernetFabricManager implements MetroNetworkVirtualNodeService {
+ private static final Logger log = getLogger(CarrierEthernetFabricManager.class);
+ private static final String APP_NAME = "org.opencord.ce.local.fabric";
+ private static final String APPS = "apps";
+ private static final String SEGMENT_ROUTING = "org.onosproject.segmentrouting";
+ private static final String XCONNECT = "xconnect";
+ private static final String VLAN = "vlan";
+ private static final String PORTS = "ports";
+ private static final String NAME = "name";
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected BigSwitchService bigSwitchService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry cfgService;
+
+ private final InternalConfigListener cfgListener = new InternalConfigListener();
+
+ private final ConfigFactory<ApplicationId, CarrierEthernetFabricConfig> configFactory =
+ new ConfigFactory<ApplicationId, CarrierEthernetFabricConfig>(APP_SUBJECT_FACTORY,
+ CarrierEthernetFabricConfig.class, "segmentrouting_ctl", false) {
+ @Override
+ public CarrierEthernetFabricConfig createConfig() {
+ return new CarrierEthernetFabricConfig();
+ }
+ };
+
+ private ApplicationId appId;
+ // TODO: use distributed maps via storage service
+ private Set<CarrierEthernetForwardingConstruct> forwardingConstructs = new LinkedHashSet<>();
+ private Map<EvcConnId, ConnectPoint> eePorts = new HashMap<>();
+ private Map<EvcConnId, ConnectPoint> upstreamPorts = new HashMap<>();
+ private IpAddress publicIp;
+ private Integer port;
+ private String username;
+ private String password;
+ private DeviceId deviceId;
+
+ @Activate
+ protected void activate() {
+ appId = coreService.registerApplication(APP_NAME);
+ cfgService.addListener(cfgListener);
+ cfgService.registerConfigFactory(configFactory);
+ cfgListener.doUpdate(cfgService.getConfig(appId, CarrierEthernetFabricConfig.class));
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ cfgService.removeListener(cfgListener);
+ cfgService.unregisterConfigFactory(configFactory);
+ log.info("Stopped");
+ }
+
+ @Override
+ public void setNodeForwarding(CarrierEthernetForwardingConstruct fc,
+ CarrierEthernetNetworkInterface srcNi,
+ Set<CarrierEthernetNetworkInterface> dstNiSet) {
+ addCrossconnect(fc, srcNi, dstNiSet);
+ postToSegmentRouting(buildConfig());
+ }
+
+ @Override
+ public void createBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ // No resources are allocated on the fabric
+ return;
+ }
+
+ @Override
+ public void applyBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ // No resources are allocated on the fabric
+ return;
+ }
+
+ @Override
+ public void removeBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ // No resources are allocated on the fabric
+ return;
+ }
+
+ @Override
+ public void removeAllForwardingResources(EvcConnId fcId) {
+ removeCrossconnect(fcId);
+ postToSegmentRouting(buildConfig());
+ }
+
+ /**
+ * Adds a fabric cross connect based on given Carrier Ethernet service.
+ *
+ * @param fc forwarding construct
+ * @param srcNi source network interface
+ * @param dstNiSet set of destination network interfaces
+ */
+ public void addCrossconnect(CarrierEthernetForwardingConstruct fc,
+ CarrierEthernetNetworkInterface srcNi,
+ Set<CarrierEthernetNetworkInterface> dstNiSet) {
+ // Store fc and extract physical fabric ports
+ Optional<ConnectPoint> eePort = bigSwitchService.connectPointFromVirtPort(srcNi.cp().port());
+ // Assume only a single upstream port is used, so we select randomly from set
+ CarrierEthernetNetworkInterface dstNi = dstNiSet.iterator().next();
+ Optional<ConnectPoint> upstreamPort = (dstNi == null) ? Optional.empty() :
+ bigSwitchService.connectPointFromVirtPort(dstNi.cp().port());
+ if (!eePort.isPresent() || !upstreamPort.isPresent()) {
+ log.error("Failed to install node forwarding, missing fabric ports: EE {} - upstream {}",
+ eePort, upstreamPort);
+ return;
+ } else {
+ forwardingConstructs.add(fc);
+ eePorts.put(fc.id(), eePort.get());
+ upstreamPorts.put(fc.id(), upstreamPort.get());
+ }
+ }
+
+ /**
+ * Removes a fabric cross connect based on given forwarding construct.
+ *
+ * @param fcId forwarding construct id
+ */
+ public void removeCrossconnect(EvcConnId fcId) {
+ for (Iterator<CarrierEthernetForwardingConstruct> i = forwardingConstructs.iterator(); i.hasNext();) {
+ CarrierEthernetForwardingConstruct fc = i.next();
+ if (fcId.equals(fc.id())) {
+ forwardingConstructs.remove(fc);
+ break;
+ }
+ }
+ eePorts.remove(fcId);
+ upstreamPorts.remove(fcId);
+ }
+
+
+ /**
+ * All VLAN cross connects are rebuilt and pushed out since ONOS network config does not support updates.
+ *
+ * @return JSON with cross connect configuration for segment routing app
+ */
+ public JsonObject buildConfig() {
+ JsonArray xconnects = new JsonArray();
+ forwardingConstructs.stream()
+ .map(fc -> json(fc))
+ .forEach(fc -> xconnects.add(fc));
+
+ JsonObject dpid = new JsonObject();
+ dpid.add(deviceId.toString(), xconnects);
+
+ JsonObject xconnect = new JsonObject();
+ xconnect.add(XCONNECT, dpid);
+
+ JsonObject appName = new JsonObject();
+ appName.add(SEGMENT_ROUTING, xconnect);
+
+ JsonObject config = new JsonObject();
+ config.add(APPS, appName);
+
+ return config;
+ }
+
+ /**
+ * Execute REST POST to segment routing app with given VLAN cross connect config.
+ *
+ * @param json fabric VLAN cross connect configuration in json form
+ */
+ public void postToSegmentRouting(JsonObject json) {
+ // Setup credentials
+ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+ .nonPreemptive()
+ .credentials(username, password)
+ .build();
+ ClientConfig cfg = new ClientConfig();
+ cfg.register(feature);
+ Client client = ClientBuilder.newClient(cfg);
+
+ // Build URL and perform post
+ WebTarget target = client.target("http://" + publicIp + ":" + port + "/onos/v1/network/configuration/");
+ Response response = target.request().post(Entity.entity(json, MediaType.APPLICATION_JSON_TYPE));
+ response.close();
+ }
+
+ /**
+ * Build fabric config json from forwarding construct.
+ *
+ * Example VLAN cross connect configuration for fabric
+ * "apps": {
+ * "org.onosproject.segmentrouting": {
+ * "xconnect": {
+ * "of:0000000000000001": [{
+ * "vlan": 10,
+ * "ports": [5, 73],
+ * "name": "OLT1"
+ * }]
+ * }
+ * }
+ * }
+ */
+ private JsonObject json(CarrierEthernetForwardingConstruct fc) {
+ JsonObject jo = new JsonObject();
+ jo.addProperty(VLAN, fc.vlanId().toShort());
+
+ // First port is EE -> fabric, second is fabric -> upstream / CO egress
+ JsonArray ports = new JsonArray();
+ // FIXME: need to be more careful of nulls here
+ ports.add(eePorts.get(fc.id()).port().toLong());
+ ports.add(upstreamPorts.get(fc.id()).port().toLong());
+ jo.add(PORTS, ports);
+
+ jo.addProperty(NAME, fc.id().id());
+
+ return jo;
+ }
+
+ private class InternalConfigListener implements NetworkConfigListener {
+ private void doUpdate(CarrierEthernetFabricConfig cfg) {
+ if (cfg == null) {
+ log.error("Fabric config for VLAN xconnect missing");
+ return;
+ }
+
+ publicIp = cfg.publicIp();
+ port = cfg.port();
+ username = cfg.username();
+ password = cfg.password();
+ deviceId = cfg.deviceId();
+ log.info("Reconfigured");
+ }
+
+ @Override
+ public void event(NetworkConfigEvent event) {
+ if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
+ event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
+ event.configClass().equals(CarrierEthernetFabricConfig.class)) {
+
+ if (event.config().isPresent()) {
+ doUpdate((CarrierEthernetFabricConfig) event.config().get());
+ }
+ }
+ }
+ }
+}
diff --git a/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/package-info.java b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/package-info.java
new file mode 100644
index 0000000..0b030a4
--- /dev/null
+++ b/local/ce-fabric/src/main/java/org/opencord/ce/local/fabric/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * Single switch CORD fabric support for Carrier Ethernet services.
+ */
+package org.opencord.ce.local.fabric;
\ No newline at end of file
diff --git a/local/ce-fabric/src/test/java/org.opencord.ce.local.fabric/CarrierEthernetFabricManagerTest.java b/local/ce-fabric/src/test/java/org.opencord.ce.local.fabric/CarrierEthernetFabricManagerTest.java
new file mode 100644
index 0000000..cabcb77
--- /dev/null
+++ b/local/ce-fabric/src/test/java/org.opencord.ce.local.fabric/CarrierEthernetFabricManagerTest.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.fabric;
+
+import com.google.common.collect.Sets;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onlab.junit.TestUtils;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.TestServiceDirectory;
+import org.onlab.packet.VlanId;
+import org.onosproject.core.CoreServiceAdapter;
+import org.onosproject.event.AbstractListenerManager;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.NetworkConfigRegistryAdapter;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.domain.DomainId;
+import org.opencord.ce.api.models.CarrierEthernetConnection;
+import org.opencord.ce.api.models.CarrierEthernetEnni;
+import org.opencord.ce.api.models.CarrierEthernetForwardingConstruct;
+import org.opencord.ce.api.models.CarrierEthernetInni;
+import org.opencord.ce.api.models.CarrierEthernetLogicalTerminationPoint;
+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.local.bigswitch.BigSwitchEvent;
+import org.opencord.ce.local.bigswitch.BigSwitchListener;
+import org.opencord.ce.local.bigswitch.BigSwitchService;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for {@link CarrierEthernetFabricManager}.
+ */
+public class CarrierEthernetFabricManagerTest {
+
+ private CarrierEthernetFabricManager target;
+ private static ServiceDirectory original;
+ private static TestServiceDirectory directory;
+
+ private CarrierEthernetLogicalTerminationPoint ltpSrc;
+ private CarrierEthernetLogicalTerminationPoint ltpDst;
+ // Physical connect points
+ private static ConnectPoint srcUniCp = ConnectPoint.deviceConnectPoint("netconf:10.0.0.10/1");
+ private ConnectPoint dstUniCp = ConnectPoint.deviceConnectPoint("netconf:10.0.0.20/1");
+ private ConnectPoint inniPhyCp = ConnectPoint.deviceConnectPoint("of:0000000000000001/1");
+ private ConnectPoint enni1PhyCp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2");
+ private ConnectPoint enni2PhyCp = ConnectPoint.deviceConnectPoint("of:0000000000000001/3");
+ // Bigswitch (logical) connect points
+ private ConnectPoint inniBsCp = ConnectPoint.deviceConnectPoint("domain:0000000000000001/1");
+ private ConnectPoint enni1BsCp = ConnectPoint.deviceConnectPoint("domain:0000000000000001/2");
+ private ConnectPoint enni2BsCp = ConnectPoint.deviceConnectPoint("domain:0000000000000001/3");
+ // Carrier Ethernet models
+ private CarrierEthernetForwardingConstruct fc1;
+ private CarrierEthernetForwardingConstruct fc2;
+ private CarrierEthernetNetworkInterface srcUni;
+ private CarrierEthernetNetworkInterface dstUni;
+ private CarrierEthernetNetworkInterface inni;
+ private CarrierEthernetNetworkInterface enni1;
+ private CarrierEthernetNetworkInterface enni2;
+
+ private DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
+ private static VlanId vlan1 = VlanId.vlanId((short) 100);
+ private static VlanId vlan2 = VlanId.vlanId((short) 200);
+
+ @BeforeClass
+ public static void setUpBaseConfigClass() throws TestUtils.TestUtilsException {
+ directory = new TestServiceDirectory();
+ directory.add(DeviceService.class, new DeviceServiceAdapter(Collections.emptyList()));
+ original = TestUtils.getField(CarrierEthernetNetworkInterface.class, "serviceDirectory");
+ TestUtils.setField(CarrierEthernetNetworkInterface.class, "serviceDirectory", directory);
+ }
+
+ @AfterClass
+ public static void tearDownBaseConfigClass() throws TestUtils.TestUtilsException {
+ TestUtils.setField(CarrierEthernetNetworkInterface.class, "serviceDirectory", original);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ // Initialize the fabric manager
+ target = new CarrierEthernetFabricManager();
+ target.bigSwitchService = new TestBigSwitchService();
+ target.cfgService = new NetworkConfigRegistryAdapter();
+ target.coreService = new CoreServiceAdapter();
+
+ // Build UNIs
+ srcUni = CarrierEthernetUni.builder()
+ .cp(srcUniCp)
+ .build();
+ dstUni = CarrierEthernetUni.builder()
+ .cp(dstUniCp)
+ .build();
+ ltpSrc = new CarrierEthernetLogicalTerminationPoint("srcUni", srcUni);
+ ltpDst = new CarrierEthernetLogicalTerminationPoint("dstUni", dstUni);
+
+ // Build FC connecting UNIs
+ fc1 = CarrierEthernetForwardingConstruct.builder()
+ .cfgId("test1")
+ .id(EvcConnId.of("test1"))
+ .type(CarrierEthernetConnection.Type.POINT_TO_POINT)
+ .ltpSet(Sets.newHashSet(ltpSrc, ltpDst))
+ .build();
+ fc1.setVlanId(vlan1);
+ fc2 = CarrierEthernetForwardingConstruct.builder()
+ .cfgId("test2")
+ .id(EvcConnId.of("test2"))
+ .type(CarrierEthernetConnection.Type.POINT_TO_POINT)
+ .ltpSet(Sets.newHashSet(ltpSrc, ltpDst))
+ .build();
+ fc2.setVlanId(vlan2);
+ inni = CarrierEthernetInni.builder()
+ .cp(inniBsCp)
+ .build();
+ enni1 = CarrierEthernetEnni.builder()
+ .cp(enni1BsCp)
+ .build();
+ enni2 = CarrierEthernetEnni.builder()
+ .cp(enni2BsCp)
+ .build();
+
+ target.activate();
+ }
+
+ @After
+ public void tearDown() {
+ target.deactivate();
+ }
+
+ @Test
+ public void testBuildConfig() {
+ TestUtils.setField(target, "deviceId", deviceId);
+ JsonParser parser = new JsonParser();
+ JsonObject json;
+ String expected;
+
+ // Add first fc
+ target.addCrossconnect(fc1, inni, Sets.newHashSet(enni1));
+ json = target.buildConfig();
+ expected =
+ "{\"apps\":{" +
+ "\"org.onosproject.segmentrouting\":{" +
+ "\"xconnect\":{" +
+ "\"of:0000000000000001\":[{" +
+ "\"vlan\":" + vlan1.toString() + "," +
+ "\"ports\":[1, 2]," +
+ "\"name\": \"" + fc1.id().id() + "\"}" +
+ "]}}}}";
+ assertEquals(json, parser.parse(expected).getAsJsonObject());
+
+ // Add second fc
+ target.addCrossconnect(fc2, inni, Sets.newHashSet(enni2));
+ json = target.buildConfig();
+ expected =
+ "{\"apps\":{" +
+ "\"org.onosproject.segmentrouting\":{" +
+ "\"xconnect\":{" +
+ "\"of:0000000000000001\":[{" +
+ "\"vlan\":" + vlan1.toString() + "," +
+ "\"ports\":[1, 2]," +
+ "\"name\": \"" + fc1.id().id() + "\"}," +
+ "{\"vlan\":" + vlan2.toString() + "," +
+ "\"ports\":[1, 3]," +
+ "\"name\": \"" + fc2.id().id() + "\"}" +
+ "]}}}}";
+ assertEquals(json, parser.parse(expected).getAsJsonObject());
+
+ // Remove first fc
+ target.removeCrossconnect(fc1.id());
+ json = target.buildConfig();
+ expected =
+ "{\"apps\":{" +
+ "\"org.onosproject.segmentrouting\":{" +
+ "\"xconnect\":{" +
+ "\"of:0000000000000001\":[{" +
+ "\"vlan\":" + vlan2.toString() + "," +
+ "\"ports\":[1, 3]," +
+ "\"name\": \"" + fc2.id().id() + "\"}" +
+ "]}}}}";
+ assertEquals(json, parser.parse(expected).getAsJsonObject());
+ }
+
+ private class TestBigSwitchService
+ extends AbstractListenerManager<BigSwitchEvent, BigSwitchListener>
+ implements BigSwitchService {
+
+ @Override
+ public List<PortDescription> getPorts() {
+ return null;
+ }
+
+ @Override
+ public PortNumber getPort(ConnectPoint port) {
+ return null;
+ }
+
+ @Override
+ public Optional<ConnectPoint> connectPointFromVirtPort(PortNumber portNumber) {
+ if (portNumber.toLong() == 1) {
+ return Optional.of(inniPhyCp);
+ }
+ if (portNumber.toLong() == 2) {
+ return Optional.of(enni1PhyCp);
+ }
+ if (portNumber.toLong() == 3) {
+ return Optional.of(enni2PhyCp);
+ }
+
+ return Optional.empty();
+ }
+
+ @Override
+ public DomainId domainId() {
+ return null;
+ }
+ }
+}
diff --git a/local/ce-transport/pom.xml b/local/ce-transport/pom.xml
new file mode 100644
index 0000000..13203ba
--- /dev/null
+++ b/local/ce-transport/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</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.6</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..6da5261
--- /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 Foundation
+ *
+ * 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..5ac2ee6
--- /dev/null
+++ b/local/ce-vee/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>vee</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <description>Virtual Ethernet Edge service for CORD</description>
+
+ <properties>
+ <onos.app.name>org.opencord.ce.local.vee</onos.app.name>
+ <onos.app.title>E-CORD Ethernet Edge app</onos.app.title>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <onos.app.requires>org.opencord.ce.local.bigswitch</onos.app.requires>
+ <onos.app.requires>org.opencord.ce.local.channel.http</onos.app.requires>
+ </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..1ac2b21
--- /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 Foundation
+ *
+ * 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..c8ee47d
--- /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 Foundation
+ *
+ * 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..296464a
--- /dev/null
+++ b/local/common-component/app.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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>
+</app>
diff --git a/local/common-component/features.xml b/local/common-component/features.xml
new file mode 100644
index 0000000..839d7c3
--- /dev/null
+++ b/local/common-component/features.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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>
+ </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..057156a
--- /dev/null
+++ b/local/common-component/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ecord-local-app</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <description>Java application bundling the bigswitch abstraction
+ and the HTTP channel component
+ </description>
+
+ <properties>
+ <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>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/local/config-samples/co1-onos-cord-cfg.json b/local/config-samples/co1-onos-cord-cfg.json
new file mode 100644
index 0000000..a908151
--- /dev/null
+++ b/local/config-samples/co1-onos-cord-cfg.json
@@ -0,0 +1,27 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.10:830/1"
+ },
+ {
+ "mefPortType" : "INNI",
+ "connectPoint" : "netconf:10.0.0.10:830/0",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "publicIp" : "10.128.14.1",
+ "port" : "8182",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
diff --git a/local/config-samples/co1-withEE-onos-cord-cfg.json b/local/config-samples/co1-withEE-onos-cord-cfg.json
new file mode 100644
index 0000000..e54cf63
--- /dev/null
+++ b/local/config-samples/co1-withEE-onos-cord-cfg.json
@@ -0,0 +1,41 @@
+{
+ "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" : {
+ "publicIp" : "10.128.14.1",
+ "port" : "8182",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
+
+
diff --git a/local/config-samples/co2-onos-cord-cfg.json b/local/config-samples/co2-onos-cord-cfg.json
new file mode 100644
index 0000000..210c7c5
--- /dev/null
+++ b/local/config-samples/co2-onos-cord-cfg.json
@@ -0,0 +1,27 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "UNI",
+ "connectPoint" : "netconf:10.0.0.20:830/1"
+ },
+ {
+ "mefPortType" : "INNI",
+ "connectPoint" : "netconf:10.0.0.20:830/0",
+ "interlinkId" : "cm-1"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "publicIp" : "10.128.14.1",
+ "port" : "8182",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
diff --git a/local/config-samples/co2-withEE-onos-cord-cfg.json b/local/config-samples/co2-withEE-onos-cord-cfg.json
new file mode 100644
index 0000000..78b14b5
--- /dev/null
+++ b/local/config-samples/co2-withEE-onos-cord-cfg.json
@@ -0,0 +1,41 @@
+{
+ "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" : {
+ "publicIp" : "10.128.14.1",
+ "port" : "8182",
+ "username" : "sdn",
+ "password" : "rocks",
+ "topic" : "ecord-domains-topic-one"
+ }
+ }
+ }
+}
+
+
diff --git a/local/config-samples/onos-fabric-cfg.json b/local/config-samples/onos-fabric-cfg.json
new file mode 100644
index 0000000..a9a6f6f
--- /dev/null
+++ b/local/config-samples/onos-fabric-cfg.json
@@ -0,0 +1,38 @@
+{
+ "apps" : {
+ "org.opencord.ce.local.fabric" : {
+ "segmentrouting_ctl": {
+ "publicIp": "127.0.0.1",
+ "port": "8181",
+ "username": "sdn",
+ "password": "rocks",
+ "deviceId": "of:0000001e08095936"
+ }
+ },
+ "org.opencord.ce.local.bigswitch" : {
+ "mefPorts" :
+ [
+ {
+ "mefPortType" : "INNI",
+ "connectPoint" : "of:0000001e08095936/1",
+ "interlinkId" : "EE-2-fabric"
+ },
+ {
+ "mefPortType" : "ENNI",
+ "connectPoint" : "of:0000001e08095936/49",
+ "interlinkId" : "fabric-upstream"
+ }
+ ]
+ },
+ "org.opencord.ce.local.channel.http" : {
+ "global" : {
+ "publicIp" : "10.128.14.1",
+ "port" : "8182",
+ "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..90e4c64
--- /dev/null
+++ b/local/http-channel/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>local-channel</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <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>E-CORD 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>
+ <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..2113862
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/ConnectionConfig.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.models.DomainEndPoint;
+
+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 PUBLIC_IP = "publicIp";
+ private static final String USERNAME = "username";
+ private static final String PASSWD = "password";
+ private static final String TOPIC = "topic";
+
+ public DomainEndPoint global() {
+ Set<IpAddress> ipAddresses = Sets.newHashSet();
+ IpAddress publicIp = IpAddress.valueOf(object.path(PUBLIC_IP).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 DomainEndPoint(DomainId.domainId("global"), publicIp, 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..e8513c9
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/DomainMasterIpDiscoveryTask.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.models.DomainEndPoint;
+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 DomainEndPoint endPoint;
+ private Client client;
+ private String localSiteId;
+
+ private ObjectMapper mapper;
+
+ public DomainMasterIpDiscoveryTask(DomainEndPoint 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;
+ }
+ String url = HTTP + COLON + DOUBLESLASH + endPoint.publicIp() + 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()) {
+ 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());
+ 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..a29299b
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientComponent.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.models.DomainEndPoint;
+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 static DomainEndPoint 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);
+ if (globalOnos != null) {
+ leadershipService.withdraw(globalOnos.topic());
+ }
+ }
+
+ private void readConfig() {
+ globalOnos = configRegistry.getConfig(appId, ConnectionConfig.class)
+ .global();
+ if (globalOnos == null) {
+ log.error("Configuration failure");
+ return;
+ }
+ leadershipService.runForLeadership(globalOnos.topic());
+ 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(bigSwitchService.domainId());
+ 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(bigSwitchService.domainId(), 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..132e648
--- /dev/null
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/client/HttpClientInstance.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.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.domain.DomainId;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.rest.AbstractWebResource;
+import org.opencord.ce.api.models.DomainEndPoint;
+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 DomainEndPoint globalOnos;
+
+ private final ExecutorService networkExecutor =
+ newSingleThreadExecutor();
+
+ public void configure(ClusterService clusterService, LeadershipService leadershipService) {
+ this.clusterService = clusterService;
+ this.leadershipService = leadershipService;
+ }
+
+ protected void setGlobalOnos(DomainEndPoint globalOnos) {
+ synchronized (MONITOR) {
+ this.globalOnos = globalOnos;
+ }
+ }
+
+ 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 notifyBigSwitch(DomainId siteId) {
+ String deviceId = "domain:" + siteId.id();
+ 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(DomainId siteId, List<PortDescription> ports) {
+ JsonCodec<Port> portCodec = codecContext.codec(Port.class);
+ ArrayNode body = codecContext.mapper().createArrayNode();
+ DeviceId deviceId = DeviceId.deviceId("domain:" + siteId.id());
+ 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) {
+ try {
+ log.info("wait() global ONOS endpoint");
+ MONITOR.wait();
+ } catch (InterruptedException ie) {
+ log.info("Interrupted exception: " + ie.getMessage());
+ }
+ }
+ }
+ if (!isLeader(globalOnos.topic())) {
+ return;
+ }
+ String url = HTTP + COLON + DOUBLESLASH + globalOnos.publicIp() + 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..23f1337
--- /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 Foundation
+ *
+ * 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..f961747
--- /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 Foundation
+ *
+ * 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/EcordLocalRestApp.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/EcordLocalRestApp.java
new file mode 100644
index 0000000..51b8b32
--- /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 Foundation
+ *
+ * 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);
+ }
+}
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..acd04cd
--- /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 Foundation
+ *
+ * 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..d2886b7
--- /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 Foundation
+ *
+ * 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..06ebfcd
--- /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 2017-present Open Networking Foundation
+ ~
+ ~ 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..ed76a1c
--- /dev/null
+++ b/local/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2017-present Open Networking Foundation
+ ~
+ ~ 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-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>local</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <description>Local components of the CORD Carrier Ethernet service</description>
+
+ <properties>
+ <onos.version>1.10.6</onos.version>
+ <onos.app.title>E-CORD 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-fabric</module>
+ <module>common-component</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>ce-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ <version>${onos.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </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>