CORD-60:Splitting OLT application bundle into api and app bundles so that other applications can import the necessary packages from api bundle
Change-Id: Ib2bacc28e50f2b65dadd3dd20c642afccba88ac7
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..6e89855
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,73 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016 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>
+ <artifactId>onos-olt</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-olt-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <url>http://onosproject.org</url>
+
+ <description>CORD OLT application API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.onosproject.olt</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/api/src/main/java/org/onosproject/olt/AccessDeviceEvent.java b/api/src/main/java/org/onosproject/olt/AccessDeviceEvent.java
new file mode 100644
index 0000000..7eda5a9
--- /dev/null
+++ b/api/src/main/java/org/onosproject/olt/AccessDeviceEvent.java
@@ -0,0 +1,88 @@
+package org.onosproject.olt;
+
+import org.onlab.packet.VlanId;
+import org.onosproject.event.AbstractEvent;
+import org.onosproject.net.DeviceId;
+
+import java.util.Optional;
+
+/**
+ * Describes an access device event.
+ */
+public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> {
+
+ private final Optional<VlanId> sVlan;
+ private final Optional<VlanId> cVlan;
+
+ public enum Type {
+ /**
+ * A subscriber was registered and provisioned.
+ */
+ SUBSCRIBER_REGISTERED,
+
+ /**
+ * A subscriber was unregistered and deprovisioned.
+ */
+ SUBSCRIBER_UNREGISTERED,
+
+ /**
+ * An access device connected.
+ */
+ DEVICE_CONNECTED,
+
+ /**
+ * An access device disconnected.
+ */
+ DEVICE_DISCONNECTED
+
+ }
+
+ /**
+ *
+ * Creates an event of a given type and for the specified device,
+ * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
+ * if the event is related to the access device (dis)connection.
+ *
+ * @param type the event type
+ * @param deviceId the device id
+ * @param sVlanId the service vlan
+ * @param cVlanId the customer vlan
+ */
+ public AccessDeviceEvent(Type type, DeviceId deviceId,
+ VlanId sVlanId,
+ VlanId cVlanId) {
+ super(type, deviceId);
+ this.sVlan = Optional.ofNullable(sVlanId);
+ this.cVlan = Optional.ofNullable(cVlanId);
+ }
+
+ /**
+ *
+ * Creates an event of a given type and for the specified device, and timestamp
+ * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
+ * if the event is related to the access device (dis)connection.
+ *
+ * @param type the event type
+ * @param deviceId the device id
+ * @param time a timestamp
+ * @param sVlanId the service vlan
+ * @param cVlanId the customer vlan
+ */
+ protected AccessDeviceEvent(Type type, DeviceId deviceId, long time,
+ VlanId sVlanId,
+ VlanId cVlanId) {
+ super(type, deviceId, time);
+ this.sVlan = Optional.ofNullable(sVlanId);
+ this.cVlan = Optional.ofNullable(cVlanId);
+
+ }
+
+ public Optional<VlanId> sVlanId() {
+ return sVlan;
+ }
+
+ public Optional<VlanId> cVlanId() {
+ return cVlan;
+ }
+
+}
diff --git a/api/src/main/java/org/onosproject/olt/AccessDeviceListener.java b/api/src/main/java/org/onosproject/olt/AccessDeviceListener.java
new file mode 100644
index 0000000..9dc4151
--- /dev/null
+++ b/api/src/main/java/org/onosproject/olt/AccessDeviceListener.java
@@ -0,0 +1,9 @@
+package org.onosproject.olt;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving access device related events.
+ */
+public interface AccessDeviceListener extends EventListener<AccessDeviceEvent> {
+}
diff --git a/api/src/main/java/org/onosproject/olt/AccessDeviceService.java b/api/src/main/java/org/onosproject/olt/AccessDeviceService.java
new file mode 100644
index 0000000..831784c
--- /dev/null
+++ b/api/src/main/java/org/onosproject/olt/AccessDeviceService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.olt;
+
+import org.onlab.packet.VlanId;
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.ConnectPoint;
+
+/**
+ * Service for interacting with an access device (OLT).
+ */
+public interface AccessDeviceService
+ extends ListenerService<AccessDeviceEvent, AccessDeviceListener> {
+
+ /**
+ * Provisions connectivity for a subscriber on an access device.
+ *
+ * @param port subscriber's connection point
+ * @param vlan VLAN ID to provision for subscriber
+ */
+ void provisionSubscriber(ConnectPoint port, VlanId vlan);
+
+ /**
+ * Removes provisioned connectivity for a subscriber from an access device.
+ *
+ * @param port subscriber's connection point
+ */
+ void removeSubscriber(ConnectPoint port);
+
+}
diff --git a/api/src/main/java/org/onosproject/olt/package-info.java b/api/src/main/java/org/onosproject/olt/package-info.java
new file mode 100644
index 0000000..edfcc0a
--- /dev/null
+++ b/api/src/main/java/org/onosproject/olt/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * OLT application api.
+ */
+package org.onosproject.olt;