ONOS-4420 Implemented BMv2 packet provider
Also, moved DeviceId generation logic from Bmv2DeviceProvider to
Bmv2Device.
Change-Id: I0a7af6d558d054604038a858dce67a2d287bcde3
diff --git a/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Device.java b/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Device.java
index 446a514..e289615 100644
--- a/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Device.java
+++ b/protocols/bmv2/src/main/java/org/onosproject/bmv2/api/runtime/Bmv2Device.java
@@ -17,6 +17,10 @@
package org.onosproject.bmv2.api.runtime;
import com.google.common.base.Objects;
+import org.onosproject.net.DeviceId;
+
+import java.net.URI;
+import java.net.URISyntaxException;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -25,6 +29,10 @@
*/
public final class Bmv2Device {
+ public static final String SCHEME = "bmv2";
+ public static final String MANUFACTURER = "p4.org";
+ public static final String HW_VERSION = "bmv2";
+
private final String thriftServerHost;
private final int thriftServerPort;
private final int internalDeviceId;
@@ -66,10 +74,24 @@
*
* @return an integer value
*/
- public int getInternalDeviceId() {
+ public int internalDeviceId() {
return internalDeviceId;
}
+ /**
+ * Returns a new ONOS device ID for this device.
+ *
+ * @return a new device ID
+ */
+ public DeviceId asDeviceId() {
+ try {
+ // TODO: include internalDeviceId number in the deviceId URI
+ return DeviceId.deviceId(new URI(SCHEME, this.thriftServerHost + ":" + this.thriftServerPort, null));
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Unable to build deviceID for device " + this.toString(), e);
+ }
+ }
+
@Override
public int hashCode() {
return Objects.hashCode(thriftServerHost, thriftServerPort, internalDeviceId);