Initial development of Carrier Ethernet E-CORD
Change-Id: I57ca86dc1dd6a19636f3778d6f5030df33169144
diff --git a/global/http-channel/pom.xml b/global/http-channel/pom.xml
new file mode 100644
index 0000000..1ff30e9
--- /dev/null
+++ b/global/http-channel/pom.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2015-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>global</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>global-channel</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Http communication channel between hierarchic ONOS controllers</description>
+
+ <properties>
+ <web.context>/ecord/global</web.context>
+ <onos.app.name>org.opencord.ce.global.channel</onos.app.name>
+ <onos.version>1.10.3</onos.version>
+ <onos.app.url>http://opencord.org</onos.app.url>
+ <project.version>1.0.0</project.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opencord.ce</groupId>
+ <artifactId>orchestration</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${onos.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${onos.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>
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/HttpClientComponent.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/HttpClientComponent.java
new file mode 100644
index 0000000..d470f9f
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/HttpClientComponent.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel;
+
+
+import com.google.common.collect.Sets;
+
+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.IpAddress;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+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.domain.DomainId;
+import org.onosproject.net.domain.DomainService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.opencord.ce.api.services.channel.ConnectionService;
+import org.opencord.ce.api.services.channel.ControlChannelListenerService;
+import org.opencord.ce.api.services.channel.EndPoint;
+import org.opencord.ce.global.channel.client.ConnectionConfig;
+import org.opencord.ce.global.channel.client.HttpClientInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.Client;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+/**
+ * Southbound component that adds a listener to the
+ * {@link ControlChannelListenerService}.
+ *
+ * Accomplishes network tasks through HTTP requests,
+ * acting as a client that send {@link org.opencord.ce.api.models.CarrierEthernetForwardingConstruct}
+ * requests to the underlying domains
+ */
+@Component(immediate = true)
+@Service(ConnectionService.class)
+public class HttpClientComponent implements ConnectionService {
+ private static final String APP_NAME = "org.opencord.ce.global.channel.http";
+
+ // temporary
+ private static final String TOPIC_ONE = "ecord-domains-topic-one";
+ private static final String TOPIC_TWO = "ecord-domains-topic-two";
+ private static final String TOPIC_THREE = "ecord-domains-topic-three";
+
+ 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 StorageService storageService;
+
+ @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 ControlChannelListenerService channelListenerService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DomainService domainService;
+
+ private final Set<EndPoint> endPoints = Sets.newHashSet();
+
+ private ConsistentMap<EndPoint, IpAddress> endPointMasterIpMap;
+
+ private final ExecutorService eventExecutor =
+ Executors.newSingleThreadExecutor();
+
+ private final ConfigFactory<ApplicationId, ConnectionConfig> configFactory =
+ new ConfigFactory<ApplicationId, ConnectionConfig>(SubjectFactories.APP_SUBJECT_FACTORY,
+ ConnectionConfig.class, "endPoints") {
+ @Override
+ public ConnectionConfig createConfig() {
+ return new ConnectionConfig();
+ }
+ };
+
+ private final NetworkConfigListener configListener = new InternalConfigListener();
+
+ @Activate
+ protected void activate() {
+ log.info("Started");
+
+ appId = coreService.registerApplication(APP_NAME);
+ endPointMasterIpMap = storageService.<EndPoint, IpAddress>consistentMapBuilder()
+ .withName("ecord-domain-endpoints")
+ .withSerializer(Serializer.using(
+ new KryoNamespace.Builder()
+ .register(KryoNamespaces.API)
+ .register(DomainId.class)
+ .register(EndPoint.class)
+ .build()
+ )).build();
+ configRegistry.registerConfigFactory(configFactory);
+ configService.addListener(configListener);
+ channelListenerService.addListener(HttpClientInstance.INSTANCE);
+ leadershipService.runForLeadership(TOPIC_ONE);
+ leadershipService.runForLeadership(TOPIC_TWO);
+ leadershipService.runForLeadership(TOPIC_THREE);
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ log.info("Stopped");
+
+ configService.removeListener(configListener);
+ configRegistry.unregisterConfigFactory(configFactory);
+ channelListenerService.removeListener(HttpClientInstance.INSTANCE);
+ leadershipService.withdraw(TOPIC_ONE);
+ leadershipService.withdraw(TOPIC_TWO);
+ leadershipService.withdraw(TOPIC_THREE);
+ HttpClientInstance.INSTANCE.stopNetworkTasks();
+ }
+
+ @Override
+ public IpAddress getLocalMasterIp(String domainId) {
+ synchronized (this) {
+ for (EndPoint ep : endPoints) {
+ if (ep.domainId().id().equals(domainId)) {
+ String topic = ep.topic();
+ String masterIp;
+ String leaderId = leadershipService.getLeader(topic).id();
+ log.info("local leaderId: " + leaderId);
+ masterIp = clusterService.getNode(NodeId.nodeId(leaderId)).ip().toString();
+
+ return IpAddress.valueOf(masterIp);
+ }
+ }
+ }
+ log.info("Found no leader for domain " + domainId +
+ "-- endPoints size: " + endPoints.size());
+ return null;
+ }
+
+ @Override
+ public IpAddress getRemoteMasterIp(String domainId) {
+ synchronized (this) {
+ for (EndPoint ep : endPoints) {
+ if (ep.domainId().id().equals(domainId)) {
+ return HttpClientInstance.INSTANCE.getRemoteMasterIp(ep);
+ }
+ }
+ }
+ log.info("Found no master ip for domain {}", domainId);
+ return null;
+ }
+
+ @Override
+ public Pair<Client, IpAddress> getConnectionInfo(DomainId domainId) {
+ Client client = HttpClientInstance.INSTANCE
+ .getConnectionInfo(domainId);
+ return Pair.of(client, getRemoteMasterIp(domainId.id()));
+ }
+
+ private void readConfig() {
+ ConnectionConfig config = configRegistry.getConfig(appId, ConnectionConfig.class);
+ log.debug("Domains connections config received");
+
+ synchronized (this) {
+ endPoints.addAll(config.endPoints());
+ }
+
+ HttpClientInstance.INSTANCE.configure(clusterService, leadershipService, domainService,
+ endPointMasterIpMap, config);
+ }
+
+ 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/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/ConnectionConfig.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/ConnectionConfig.java
new file mode 100644
index 0000000..c9c91f7
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/ConnectionConfig.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.client;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.domain.DomainId;
+import org.opencord.ce.api.services.channel.EndPoint;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * Configuration class for this bundle.
+ *
+ * Look at /config-samples/ecord-global-config.json for a sample configuration
+ */
+public class ConnectionConfig extends Config<ApplicationId> {
+
+ private static final String PORT = "port";
+
+ private static final String TOPICS = "topics";
+
+ private static final String DOMAINS = "domains";
+ private static final String DOMAIN_ID = "domainId";
+ private static final String DOMAIN_IPS = "clusterIps";
+ private static final String USERNAME = "username";
+ private static final String PASSWD = "password";
+ private static final String TOPIC = "topic";
+
+
+
+ /**
+ * Gets listen port from configuration.
+ * @return port number
+ */
+ public int listenPort() {
+ return object.path(PORT).asInt();
+ }
+
+ /**
+ * List of topics to distribute network operations among ONOS instances.
+ * @return list of topics
+ */
+ public ArrayList<String> topics() {
+ ArrayList<String> topics = new ArrayList<>();
+ object.path(TOPICS).forEach(
+ topic -> topics.add(topic.asText())
+ );
+ return topics;
+ }
+
+ /**
+ * Returns set of domain end points.
+ * @return set of domain end points
+ */
+ public Set<EndPoint> endPoints() {
+ JsonNode peersNode = object.get(DOMAINS);
+ Set<EndPoint> endPoints = Sets.newHashSet();
+
+ peersNode.forEach(jsonNode -> {
+ DomainId domainId = DomainId.domainId(
+ jsonNode.path(DOMAIN_ID).asText());
+ Set<IpAddress> ipAddresses = Sets.newHashSet();
+ jsonNode.path(DOMAIN_IPS).forEach(ipAddress -> ipAddresses.add(
+ IpAddress.valueOf(ipAddress.asText())
+ ));
+ int port = jsonNode.path(PORT).asInt();
+
+ String username = jsonNode.path(USERNAME).asText();
+ String password = jsonNode.path(PASSWD).asText();
+
+ String topic = jsonNode.path(TOPIC).asText();
+
+ endPoints.add(new EndPoint(domainId, ipAddresses, port,
+ username, password, topic));
+ });
+
+ return endPoints;
+ }
+}
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/DomainMasterIpDiscoveryTask.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/DomainMasterIpDiscoveryTask.java
new file mode 100644
index 0000000..8638639
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/DomainMasterIpDiscoveryTask.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.client;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.jboss.netty.util.Timeout;
+import org.jboss.netty.util.TimerTask;
+import org.onlab.packet.IpAddress;
+import org.onlab.util.Timer;
+import org.opencord.ce.api.services.channel.EndPoint;
+import org.slf4j.Logger;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.opencord.ce.api.services.channel.Symbols.BASE_URL;
+import static org.opencord.ce.api.services.channel.Symbols.COLON;
+import static org.opencord.ce.api.services.channel.Symbols.DOUBLESLASH;
+import static org.opencord.ce.api.services.channel.Symbols.HTTP;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER_IP;
+import static org.opencord.ce.api.services.channel.Symbols.OK;
+import static org.opencord.ce.api.services.channel.Symbols.RESULT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Executed periodically to find the leader node of a domain.
+ * Stops when the ip is found
+ */
+public class DomainMasterIpDiscoveryTask implements TimerTask {
+
+ private final Logger log = getLogger(getClass());
+
+ private Timeout timeout;
+ private volatile boolean isStopped;
+ private EndPoint endPoint;
+ private Client client;
+
+ ObjectMapper mapper;
+
+ public DomainMasterIpDiscoveryTask(EndPoint endPoint, Client client,
+ ObjectMapper mapper) {
+ this.endPoint = endPoint;
+ this.client = client;
+ this.mapper = mapper;
+
+ isStopped = true;
+ start();
+
+ }
+
+ public synchronized void stop() {
+ if (!isStopped) {
+ isStopped = true;
+ timeout.cancel();
+ } else {
+ log.warn("IpDiscovery stopped multiple times?");
+ }
+ }
+
+ public synchronized void start() {
+ if (isStopped) {
+ isStopped = false;
+ timeout = Timer.getTimer().newTimeout(this, 0, SECONDS);
+ } else {
+ log.warn("IpDiscovery started multiple times?");
+ }
+ }
+
+ public synchronized boolean isStopped() {
+ return isStopped || timeout.isCancelled();
+ }
+
+ @Override
+ public void run(Timeout t) {
+ if (isStopped()) {
+ return;
+ }
+ for (IpAddress ipAddress : endPoint.ipAddresses()) {
+ String url = HTTP + COLON + DOUBLESLASH + ipAddress.toString() + COLON +
+ endPoint.port() + BASE_URL + MASTER;
+ log.info("masterIp url: " + url);
+ WebTarget wt = client.target(url);
+ Response response = wt.request(MediaType.APPLICATION_JSON)
+ .get();
+ if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+ continue;
+ }
+ String stringBody = response.readEntity(String.class);
+ log.info("getLocalMasterIp() response: " + stringBody);
+ try {
+ ObjectNode responseBody = (ObjectNode) mapper.readTree(stringBody);
+ if (responseBody.path(RESULT).asText().equals(OK)) {
+ IpAddress masterIpAdress = IpAddress.valueOf(responseBody.path(MASTER_IP).asText());
+ HttpClientInstance.INSTANCE.setMasterIp(endPoint, masterIpAdress);
+ this.stop();
+ return;
+ }
+ } catch (IOException ex) {
+ log.info("getLocalMasterIp() IOException, try next endpoint ip");
+ }
+ }
+
+ if (!isStopped()) {
+ timeout = Timer.getTimer().newTimeout(this, 3, SECONDS);
+ }
+ }
+}
+
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java
new file mode 100644
index 0000000..cf16ab5
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java
@@ -0,0 +1,427 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.client;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+import org.apache.commons.lang3.tuple.Pair;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.net.domain.DomainId;
+import org.onosproject.net.domain.DomainService;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.store.service.ConsistentMap;
+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.api.services.channel.EndPoint;
+import org.opencord.ce.api.services.channel.RequestCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.Map;
+import java.util.Set;
+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.DST_NI_LIST;
+import static org.opencord.ce.api.services.channel.Symbols.FC;
+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;
+import static org.opencord.ce.api.services.channel.Symbols.SRC_NI;
+import static org.opencord.ce.api.services.channel.Symbols.UNI;
+import static org.onosproject.net.domain.DomainId.LOCAL;
+
+/**
+ * Implementation of the listener methods for requesting {@link
+ * org.opencord.ce.api.models.CarrierEthernetForwardingConstruct} configuration.
+ */
+public enum HttpClientInstance
+ implements MetroNetworkVirtualNodeService {
+ INSTANCE;
+ private final Logger log =
+ LoggerFactory.getLogger(HttpClientInstance.class);
+
+ private static final int STATUS_OK = Response.Status.OK.getStatusCode();
+ private static final int STATUS_REQ_UNPROCESSABLE = Response.Status.NOT_ACCEPTABLE.getStatusCode();
+
+ private final Map<DomainId, Pair<Client, EndPoint>> domainsEndPointsMap = Maps.newConcurrentMap();
+
+ private ConsistentMap<EndPoint, IpAddress> endPointMasterIpMap;
+
+ protected final Map<EndPoint, DomainMasterIpDiscoveryTask> ipDiscoveryTaskMap = Maps.newConcurrentMap();
+
+ private final AbstractWebResource codecContext = new AbstractWebResource();
+
+ private boolean configured = false;
+
+ private ClusterService clusterService;
+ private LeadershipService leadershipService;
+ private DomainService domainService;
+
+ private final ExecutorService networkExecutor =
+ newSingleThreadExecutor();
+ // newFixedThreadPool(5, groupedThreads("opencord/ecord-http", "event-handler"));
+
+ public void configure(ClusterService clusterService, LeadershipService leadershipService,
+ DomainService domainService, ConsistentMap<EndPoint,
+ IpAddress> endPointMasterIpMap, ConnectionConfig connConfig) {
+
+ if (!configured) {
+ this.clusterService = clusterService;
+ this.leadershipService = leadershipService;
+ this.domainService = domainService;
+ this.endPointMasterIpMap = endPointMasterIpMap;
+ configured = true;
+ }
+ connConfig.endPoints().forEach(siteConfig -> {
+ DomainId domainId = siteConfig.domainId();
+ synchronized (this) {
+ domainsEndPointsMap.putIfAbsent(domainId,
+ Pair.of(createClient(), siteConfig));
+ notify();
+ }
+ String topic = siteConfig.topic();
+ // TODO: add leadership listeners to react to changes
+ if (isLeader(topic)) {
+ log.info("I am the leader for domain: {} ", domainId);
+ probeMasterIp(siteConfig, domainsEndPointsMap.get(domainId).getLeft());
+ } else {
+ log.info("I am NOT the leader for domain: {}", domainId);
+
+ }
+ });
+ }
+
+ private void probeMasterIp(EndPoint endPoint, Client client) {
+ ipDiscoveryTaskMap.putIfAbsent(endPoint,
+ new DomainMasterIpDiscoveryTask(endPoint, client, codecContext.mapper()));
+ }
+
+ protected void setMasterIp(EndPoint endPoint, IpAddress ipAddress) {
+ synchronized (this) {
+ endPointMasterIpMap.put(endPoint, ipAddress);
+ notify();
+ }
+ }
+
+ public IpAddress getRemoteMasterIp(EndPoint endPoint) {
+ synchronized (this) {
+ return endPointMasterIpMap.get(endPoint).value();
+ }
+ }
+
+ public Client getConnectionInfo(DomainId domainId) {
+ return domainsEndPointsMap.get(domainId).getLeft();
+ }
+
+ 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;
+ }
+ }
+
+ private boolean isLeader(String topic) {
+ return leadershipService.getLeader(topic).id()
+ .equals(clusterService.getLocalNode().id().id());
+ }
+
+ private String getTopic(DomainId domainId) {
+ return domainsEndPointsMap.get(domainId).getRight().topic();
+ }
+
+ private Client createClient() {
+ return ClientBuilder.newClient();
+ }
+
+ public void stopNetworkTasks() {
+ ipDiscoveryTaskMap.forEach((ep, task) -> task.stop());
+ }
+
+ @Override
+ public void setNodeForwarding(CarrierEthernetForwardingConstruct fc, CarrierEthernetNetworkInterface srcNi,
+ Set<CarrierEthernetNetworkInterface> dstNiSet) {
+
+ DomainId domainId = domainService.getDomain(srcNi.cp().deviceId());
+ if (domainId == LOCAL || !isLeader(getTopic(domainId))) {
+ return;
+ }
+ JsonCodec<CarrierEthernetForwardingConstruct> fcCodec =
+ codecContext.codec(CarrierEthernetForwardingConstruct.class);
+ JsonCodec<CarrierEthernetNetworkInterface> niCodec =
+ codecContext.codec(CarrierEthernetNetworkInterface.class);
+ ObjectNode body = codecContext.mapper().createObjectNode();
+
+ body.set(FC, fcCodec.encode(fc, codecContext));
+ body.set(SRC_NI, niCodec.encode(srcNi, codecContext));
+ ArrayNode dstNiJsonArrayNode = codecContext.mapper().createArrayNode();
+ dstNiSet.forEach(dstNi ->
+ dstNiJsonArrayNode.add(niCodec.encode(dstNi, codecContext)));
+ body.set(DST_NI_LIST, dstNiJsonArrayNode);
+/*
+ String fcId = fc.id().id();
+ VlanId fcTag = fc.vlanId();
+ ConnectPoint ingressCp = srcNi.cp();
+ CarrierEthernetNetworkInterface.Type srcType = srcNi.type();
+ VlanId sTag = srcNi.sVlanId();
+ VlanId ceTag = srcNi.ceVlanId();
+ CarrierEthernetForwardingConstruct.Type fcType = fc.type();
+ ArrayList<Pair<ConnectPoint, CarrierEthernetNetworkInterface.Type>> egressList =
+ new ArrayList<>();
+ dstNiSet.forEach(dstNi -> egressList.add(Pair.of(dstNi.cp(), dstNi.type())));
+
+ ObjectNode jsonBody = codecContext.mapper().createObjectNode()
+ .put(FC_ID, fcId)
+ .put(FC_TAG, fcTag.toShort())
+ .put(FC_TYPE, fcType.toString())
+ .put(INGRESS_NI_TYPE, srcType.toString());
+ JsonCodec<ConnectPoint> cpCodec = codecContext.codec(ConnectPoint.class);
+ jsonBody.set(FC_INGRESS_CP, cpCodec.encode(ingressCp, codecContext));
+ jsonBody.put(INGRESS_FC_TAG, sTag.toShort())
+ .put(CUSTOMER_TAG, ceTag.toShort());
+ ArrayNode egressListNode = codecContext.newArray(jsonBody, FC_EGRESS_LST);
+ dstNiSet.forEach(dstNi -> {
+ ObjectNode item = codecContext.mapper().createObjectNode()
+ .put(FC_EGRESS_TYPE, dstNi.type().toString());
+ item.set(FC_EGRESS_CP, cpCodec.encode(dstNi.cp(), codecContext));
+ egressListNode.add(item);
+ });
+ */
+ String resource = "/ForwardingConstruct";
+ networkExecutor.execute(new NetworkTask(domainId, POST, resource, body.toString(),
+ new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ log.info("FC request submit to domain: {}", domainId);
+
+ }
+
+ @Override
+ public void onError(Response response) {
+ log.error("FC call failure reason: {}", response.getStatusInfo());
+
+ }
+ }));
+ }
+
+ @Override
+ public void createBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ DomainId domainId = domainService.getDomain(uni.cp().deviceId());
+ if (domainId == LOCAL || !isLeader(getTopic(domainId))) {
+ return;
+ }
+ String resource = "/createBwp";
+ networkExecutor.execute(new NetworkTask(domainId, POST, resource,
+ fcUniToRestBody(fc, uni).toString(),
+ new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ log.info("BW profile creation request submitted to domain: {}", domainId);
+ }
+
+ @Override
+ public void onError(Response response) {
+ log.error("BwProfile creation call fail: {}", response.getStatusInfo());
+
+ }
+ }));
+ }
+
+ @Override
+ public void applyBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ DomainId domainId = domainService.getDomain(uni.cp().deviceId());
+ if (domainId == LOCAL || !isLeader(getTopic(domainId))) {
+ return;
+ }
+ String resource = "/applyBwp";
+ networkExecutor.execute(new NetworkTask(domainId, POST, resource, fcUniToRestBody(fc, uni).toString(),
+ new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ log.info("BW profile activation request submitted to domain: {}", domainId);
+ }
+
+ @Override
+ public void onError(Response response) {
+ log.error("FAIL BW profile activation: {}", response.getStatusInfo());
+
+ }
+ }));
+ }
+
+ @Override
+ public void removeBandwidthProfileResources(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ DomainId domainId = domainService.getDomain(uni.cp().deviceId());
+ if (domainId == LOCAL || !isLeader(getTopic(domainId))) {
+ return;
+ }
+ String resource = "/deleteBwp";
+ networkExecutor.execute(new NetworkTask(domainId, POST, resource,
+ fcUniToRestBody(fc, uni).toString(),
+ new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ log.info("BW profile creation request submitted to domain: {}", domainId);
+ }
+
+ @Override
+ public void onError(Response response) {
+ log.info("FAIL BW profile creation: {}", response.getStatusInfo());
+
+ }
+ }));
+ }
+
+ @Override
+ public void removeAllForwardingResources(EvcConnId fcId) {
+ Set<DomainId> domainIds = domainService.getDomainIds();
+ String resource = "/deleteFcResources/" + fcId.id();
+ domainIds.forEach(domainId -> {
+ if (isLeader(getTopic(domainId))) {
+ networkExecutor.execute(new NetworkTask(domainId, DELETE, resource,
+ null, new RequestCallback() {
+ @Override
+ public void onSuccess(Response response) {
+
+ }
+
+ @Override
+ public void onError(Response response) {
+
+ }
+ }));
+ }
+ });
+
+ }
+
+ private ObjectNode fcUniToRestBody(CarrierEthernetForwardingConstruct fc, CarrierEthernetUni uni) {
+ JsonCodec<CarrierEthernetForwardingConstruct> fcCodec =
+ codecContext.codec(CarrierEthernetForwardingConstruct.class);
+ JsonCodec<CarrierEthernetNetworkInterface> niCodec =
+ codecContext.codec(CarrierEthernetNetworkInterface.class);
+ ObjectNode body = codecContext.mapper().createObjectNode();
+ body.set(FC, fcCodec.encode(fc, codecContext));
+ body.set(UNI, niCodec.encode(uni, codecContext));
+ return body;
+ }
+
+ private class NetworkTask implements Runnable {
+ private String method;
+ private String resource;
+ private String body;
+ private DomainId domainId;
+ private RequestCallback callback;
+
+ NetworkTask(DomainId domainId, String method, String resource, String body,
+ RequestCallback callback) {
+ this.domainId = domainId;
+ this.method = method;
+ this.resource = resource;
+ this.body = body;
+ this.callback = callback;
+ }
+ @Override
+ public void run() {
+
+ synchronized (this) {
+ while (domainsEndPointsMap.get(domainId) == null) {
+ log.info("End point object missing for domain {}." +
+ "\nPossibly the Bundle configuration is missing ", domainId);
+ try {
+ wait();
+ } catch (InterruptedException ie) {
+ log.info("Interrupted exception: " + ie.getMessage());
+ }
+
+ }
+ }
+ EndPoint endPoint = domainsEndPointsMap.get(domainId).getRight();
+ IpAddress ipAddress;
+ synchronized (this) {
+ while (!endPointMasterIpMap.containsKey(endPoint) ||
+ endPointMasterIpMap.get(endPoint).value() == null) {
+ try {
+ log.info("wait() master ip");
+ wait();
+ } catch (InterruptedException ie) {
+ log.info("Interrupted exception: " + ie.getMessage());
+ }
+ }
+ ipAddress = endPointMasterIpMap.get(endPoint).value();
+ }
+
+
+ Client client = domainsEndPointsMap.get(domainId).getLeft();
+
+ String url = HTTP + COLON + DOUBLESLASH + ipAddress.toString() + COLON +
+ endPoint.port() + BASE_URL + "/carrierethernet" + resource;
+ log.info("DEBUG {}: Sending data via http: {}", 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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/package-info.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/package-info.java
new file mode 100644
index 0000000..cf86254
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of the client-side communication channel APIs.
+ */
+package org.opencord.ce.global.channel.client;
\ No newline at end of file
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/package-info.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/package-info.java
new file mode 100644
index 0000000..0645657
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of the communication channel APIs.
+ */
+package org.opencord.ce.global.channel;
\ No newline at end of file
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DeviceResource.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DeviceResource.java
new file mode 100644
index 0000000..377abf0
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DeviceResource.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.server;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.opencord.ce.api.services.virtualprovider.DefaultDomainVirtualDevice;
+import org.opencord.ce.api.services.virtualprovider.DomainVirtualDevice;
+import org.opencord.ce.api.services.virtualprovider.EcordDeviceProviderService;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.domain.DomainId;
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+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.ArrayList;
+import java.util.List;
+
+/**
+ * Remote device REST control.
+ */
+@Path("/topology/{domainId}")
+public class DeviceResource extends AbstractWebResource {
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private EcordDeviceProviderService ecordDeviceProviderService =
+ get(EcordDeviceProviderService.class);
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{deviceId}")
+ public Response postDevice(@PathParam("domainId") String domainId, @PathParam("deviceId") String deviceId,
+ InputStream stream) {
+ log.info("Notified device from domainId {}", domainId);
+ try {
+ JsonNode responseBody = mapper().readTree(stream);
+ // the json body superfluous now. Can be used to add annotations to the device later
+ log.debug(responseBody.toString());
+ DomainVirtualDevice domainDevice = new DefaultDomainVirtualDevice(DeviceId.deviceId(deviceId),
+ DomainId.domainId(domainId));
+ ecordDeviceProviderService.connectRemoteDevice(domainDevice);
+ return Response.status(200).build();
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+ }
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("{deviceId}/ports")
+ public Response postBigSwitchPorts(@PathParam("domainId") String domainId, @PathParam("deviceId") String deviceId,
+ InputStream stream) {
+ log.info("Notified device port from domainId {}", domainId);
+ try {
+ JsonNode responseBody = mapper().readTree(stream);
+ log.debug(responseBody.toString());
+ JsonCodec<Port> portCodec = codec(Port.class);
+ List<PortDescription> ports = new ArrayList<>();
+ responseBody.forEach(item -> {
+ Port port = portCodec.decode((ObjectNode) item, this);
+ DefaultAnnotations.Builder annot = DefaultAnnotations.builder();
+ port.annotations().keys()
+ .forEach(k -> annot.set(k, port.annotations().value(k)));
+ ports.add(new DefaultPortDescription(port.number(), port.isEnabled(), port.type(),
+ port.portSpeed(), annot.build()));
+ });
+
+ ecordDeviceProviderService.addOrUpdateRemotePorts(DomainId.domainId(domainId),
+ DeviceId.deviceId(deviceId), ports);
+ return Response.status(200).build();
+
+ } catch (IOException io) {
+ log.info("Json parse error");
+ return Response.status(Response.Status.NOT_ACCEPTABLE).build();
+ }
+
+ }
+}
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DomainMasterIpResource.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DomainMasterIpResource.java
new file mode 100644
index 0000000..6ba8469
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/DomainMasterIpResource.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.server;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.packet.IpAddress;
+import org.onosproject.rest.AbstractWebResource;
+import org.opencord.ce.api.services.channel.ConnectionService;
+import org.slf4j.Logger;
+
+import javax.ws.rs.GET;
+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 static org.opencord.ce.api.services.channel.Symbols.MASTER_API_NO_IP_BODY;
+import static org.opencord.ce.api.services.channel.Symbols.MASTER_IP;
+import static org.opencord.ce.api.services.channel.Symbols.OK;
+import static org.opencord.ce.api.services.channel.Symbols.RESULT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Gets the ip of the instance leader of the communication with the specified
+ * domainId.
+ */
+@Path("master/{domainId}")
+public class DomainMasterIpResource extends AbstractWebResource {
+ private final Logger log = getLogger(getClass());
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getMasterIp(@PathParam("domainId") String id) {
+ log.info("Domain {} asks who is the master for him", id);
+
+ IpAddress ip = get(ConnectionService.class).getLocalMasterIp(id);
+ if (ip != null) {
+ ObjectNode body = mapper().createObjectNode();
+ body.put(RESULT, OK);
+ body.put(MASTER_IP, ip.toString());
+
+ return ok(body.toString()).build();
+ } else {
+ return ok(MASTER_API_NO_IP_BODY).build();
+ }
+ }
+}
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/EcordGlobalRestApp.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/EcordGlobalRestApp.java
new file mode 100644
index 0000000..bd0691f
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/EcordGlobalRestApp.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.ce.global.channel.server;
+
+import org.onlab.rest.AbstractWebApplication;
+
+import java.util.Set;
+
+/**
+ * Loader class for web resource APIs.
+ */
+public class EcordGlobalRestApp extends AbstractWebApplication {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return getClasses(DeviceResource.class, DomainMasterIpResource.class);
+ }
+}
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/package-info.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/package-info.java
new file mode 100644
index 0000000..f75a73a
--- /dev/null
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/server/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of the server-side communication channel APIs.
+ */
+package org.opencord.ce.global.channel.server;
\ No newline at end of file
diff --git a/global/http-channel/src/main/webapp/WEB-INF/web.xml b/global/http-channel/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..7155765
--- /dev/null
+++ b/global/http-channel/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="ONOS" version="2.5">
+ <display-name>ECORD 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.global.channel.server.EcordGlobalRestApp</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>