Added patch interface add and remove behavior, and implemented OVSDB driver

Change-Id: Ic7632906fcfe50ec224fabdc15cb902a70150fae
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/DefaultPatchDescription.java b/core/api/src/main/java/org/onosproject/net/behaviour/DefaultPatchDescription.java
new file mode 100644
index 0000000..e8cd002
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/DefaultPatchDescription.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+package org.onosproject.net.behaviour;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
+import org.onosproject.net.AbstractDescription;
+import org.onosproject.net.SparseAnnotations;
+
+import java.util.Optional;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Default implementation of immutable patch interface description entity.
+ */
+public final class DefaultPatchDescription extends AbstractDescription
+        implements PatchDescription {
+
+    private final Optional<String> deviceId;
+    private final String ifaceName;
+    private final String peerName;
+
+    private DefaultPatchDescription(Optional<String> deviceId,
+                                    String ifaceName,
+                                    String peerName,
+                                    SparseAnnotations... annotations) {
+        super(annotations);
+        this.deviceId = deviceId;
+        this.ifaceName = ifaceName;
+        this.peerName = peerName;
+    }
+
+
+    @Override
+    public Optional<String> deviceId() {
+        return deviceId;
+    }
+
+    @Override
+    public String ifaceName() {
+        return ifaceName;
+    }
+
+    @Override
+    public String peer() {
+        return peerName;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("deviceId", deviceId)
+                .add("ifaceName", ifaceName)
+                .add("peerName", peerName)
+                .toString();
+    }
+
+    /**
+     * Returns new builder instance.
+     *
+     * @return default patch description builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static final class Builder implements PatchDescription.Builder {
+
+        private Optional<String> deviceId = Optional.empty();
+        private String ifaceName;
+        private String peerName;
+
+        private Builder() {
+        }
+
+        @Override
+        public PatchDescription build() {
+            return new DefaultPatchDescription(deviceId, ifaceName, peerName);
+        }
+
+        @Override
+        public PatchDescription.Builder deviceId(String deviceId) {
+            this.deviceId = Optional.ofNullable(deviceId);
+            return this;
+        }
+
+        @Override
+        public PatchDescription.Builder ifaceName(String ifaceName) {
+            checkArgument(!Strings.isNullOrEmpty(ifaceName));
+            this.ifaceName = ifaceName;
+            return this;
+        }
+
+        @Override
+        public PatchDescription.Builder peer(String peerName) {
+            checkArgument(!Strings.isNullOrEmpty(peerName));
+            this.peerName = peerName;
+            return this;
+        }
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/InterfaceConfig.java b/core/api/src/main/java/org/onosproject/net/behaviour/InterfaceConfig.java
index 47f6100..6c20a96 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/InterfaceConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/InterfaceConfig.java
@@ -142,6 +142,23 @@
     boolean removeTunnelMode(String intf);
 
     /**
+     * Adds a patch mode to the supplied interface.
+     *
+     * @param ifaceName interface name to set patch mode
+     * @param patchInterface interface description
+     * @return true if the operation succeeds
+     */
+    boolean addPatchMode(String ifaceName, PatchDescription patchInterface);
+
+    /**
+     * Removes a patch mode from the supplied interface.
+     *
+     * @param ifaceName interface name
+     * @return true if the operation succeeds
+     */
+    boolean removePatchMode(String ifaceName);
+
+    /**
      * Provides the interfaces configured on a device.
      *
      * @param deviceId the device ID
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/PatchDescription.java b/core/api/src/main/java/org/onosproject/net/behaviour/PatchDescription.java
new file mode 100755
index 0000000..16958fb
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/PatchDescription.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.onosproject.net.behaviour;
+
+import org.onosproject.net.Annotated;
+import org.onosproject.net.Description;
+
+import java.util.Optional;
+
+/**
+ * Describes a patch interface.
+ */
+public interface PatchDescription extends Description, Annotated {
+
+    /**
+     * Returns the identifier of the device where this patch interface is.
+     *
+     * @return device identifier; empty value if not set
+     */
+    Optional<String> deviceId();
+
+    /**
+     * Return the name of the patch interface.
+     *
+     * @return patch interface name
+     */
+    String ifaceName();
+
+    /**
+     * Returns the name of the interface for the other side of the patch.
+     *
+     * @return peer patch interface name
+     */
+    String peer();
+
+    /**
+     * Builder of patch interface description entities.
+     */
+    interface Builder {
+
+        /**
+         * Returns new patch interface description.
+         *
+         * @return patch interface description
+         */
+        PatchDescription build();
+
+        /**
+         * Returns new patch interface description.
+         *
+         * @param deviceId device id
+         * @return patch interface description builder
+         */
+        Builder deviceId(String deviceId);
+        /**
+         * Returns patch interface description builder with a given interface name.
+         *
+         * @param ifaceName interface name
+         * @return patch interface description builder
+         */
+        Builder ifaceName(String ifaceName);
+
+        /**
+         * Returns patch interface description builder with a given peer.
+         *
+         * @param peerName peer patch interface name
+         * @return patch interface description builder
+         */
+        Builder peer(String peerName);
+    }
+
+}