[ONOS-6519] Supporting OVS DPDK, and PICA8 OVS interface creation & MTU setting
Change-Id: Icee3f9c6cf430d952acc7bfebd82cfa6d94b0e63
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
index df3461d..ebbdd76 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbInterface.java
@@ -16,10 +16,12 @@
package org.onosproject.ovsdb.controller;
import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.ovsdb.controller.OvsdbConstant.*;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import com.google.common.collect.Maps;
import org.onosproject.net.DefaultAnnotations;
@@ -56,20 +58,26 @@
/**
* A pair of virtual devices that act as a patch cable.
*/
- PATCH
+ PATCH,
+ /**
+ * A DPDK net device.
+ */
+ DPDK
}
private final String name;
private final Type type;
+ private final Optional<Long> mtu;
/* Adds more configs */
/* Fields start with "options:" prefix defined in the OVSDB */
private final Map<String, String> options;
- private OvsdbInterface(String name, Type type, Map<String, String> options) {
+ private OvsdbInterface(String name, Type type, Optional<Long> mtu, Map<String, String> options) {
this.name = name;
- this.type = type;
+ this.type = checkNotNull(type, "the type of interface can not be null");
+ this.mtu = mtu;
this.options = Maps.newHashMap(options);
}
@@ -101,6 +109,15 @@
}
/**
+ * Returns mtu of the interface.
+ *
+ * @return interface mtu
+ */
+ public Optional<Long> mtu() {
+ return mtu;
+ }
+
+ /**
* Returns optional configs of the interface.
*
* @return interface options
@@ -131,6 +148,7 @@
return toStringHelper(this)
.add("name", name)
.add("type", type)
+ .add("mtu", mtu)
.add("options", options)
.toString();
}
@@ -170,6 +188,7 @@
public static final class Builder {
private String name;
private Type type;
+ private Optional<Long> mtu = Optional.empty();
private Map<String, String> options = Maps.newHashMap();
private Builder() {
@@ -220,7 +239,7 @@
* @return ovsdb interface
*/
public OvsdbInterface build() {
- return new OvsdbInterface(name, type, options);
+ return new OvsdbInterface(name, type, mtu, options);
}
/**
@@ -246,6 +265,17 @@
}
/**
+ * Returns OVSDB interface builder with a given interface mtu.
+ *
+ * @param mtu mtu of the interface
+ * @return ovsdb interface builder
+ */
+ public Builder mtu(Long mtu) {
+ this.mtu = Optional.ofNullable(mtu);
+ return this;
+ }
+
+ /**
* Returns OVSDB interface builder with given options.
*
* @param options map of options
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 2ed28f7..0ed4663 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -1025,7 +1025,16 @@
// insert an interface
Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
intf.setName(ovsdbIface.name());
+
intf.setType(ovsdbIface.typeToString());
+
+ if (ovsdbIface.mtu().isPresent()) {
+ Set<Long> mtuSet = Sets.newConcurrentHashSet();
+ mtuSet.add(ovsdbIface.mtu().get());
+ intf.setMtu(mtuSet);
+ intf.setMtuRequest(mtuSet);
+ }
+
intf.setOptions(ovsdbIface.options());
Insert intfInsert = new Insert(dbSchema.getTableSchema(INTERFACE), INTERFACE, intf.getRow());
operations.add(intfInsert);