[ONOS-7731] Add a set of interfaces for openstack vTap app
Change-Id: Ic44030a996bb6c3d5883acfdb3ac310a290682f6
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtap.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtap.java
new file mode 100644
index 0000000..6f74e81
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtap.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onosproject.net.Annotated;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.SparseAnnotations;
+
+import java.util.Set;
+
+/**
+ * Abstraction of an OpenstackVtap.
+ */
+public interface OpenstackVtap extends Annotated {
+
+ /**
+ * Openstack vTap type.
+ */
+ enum Type {
+
+ /**
+ * Indicates mirroring both TX and RX traffic.
+ */
+ VTAP_ALL(0x3),
+
+ /**
+ * Indicates only mirroring RX traffic.
+ */
+ VTAP_RX(0x2),
+
+ /**
+ * Indicates only mirroring TX traffic.
+ */
+ VTAP_TX(0x1),
+
+ /**
+ * Indicates do not mirroring any traffic.
+ */
+ VTAP_NONE(0);
+
+ private final int type;
+
+ Type(int type) {
+ this.type = type;
+ }
+
+ public boolean isValid(Type comp) {
+ return (this.type & comp.type) == comp.type;
+ }
+ }
+
+ /**
+ * OpenstackVtap identifier.
+ *
+ * @return OpenstackVtap id
+ */
+ OpenstackVtapId id();
+
+ /**
+ * Returns OpenstackVtap type.
+ *
+ * @return type
+ */
+ Type type();
+
+ /**
+ * Returns the vTap criterion.
+ *
+ * @return vTap criterion
+ */
+ OpenstackVtapCriterion vTapCriterion();
+
+ /**
+ * Returns a collection of TX device identifiers.
+ *
+ * @return device identifiers
+ */
+ Set<DeviceId> txDeviceIds();
+
+ /**
+ * Returns a collection of RX device identifiers.
+ *
+ * @return device identifiers
+ */
+ Set<DeviceId> rxDeviceIds();
+
+ /**
+ * Builder of new openstack vTap instance.
+ */
+ interface Builder {
+
+ /**
+ * Returns openstack vTap builder with supplied vTap identifier.
+ *
+ * @param id vTap identifier
+ * @return openstack vTap builder
+ */
+ Builder id(OpenstackVtapId id);
+
+ /**
+ * Returns openstack vTap builder with supplied vTap type.
+ *
+ * @param type vTap type
+ * @return openstack vTap builder
+ */
+ Builder type(OpenstackVtap.Type type);
+
+ /**
+ * Returns openstack vTap builder with supplied vTap criterion.
+ *
+ * @param vTapCriterion vTap criterion
+ * @return openstack vTap builder
+ */
+ Builder vTapCriterion(OpenstackVtapCriterion vTapCriterion);
+
+ /**
+ * Returns openstack vTap builder with supplied TX device identifiers.
+ *
+ * @param txDeviceIds TX device identifiers
+ * @return openstack vTap builder
+ */
+ Builder txDeviceIds(Set<DeviceId> txDeviceIds);
+
+ /**
+ * Returns openstack vTap builder with supplied RX device identifiers.
+ *
+ * @param rxDeviceIds RX device identifiers
+ * @return openstack vTap builder
+ */
+ Builder rxDeviceIds(Set<DeviceId> rxDeviceIds);
+
+ /**
+ * Returns openstack vTap builder with supplied annotations.
+ *
+ * @param annotations a set of annotations
+ * @return openstack vTap builder
+ */
+ Builder annotations(SparseAnnotations... annotations);
+
+ /**
+ * Builds an immutable openstack vTap instance.
+ *
+ * @return openstack vTap instance
+ */
+ OpenstackVtap build();
+ }
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapAdminService.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapAdminService.java
new file mode 100644
index 0000000..da9fd24
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapAdminService.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onlab.packet.VlanId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Service for administering the inventory of vTap.
+ */
+public interface OpenstackVtapAdminService extends OpenstackVtapService {
+
+ /**
+ * Creates a new vTap based on the specified description.
+ *
+ * @param type vTap type
+ * @param vTapCriterion criterion of a vTap
+ * @return created vTap object or null if error occurred
+ */
+ OpenstackVtap createVtap(OpenstackVtap.Type type, OpenstackVtapCriterion vTapCriterion);
+
+ /**
+ * Updates the existing vTap based on the given vTap instance.
+ *
+ * @param vTapId vTap identifier
+ * @param vTap vTap instance to be modified
+ * @return updated vTap object or null if error occurred
+ */
+ OpenstackVtap updateVtap(OpenstackVtapId vTapId, OpenstackVtap vTap);
+
+ /**
+ * Removes the specified vTap with given vTap identifier.
+ *
+ * @param vTapId vTap identifier
+ * @return removed vTap object or null if error occurred
+ */
+ OpenstackVtap removeVtap(OpenstackVtapId vTapId);
+
+ /**
+ * Sets output port and VLAN tag for vTap.
+ *
+ * @param deviceId device identifier
+ * @param type vTap type
+ * @param portNumber port number
+ * @param vlanId VLAN tag
+ */
+ void setVtapOutput(DeviceId deviceId, OpenstackVtap.Type type,
+ PortNumber portNumber, VlanId vlanId);
+
+ /**
+ * Sets output port and VNI for vTap.
+ *
+ * @param deviceId device identifier
+ * @param type vTap type
+ * @param portNumber port number
+ * @param vni virtual network index (VNI) of VxLAN
+ */
+ void setVtapOutput(DeviceId deviceId, OpenstackVtap.Type type,
+ PortNumber portNumber, int vni);
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapCriterion.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapCriterion.java
new file mode 100644
index 0000000..eb21b0c
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapCriterion.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.TpPort;
+
+/**
+ * A vTAP criterion used for mirroring traffic.
+ */
+public interface OpenstackVtapCriterion {
+
+ /**
+ * Returns IP Prefix of Source VM.
+ *
+ * @return source IP prefix
+ */
+ IpPrefix srcIpPrefix();
+
+ /**
+ * Returns IP Prefix of Destination VM.
+ *
+ * @return destination IP prefix
+ */
+ IpPrefix dstIpPrefix();
+
+ /**
+ * Returns IP protocol.
+ *
+ * @return IP protocol
+ */
+ byte ipProtocol();
+
+ /**
+ * Returns source transport port.
+ *
+ * @return source transport port number
+ */
+
+ TpPort srcTpPort();
+
+ /**
+ * Returns destination transport port.
+ *
+ * @return destination transport port number
+ */
+ TpPort dstTpPort();
+
+ /**
+ * Builder of new openstack vTap criteria.
+ */
+ interface Builder {
+
+ /**
+ * Builds an immutable openstack vTap criterion instance.
+ *
+ * @return openstack vTap criterion
+ */
+ OpenstackVtapCriterion build();
+
+ /**
+ * Returns openstack vTap criterion builder with supplied srcIpPrefix.
+ *
+ * @param srcIpPrefix Source IP address
+ * @return openstack vTap criterion builder
+ */
+ Builder srcIpPrefix(IpPrefix srcIpPrefix);
+
+ /**
+ * Returns openstack vTap criterion builder with supplied srcIpPrefix.
+ *
+ * @param dstIpPrefix Destination IP Prefix
+ * @return openstack vTap criterion builder
+ */
+ Builder dstIpPrefix(IpPrefix dstIpPrefix);
+
+ /**
+ * Returns openstack vTap criterion builder with supplied ipProtocol.
+ *
+ * @param ipProtocol IP protocol number
+ * @return openstack vTap criterion builder
+ */
+ Builder ipProtocol(byte ipProtocol);
+
+ /**
+ * Returns openstack vTap criterion builder with supplied srcTpPort.
+ *
+ * @param srcTpPort Source transport port number
+ * @return openstack vTap criterion builder
+ */
+ Builder srcTpPort(TpPort srcTpPort);
+
+ /**
+ * Returns openstack vTap criterion builder with supplied dstTpPort.
+ *
+ * @param dstTpPort Destination transport port number
+ * @return openstack vTap criterion builder
+ */
+ Builder dstTpPort(TpPort dstTpPort);
+ }
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapEvent.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapEvent.java
new file mode 100644
index 0000000..70c1e11
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapEvent.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onlab.util.Tools;
+import org.onosproject.event.AbstractEvent;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Describes vTap event.
+ */
+public class OpenstackVtapEvent extends AbstractEvent<OpenstackVtapEvent.Type, OpenstackVtap> {
+
+ /**
+ * Type of vTap events.
+ */
+ public enum Type {
+
+ /**
+ * Signifies that a new vTap has been added.
+ */
+ VTAP_ADDED,
+
+ /**
+ * Signifies that a vTap has been removed.
+ */
+ VTAP_REMOVED,
+
+ /**
+ * Signifies that a vTap data changed.
+ */
+ VTAP_UPDATED,
+ }
+
+ private OpenstackVtap prevSubject;
+
+ /**
+ * Creates an event of a given type and for the specified vTap and the
+ * current time.
+ *
+ * @param type vTap event type
+ * @param vTap event vTap subject
+ */
+ public OpenstackVtapEvent(Type type, OpenstackVtap vTap) {
+ super(type, vTap);
+ }
+
+ /**
+ * Creates an event of a given type and for the specified vTap and time.
+ *
+ * @param type vTap event type
+ * @param vTap event vTap subject
+ * @param time occurrence time
+ */
+ public OpenstackVtapEvent(Type type, OpenstackVtap vTap, long time) {
+ super(type, vTap, time);
+ }
+
+ /**
+ * Creates an event with previous subject.
+ *
+ * The previous subject is ignored if the type is not moved or updated
+ *
+ * @param type vTap event type
+ * @param vTap event vTap subject
+ * @param prevSubject previous vTap subject
+ */
+ public OpenstackVtapEvent(Type type, OpenstackVtap vTap, OpenstackVtap prevSubject) {
+ super(type, vTap);
+ if (type == Type.VTAP_UPDATED) {
+ this.prevSubject = prevSubject;
+ }
+ }
+
+ /**
+ * Gets the previous subject in this vTap event.
+ *
+ * @return the previous subject, or null if previous subject is not
+ * specified.
+ */
+ public OpenstackVtap prevSubject() {
+ return this.prevSubject;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("time", Tools.defaultOffsetDataTime(time()))
+ .add("type", type())
+ .add("subject", subject())
+ .add("prevSubject", prevSubject())
+ .toString();
+ }
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapId.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapId.java
new file mode 100644
index 0000000..ce8945d
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapId.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * Immutable representation of an openstack vTap identifier.
+ */
+public final class OpenstackVtapId {
+
+ /**
+ * Represents either no vTap, or an unspecified vTap.
+ */
+ public static final OpenstackVtapId NONE = new OpenstackVtapId(null);
+
+ private final UUID uuid;
+
+ // Public construction is prohibited
+ private OpenstackVtapId(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ // Default constructor for serialization
+ private OpenstackVtapId() {
+ this.uuid = null;
+ }
+
+ /**
+ * Returns an unique UUID.
+ *
+ * @return UUID
+ */
+ public UUID uuid() {
+ return uuid;
+ }
+
+ /**
+ * Creates a vTap identifier using the supplied UUID.
+ *
+ * @param uuid vTap UUID
+ * @return vTap identifier
+ */
+ public static OpenstackVtapId vTapId(UUID uuid) {
+ return new OpenstackVtapId(uuid);
+ }
+
+ /**
+ * Creates a vTap identifier using the supplied string format of UUID.
+ *
+ * @param uuidString vTap UUID
+ * @return vTap identifier
+ */
+ public static OpenstackVtapId vTapId(String uuidString) {
+ try {
+ return vTapId(UUID.fromString(uuidString));
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Invalid UUID string: " + uuidString);
+ }
+ }
+
+ /**
+ * Creates a OpenstackVtap id using random uuid.
+ *
+ * @return OpenstackVtap identifier
+ */
+ public static OpenstackVtapId vTapId() {
+ return new OpenstackVtapId(UUID.randomUUID());
+ }
+
+ @Override
+ public String toString() {
+ return uuid.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(uuid);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpenstackVtapId) {
+ final OpenstackVtapId other = (OpenstackVtapId) obj;
+ return Objects.equals(this.uuid, other.uuid);
+ }
+ return false;
+ }
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapListener.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapListener.java
new file mode 100644
index 0000000..ebea5ed
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving user related events.
+ */
+public interface OpenstackVtapListener extends EventListener<OpenstackVtapEvent> {
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapService.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapService.java
index f9d8fee..5041aaf 100644
--- a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapService.java
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapService.java
@@ -15,13 +15,47 @@
*/
package org.onosproject.openstackvtap.api;
+import org.onosproject.event.ListenerService;
+import org.onosproject.net.DeviceId;
+
+import java.util.Set;
+
/**
- * Openstack vtap interface.
+ * Service for interacting with the inventory of vTap.
*/
-public interface OpenstackVtapService {
+public interface OpenstackVtapService
+ extends ListenerService<OpenstackVtapEvent, OpenstackVtapListener> {
/**
- * A dummy method.
+ * Returns the number of vTaps in the store.
+ *
+ * @param type vTap type
+ * @return vTap count
*/
- void dummy();
+ int getVtapCount(OpenstackVtap.Type type);
+
+ /**
+ * Returns a collection of selected vTaps in the store.
+ *
+ * @param type vTap type
+ * @return iterable collection of selected vTaps
+ */
+ Set<OpenstackVtap> getVtaps(OpenstackVtap.Type type);
+
+ /**
+ * Returns the vTap with the specified identifier.
+ *
+ * @param vTapId vTap identifier
+ * @return vTap or null if not exist
+ */
+ OpenstackVtap getVtap(OpenstackVtapId vTapId);
+
+ /**
+ * Returns a collection of vTaps which are associated with the given device.
+ *
+ * @param type vTap type
+ * @param deviceId device identifier
+ * @return a set of vTaps
+ */
+ Set<OpenstackVtap> getVtapsByDeviceId(OpenstackVtap.Type type, DeviceId deviceId);
}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStore.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStore.java
new file mode 100644
index 0000000..15c945e
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStore.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.store.Store;
+
+import java.util.Set;
+
+/**
+ * Manages inventory of OpenstackVtap states; not intended for direct use.
+ */
+public interface OpenstackVtapStore
+ extends Store<OpenstackVtapEvent, OpenstackVtapStoreDelegate> {
+
+ /**
+ * Creates a new vTap or updates the existing one based on the specified
+ * description.
+ *
+ * @param vTapId vTap identifier
+ * @param description vTap description data
+ * @param replaceFlag replace device set if true, merge device set otherwise
+ * @return created or updated vTap object or null if error occurred
+ */
+ OpenstackVtap createOrUpdateVtap(OpenstackVtapId vTapId, OpenstackVtap description, boolean replaceFlag);
+
+ /**
+ * Removes the specified vTap from the inventory by the given vTap identifier.
+ *
+ * @param vTapId vTap identifier
+ * @return removed vTap object or null if error occurred
+ */
+ OpenstackVtap removeVtapById(OpenstackVtapId vTapId);
+
+ /**
+ * Adds the specified device id from the vTap entry.
+ *
+ * @param vTapId vTap identification
+ * @param type vTap type
+ * @param deviceId device identifier to be added
+ * @return true on success, false otherwise
+ */
+ boolean addDeviceToVtap(OpenstackVtapId vTapId, OpenstackVtap.Type type, DeviceId deviceId);
+
+ /**
+ * Removes the specified device id from the vTap entry.
+ *
+ * @param vTapId vTap identification
+ * @param type vTap type
+ * @param deviceId device identifier to be removed
+ * @return true on success, false otherwise
+ */
+ boolean removeDeviceFromVtap(OpenstackVtapId vTapId, OpenstackVtap.Type type, DeviceId deviceId);
+
+ /**
+ * Adds the specified device id from the vTap entry.
+ *
+ * @param vTapId vTap identification
+ * @param txDeviceIds TX device identifiers to be updated
+ * @param rxDeviceIds RX device identifiers to be updated
+ * @param replaceFlag replace device set if true, merge device set otherwise
+ * @return true on success, false otherwise
+ */
+ boolean updateDeviceForVtap(OpenstackVtapId vTapId, Set<DeviceId> txDeviceIds,
+ Set<DeviceId> rxDeviceIds, boolean replaceFlag);
+
+ /**
+ * Returns the number of vTaps in the store.
+ *
+ * @param type vTap type
+ * @return vTap count
+ */
+ int getVtapCount(OpenstackVtap.Type type);
+
+ /**
+ * Returns a collection of selected vTaps in the store.
+ *
+ * @param type vTap type
+ * @return iterable collection of selected vTaps
+ */
+ Set<OpenstackVtap> getVtaps(OpenstackVtap.Type type);
+
+ /**
+ * Returns the vTap with the specified identifier.
+ *
+ * @param vTapId vTap identifier
+ * @return vtap or null if not found
+ */
+ OpenstackVtap getVtap(OpenstackVtapId vTapId);
+
+ /**
+ * Returns the set of vTaps whose included on device.
+ *
+ * @param type vTap type
+ * @param deviceId device identifier
+ * @return set of vTaps
+ */
+ Set<OpenstackVtap> getVtapsByDeviceId(OpenstackVtap.Type type, DeviceId deviceId);
+}
diff --git a/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStoreDelegate.java b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStoreDelegate.java
new file mode 100644
index 0000000..0a783bd
--- /dev/null
+++ b/apps/openstackvtap/api/src/main/java/org/onosproject/openstackvtap/api/OpenstackVtapStoreDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018-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.onosproject.openstackvtap.api;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * OpenstackVtap store delegate abstraction.
+ */
+public interface OpenstackVtapStoreDelegate extends StoreDelegate<OpenstackVtapEvent> {
+}
diff --git a/apps/openstackvtap/app/pom.xml b/apps/openstackvtap/app/pom.xml
index 800c3ed..f8b40b4 100644
--- a/apps/openstackvtap/app/pom.xml
+++ b/apps/openstackvtap/app/pom.xml
@@ -158,6 +158,12 @@
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-rest</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
diff --git a/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
index 6a7e681..a7c4de7 100644
--- a/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
+++ b/apps/openstackvtap/app/src/main/java/org/onosproject/openstackvtap/impl/OpenstackVtapManager.java
@@ -15,14 +15,44 @@
*/
package org.onosproject.openstackvtap.impl;
+import org.onosproject.net.DeviceId;
+import org.onosproject.openstackvtap.api.OpenstackVtap;
+import org.onosproject.openstackvtap.api.OpenstackVtapId;
+import org.onosproject.openstackvtap.api.OpenstackVtapListener;
import org.onosproject.openstackvtap.api.OpenstackVtapService;
+import java.util.Set;
+
/**
* Implementation of openstack vtap.
*/
public class OpenstackVtapManager implements OpenstackVtapService {
@Override
- public void dummy() {
+ public int getVtapCount(OpenstackVtap.Type type) {
+ return 0;
+ }
+
+ @Override
+ public Set<OpenstackVtap> getVtaps(OpenstackVtap.Type type) {
+ return null;
+ }
+
+ @Override
+ public OpenstackVtap getVtap(OpenstackVtapId vTapId) {
+ return null;
+ }
+
+ @Override
+ public Set<OpenstackVtap> getVtapsByDeviceId(OpenstackVtap.Type type, DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public void addListener(OpenstackVtapListener listener) {
+ }
+
+ @Override
+ public void removeListener(OpenstackVtapListener listener) {
}
}