Supports dpdk config in OpenstackNode.
Change-Id: I332d7643acb56c5fa7460edb6e4c90a2d862706f
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java
new file mode 100644
index 0000000..3e8156d
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkConfigCodec.java
@@ -0,0 +1,95 @@
+/*
+ * 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.openstacknode.codec;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
+import org.onosproject.openstacknode.impl.DefaultDpdkConfig;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.IntStream;
+
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * dpdk config codec used for serializing and de-serializing JSON string.
+ */
+public class DpdkConfigCodec extends JsonCodec<DpdkConfig> {
+ private static final String DATA_PATH_TYPE = "datapathType";
+ private static final String SOCKET_DIR = "socketDir";
+ private static final String DPDK_INTFS = "dpdkIntfs";
+
+ private static final String MISSING_MESSAGE = " is required in DpdkInterface";
+
+ @Override
+ public ObjectNode encode(DpdkConfig entity, CodecContext context) {
+ ObjectNode result = context.mapper().createObjectNode()
+ .put(DATA_PATH_TYPE, entity.datapathType().name());
+
+ if (entity.socketDir() != null) {
+ result.put(SOCKET_DIR, entity.socketDir());
+ }
+
+ ArrayNode dpdkIntfs = context.mapper().createArrayNode();
+ entity.dpdkIntfs().forEach(dpdkIntf -> {
+ ObjectNode dpdkIntfJson = context.codec(DpdkInterface.class)
+ .encode(dpdkIntf, context);
+ dpdkIntfs.add(dpdkIntfJson);
+ });
+ result.set(DPDK_INTFS, dpdkIntfs);
+
+ return result;
+ }
+
+ @Override
+ public DpdkConfig decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ String datapathType = nullIsIllegal(json.get(DATA_PATH_TYPE).asText(),
+ DATA_PATH_TYPE + MISSING_MESSAGE);
+
+ DefaultDpdkConfig.Builder builder = DefaultDpdkConfig.builder()
+ .datapathType(DpdkConfig.DatapathType.valueOf(datapathType.toUpperCase()));
+
+ if (json.get(SOCKET_DIR) != null) {
+ builder.socketDir(json.get(SOCKET_DIR).asText());
+ }
+
+ List<DpdkInterface> dpdkInterfaces = new ArrayList<>();
+ JsonNode dpdkIntfsJson = json.get(DPDK_INTFS);
+
+ if (dpdkIntfsJson != null) {
+ final JsonCodec<DpdkInterface>
+ dpdkIntfCodec = context.codec(DpdkInterface.class);
+
+ IntStream.range(0, dpdkIntfsJson.size()).forEach(i -> {
+ ObjectNode intfJson = get(dpdkIntfsJson, i);
+ dpdkInterfaces.add(dpdkIntfCodec.decode(intfJson, context));
+ });
+ }
+ builder.dpdkIntfs(dpdkInterfaces);
+
+ return builder.build();
+ }
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java
new file mode 100644
index 0000000..033bfc0
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/DpdkInterfaceCodec.java
@@ -0,0 +1,90 @@
+/*
+ * 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.openstacknode.codec;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.openstacknode.api.DpdkInterface;
+import org.onosproject.openstacknode.api.DpdkInterface.Type;
+import org.onosproject.openstacknode.impl.DefaultDpdkInterface;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsIllegal;
+
+/**
+ * DPDK interface codec used for serializing and de-serializing JSON string.
+ */
+public class DpdkInterfaceCodec extends JsonCodec<DpdkInterface> {
+ private static final String DEVICE_NAME = "deviceName";
+ private static final String INTF = "intf";
+ private static final String PCI_ADDRESS = "pciAddress";
+ private static final String TYPE = "type";
+ private static final String MTU = "mtu";
+
+ private static final String NOT_NULL_MESSAGE = "dpdk interface cannot be null";
+ private static final String MISSING_MESSAGE = " is required in DpdkInterface";
+
+ @Override
+ public ObjectNode encode(DpdkInterface entity, CodecContext context) {
+ checkNotNull(entity, NOT_NULL_MESSAGE);
+
+ return context.mapper().createObjectNode()
+ .put(DEVICE_NAME, entity.deviceName())
+ .put(INTF, entity.intf())
+ .put(PCI_ADDRESS, entity.pciAddress())
+ .put(TYPE, entity.type().name())
+ .put(MTU, entity.mtu().toString());
+ }
+
+ @Override
+ public DpdkInterface decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ String deviceName = nullIsIllegal(json.get(DEVICE_NAME).asText(),
+ DEVICE_NAME + MISSING_MESSAGE);
+ String intf = nullIsIllegal(json.get(INTF).asText(),
+ INTF + MISSING_MESSAGE);
+ String pciAddress = nullIsIllegal(json.get(PCI_ADDRESS).asText(),
+ PCI_ADDRESS + MISSING_MESSAGE);
+ String typeString = nullIsIllegal(json.get(TYPE).asText(),
+ TYPE + MISSING_MESSAGE);
+
+ Type type;
+ try {
+ type = Type.valueOf(typeString.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(TYPE + MISSING_MESSAGE);
+ }
+
+ DpdkInterface.Builder builder = DefaultDpdkInterface.builder()
+ .deviceName(deviceName)
+ .intf(intf)
+ .pciAddress(pciAddress)
+ .type(type);
+
+ JsonNode mtuJson = json.get(MTU);
+
+ if (mtuJson != null) {
+ builder.mtu(Long.parseLong(mtuJson.asText()));
+ }
+
+ return builder.build();
+ }
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackNodeCodec.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackNodeCodec.java
index 5d16199..ad2f08b 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackNodeCodec.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/codec/OpenstackNodeCodec.java
@@ -24,6 +24,7 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.openstacknode.api.DefaultOpenstackNode;
+import org.onosproject.openstacknode.api.DpdkConfig;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
@@ -61,11 +62,9 @@
private static final String AUTHENTICATION = "authentication";
private static final String END_POINT = "endpoint";
private static final String SSH_AUTH = "sshAuth";
- private static final String DATA_PATH_TYPE = "datapathType";
- private static final String SOCKET_DIR = "socketDir";
+ private static final String DPDK_CONFIG = "dpdkConfig";
private static final String MISSING_MESSAGE = " is required in OpenstackNode";
- private static final String UNSUPPORTED_DATAPATH_TYPE = "Unsupported datapath type";
@Override
public ObjectNode encode(OpenstackNode node, CodecContext context) {
@@ -75,8 +74,7 @@
.put(HOST_NAME, node.hostname())
.put(TYPE, node.type().name())
.put(STATE, node.state().name())
- .put(MANAGEMENT_IP, node.managementIp().toString())
- .put(DATA_PATH_TYPE, node.datapathType().name());
+ .put(MANAGEMENT_IP, node.managementIp().toString());
OpenstackNode.NodeType type = node.type();
@@ -128,8 +126,10 @@
result.set(SSH_AUTH, sshAuthJson);
}
- if (node.socketDir() != null) {
- result.put(SOCKET_DIR, node.socketDir());
+ if (node.dpdkConfig() != null) {
+ ObjectNode dpdkConfigJson = context.codec(DpdkConfig.class)
+ .encode(node.dpdkConfig(), context);
+ result.set(DPDK_CONFIG, dpdkConfigJson);
}
return result;
@@ -175,23 +175,6 @@
nodeBuilder.intgBridge(DeviceId.deviceId(intBridgeJson.asText()));
}
- JsonNode datapathTypeJson = json.get(DATA_PATH_TYPE);
-
- if (datapathTypeJson == null ||
- datapathTypeJson.asText().equals(OpenstackNode.DatapathType.NORMAL.name().toLowerCase())) {
- nodeBuilder.datapathType(OpenstackNode.DatapathType.NORMAL);
- } else if (datapathTypeJson.asText().equals(OpenstackNode.DatapathType.NETDEV.name().toLowerCase())) {
- nodeBuilder.datapathType(OpenstackNode.DatapathType.NETDEV);
- } else {
- throw new IllegalArgumentException(UNSUPPORTED_DATAPATH_TYPE + datapathTypeJson.asText());
- }
-
- JsonNode socketDir = json.get(SOCKET_DIR);
-
- if (socketDir != null) {
- nodeBuilder.socketDir(socketDir.asText());
- }
-
// parse physical interfaces
List<OpenstackPhyInterface> phyIntfs = new ArrayList<>();
JsonNode phyIntfsJson = json.get(PHYSICAL_INTERFACES);
@@ -224,7 +207,7 @@
// parse authentication
JsonNode authJson = json.get(AUTHENTICATION);
- if (json.get(AUTHENTICATION) != null) {
+ if (authJson != null) {
final JsonCodec<OpenstackAuth> authCodec = context.codec(OpenstackAuth.class);
@@ -234,13 +217,21 @@
// parse ssh authentication
JsonNode sshAuthJson = json.get(SSH_AUTH);
- if (json.get(SSH_AUTH) != null) {
+ if (sshAuthJson != null) {
final JsonCodec<OpenstackSshAuth> sshAuthJsonCodec = context.codec(OpenstackSshAuth.class);
OpenstackSshAuth sshAuth = sshAuthJsonCodec.decode((ObjectNode) sshAuthJson.deepCopy(), context);
nodeBuilder.sshAuthInfo(sshAuth);
}
+ JsonNode dpdkConfigJson = json.get(DPDK_CONFIG);
+ if (dpdkConfigJson != null) {
+ final JsonCodec<DpdkConfig> dpdkConfigJsonCodec = context.codec(DpdkConfig.class);
+
+ DpdkConfig dpdkConfig = dpdkConfigJsonCodec.decode((ObjectNode) dpdkConfigJson.deepCopy(), context);
+ nodeBuilder.dpdkConfig(dpdkConfig);
+ }
+
log.trace("node is {}", nodeBuilder.build().toString());
return nodeBuilder.build();
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkConfig.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkConfig.java
new file mode 100644
index 0000000..afd2d22
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkConfig.java
@@ -0,0 +1,158 @@
+/*
+ * 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.openstacknode.impl;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Implementation of dpdk config.
+ */
+public final class DefaultDpdkConfig implements DpdkConfig {
+
+ private final DatapathType datapathType;
+ private final String socketDir;
+ private final Collection<DpdkInterface> dpdkIntfs;
+
+ private static final String NOT_NULL_MSG = "% cannot be null";
+
+ private DefaultDpdkConfig(DatapathType datapathType,
+ String socketDir,
+ Collection<DpdkInterface> dpdkIntfs) {
+ this.datapathType = datapathType;
+ this.socketDir = socketDir;
+ this.dpdkIntfs = dpdkIntfs;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof DefaultDpdkConfig)) {
+ return false;
+ }
+ DefaultDpdkConfig that = (DefaultDpdkConfig) o;
+ return datapathType == that.datapathType &&
+ Objects.equals(socketDir, that.socketDir) &&
+ Objects.equals(dpdkIntfs, that.dpdkIntfs);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(datapathType,
+ socketDir,
+ dpdkIntfs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("datapathType", datapathType)
+ .add("socketDir", socketDir)
+ .add("dpdkIntfs", dpdkIntfs)
+ .toString();
+ }
+
+ /**
+ * Returns the data path type.
+ *
+ * @return data path type; normal or netdev
+ */
+ @Override
+ public DatapathType datapathType() {
+ return datapathType;
+ }
+
+ /**
+ * Returns socket directory which dpdk port bound to.
+ *
+ * @return socket directory
+ */
+ @Override
+ public String socketDir() {
+ return socketDir;
+ }
+
+ /**
+ * Returns a collection of dpdk interfaces.
+ *
+ * @return dpdk interfaces
+ */
+ @Override
+ public Collection<DpdkInterface> dpdkIntfs() {
+ if (dpdkIntfs == null) {
+ return new ArrayList<>();
+ }
+ return ImmutableList.copyOf(dpdkIntfs);
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return dpdk config builder instance
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of DpdkConfig instance.
+ */
+ public static final class Builder implements DpdkConfig.Builder {
+ private DatapathType datapathType;
+ private String socketDir;
+ private Collection<DpdkInterface> dpdkIntfs;
+
+ private Builder() {
+
+ }
+
+ @Override
+ public DpdkConfig build() {
+ checkArgument(datapathType != null, NOT_NULL_MSG, "datapathType");
+ return new DefaultDpdkConfig(datapathType,
+ socketDir,
+ dpdkIntfs);
+ }
+
+ @Override
+ public Builder datapathType(DatapathType datapathType) {
+ this.datapathType = datapathType;
+ return this;
+ }
+
+ @Override
+ public Builder socketDir(String socketDir) {
+ this.socketDir = socketDir;
+ return this;
+ }
+
+ @Override
+ public Builder dpdkIntfs(Collection<DpdkInterface> dpdkIntfs) {
+ this.dpdkIntfs = dpdkIntfs;
+ return this;
+ }
+ }
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkInterface.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkInterface.java
new file mode 100644
index 0000000..c442876
--- /dev/null
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultDpdkInterface.java
@@ -0,0 +1,202 @@
+/*
+ * 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.openstacknode.impl;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.openstacknode.api.DpdkInterface;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+
+/**
+ * Implementation of dpdk interface.
+ */
+public final class DefaultDpdkInterface implements DpdkInterface {
+ private final String deviceName;
+ private final String intf;
+ private final String pciAddress;
+ private final Type type;
+ private final Long mtu;
+ private static final String NOT_NULL_MSG = "% cannot be null";
+
+ private DefaultDpdkInterface(String deviceName,
+ String intf,
+ String pciAddress,
+ Type type,
+ Long mtu) {
+ this.deviceName = deviceName;
+ this.intf = intf;
+ this.pciAddress = pciAddress;
+ this.type = type;
+ this.mtu = mtu;
+ }
+
+ /**
+ * Returns the name of the device where the dpdk interface is.
+ *
+ * @return device name
+ */
+ @Override
+ public String deviceName() {
+ return deviceName;
+ }
+
+ /**
+ * Returns the name of the dpdk interface.
+ *
+ * @return dpdk interface name
+ */
+ @Override
+ public String intf() {
+ return intf;
+ }
+
+ /**
+ * Returns the dpdk device arguments of this dpdk port.
+ * ex) "0000:85:00.1"
+ *
+ * @return pci address
+ */
+ @Override
+ public String pciAddress() {
+ return pciAddress;
+ }
+
+ /**
+ * Returns the dpdk interface type.
+ *
+ * @return type
+ */
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ /**
+ * Returns the mtu size.
+ *
+ * @return mtu
+ */
+ @Override
+ public Long mtu() {
+ return mtu;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("deviceName", deviceName)
+ .add("intf", intf)
+ .add("pciAddress", pciAddress)
+ .add("type", type)
+ .add("mtu", mtu)
+ .toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(deviceName,
+ intf,
+ pciAddress,
+ type,
+ mtu);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof DefaultDpdkInterface)) {
+ return false;
+ }
+ DefaultDpdkInterface that = (DefaultDpdkInterface) o;
+ return Objects.equals(deviceName, that.deviceName) &&
+ Objects.equals(intf, that.intf) &&
+ Objects.equals(pciAddress, that.pciAddress) &&
+ type == that.type &&
+ Objects.equals(mtu, that.mtu);
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return dpdk interface builder instance.
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of dpdk interface instance.
+ */
+ public static final class Builder implements DpdkInterface.Builder {
+ private String deviceName;
+ private String intf;
+ private String pciAddress;
+ private Type type;
+ private Long mtu = DpdkInterface.DEFAULT_MTU_SIZE;
+
+ private Builder() {
+ }
+
+ @Override
+ public DpdkInterface build() {
+ checkArgument(deviceName != null, NOT_NULL_MSG, "deviceName");
+ checkArgument(intf != null, NOT_NULL_MSG, "intf");
+ checkArgument(pciAddress != null, NOT_NULL_MSG, "pciAddress");
+ checkArgument(type != null, NOT_NULL_MSG, "type");
+
+ return new DefaultDpdkInterface(deviceName,
+ intf,
+ pciAddress,
+ type,
+ mtu);
+ }
+
+ @Override
+ public Builder deviceName(String deviceName) {
+ this.deviceName = deviceName;
+ return this;
+ }
+
+ @Override
+ public Builder intf(String name) {
+ this.intf = name;
+ return this;
+ }
+
+ @Override
+ public Builder pciAddress(String pciAddress) {
+ this.pciAddress = pciAddress;
+ return this;
+ }
+
+ @Override
+ public Builder type(Type type) {
+ this.type = type;
+ return this;
+ }
+
+ @Override
+ public Builder mtu(Long mtu) {
+ this.mtu = mtu;
+ return this;
+ }
+ }
+}
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
index 07d71de..4337355 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandler.java
@@ -78,11 +78,12 @@
import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
import static org.onosproject.openstacknode.api.Constants.DEFAULT_TUNNEL;
import static org.onosproject.openstacknode.api.Constants.INTEGRATION_BRIDGE;
+import static org.onosproject.openstacknode.api.DpdkConfig.DatapathType.NETDEV;
import static org.onosproject.openstacknode.api.NodeState.COMPLETE;
import static org.onosproject.openstacknode.api.NodeState.DEVICE_CREATED;
import static org.onosproject.openstacknode.api.NodeState.INCOMPLETE;
import static org.onosproject.openstacknode.api.NodeState.INIT;
-import static org.onosproject.openstacknode.api.OpenstackNode.DatapathType.NETDEV;
+
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.CONTROLLER;
import static org.onosproject.openstacknode.api.OpenstackNode.NodeType.GATEWAY;
import static org.onosproject.openstacknode.api.OpenstackNodeService.APP_ID;
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
index f30611b..368deed 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/impl/DistributedOpenstackNodeStore.java
@@ -28,6 +28,8 @@
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.openstacknode.api.DefaultOpenstackAuth;
import org.onosproject.openstacknode.api.DefaultOpenstackNode;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackNodeEvent;
@@ -83,9 +85,13 @@
.register(DefaultOpenstackNode.class)
.register(OpenstackNode.NodeType.class)
.register(NodeState.class)
- .register(OpenstackNode.DatapathType.class)
+ .register(DpdkConfig.class)
+ .register(DefaultDpdkConfig.class)
+ .register(DpdkConfig.DatapathType.class)
.register(OpenstackPhyInterface.class)
.register(DefaultOpenstackPhyInterface.class)
+ .register(DpdkInterface.class)
+ .register(DefaultDpdkInterface.class)
.register(ControllerInfo.class)
.register(DefaultOpenstackAuth.class)
.register(DefaultOpenstackAuth.Perspective.class)
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegister.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegister.java
index 3c8954c..4361317 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegister.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegister.java
@@ -22,10 +22,14 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onosproject.codec.CodecService;
import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackPhyInterface;
import org.onosproject.openstacknode.api.OpenstackSshAuth;
+import org.onosproject.openstacknode.codec.DpdkConfigCodec;
+import org.onosproject.openstacknode.codec.DpdkInterfaceCodec;
import org.onosproject.openstacknode.codec.OpenstackAuthCodec;
import org.onosproject.openstacknode.codec.OpenstackControllerCodec;
import org.onosproject.openstacknode.codec.OpenstackNodeCodec;
@@ -52,6 +56,8 @@
codecService.registerCodec(OpenstackPhyInterface.class, new OpenstackPhyInterfaceCodec());
codecService.registerCodec(ControllerInfo.class, new OpenstackControllerCodec());
codecService.registerCodec(OpenstackSshAuth.class, new OpenstackSshAuthCodec());
+ codecService.registerCodec(DpdkInterface.class, new DpdkInterfaceCodec());
+ codecService.registerCodec(DpdkConfig.class, new DpdkConfigCodec());
log.info("Started");
}
@@ -63,6 +69,8 @@
codecService.unregisterCodec(OpenstackPhyInterface.class);
codecService.unregisterCodec(ControllerInfo.class);
codecService.unregisterCodec(OpenstackSshAuth.class);
+ codecService.unregisterCodec(DpdkConfig.class);
+ codecService.unregisterCodec(DpdkInterface.class);
log.info("Stopped");
}
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkConfigJsonMatcher.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkConfigJsonMatcher.java
new file mode 100644
index 0000000..fd98a13
--- /dev/null
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkConfigJsonMatcher.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.openstacknode.codec;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkConfig.DatapathType;
+import org.onosproject.openstacknode.api.DpdkInterface;
+
+/**
+ * Hamcrest matcher for dpdk config.
+ */
+public final class DpdkConfigJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> {
+ private final DpdkConfig dpdkConfig;
+
+ private static final String DATA_PATH_TYPE = "datapathType";
+ private static final String SOCKET_DIR = "socketDir";
+ private static final String DPDK_INTFS = "dpdkIntfs";
+
+ private DpdkConfigJsonMatcher(DpdkConfig dpdkConfig) {
+ this.dpdkConfig = dpdkConfig;
+ }
+
+ @Override
+ protected boolean matchesSafely(JsonNode jsonNode, Description description) {
+
+ // check datapath type
+ DatapathType jsonDatapathType = DatapathType.valueOf(
+ jsonNode.get(DATA_PATH_TYPE).asText().toUpperCase());
+ DatapathType datapathType = dpdkConfig.datapathType();
+
+ if (!jsonDatapathType.equals(datapathType)) {
+ description.appendText("datapath type was " + jsonDatapathType.name());
+ return false;
+ }
+
+ // check socket directory
+ JsonNode jsonSocketDir = jsonNode.get(SOCKET_DIR);
+ if (jsonSocketDir != null) {
+ String socketDir = dpdkConfig.socketDir();
+
+ if (!jsonSocketDir.asText().equals(socketDir)) {
+ description.appendText("socketDir was " + jsonSocketDir);
+ return false;
+ }
+ }
+
+ // check dpdk interfaces
+ JsonNode jsonDpdkintfs = jsonNode.get(DPDK_INTFS);
+ if (jsonDpdkintfs != null) {
+ if (jsonDpdkintfs.size() != dpdkConfig.dpdkIntfs().size()) {
+ description.appendText("dpdk interface size was " + jsonDpdkintfs.size());
+ return false;
+ }
+
+ for (DpdkInterface dpdkIntf : dpdkConfig.dpdkIntfs()) {
+ boolean intfFound = false;
+ for (int intfIndex = 0; intfIndex < jsonDpdkintfs.size(); intfIndex++) {
+ DpdkInterfaceJsonMatcher intfMatcher =
+ DpdkInterfaceJsonMatcher.matchesDpdkInterface(dpdkIntf);
+ if (intfMatcher.matches(jsonDpdkintfs.get(intfIndex))) {
+ intfFound = true;
+ break;
+ }
+ }
+
+ if (!intfFound) {
+ description.appendText("DpdkIntf not found " + dpdkIntf.toString());
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(dpdkConfig.toString());
+ }
+
+ /**
+ * Factory to allocate and dpdk config matcher.
+ *
+ * @param dpdkConfig dpdk config object we are looking for
+ * @return matcher
+ */
+ public static DpdkConfigJsonMatcher matchDpdkConfig(DpdkConfig dpdkConfig) {
+ return new DpdkConfigJsonMatcher(dpdkConfig);
+ }
+}
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkInterfaceJsonMatcher.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkInterfaceJsonMatcher.java
new file mode 100644
index 0000000..a5b17e4
--- /dev/null
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/DpdkInterfaceJsonMatcher.java
@@ -0,0 +1,105 @@
+/*
+ * 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.openstacknode.codec;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+import org.onosproject.openstacknode.api.DpdkInterface;
+import org.onosproject.openstacknode.api.DpdkInterface.Type;
+import org.slf4j.Logger;
+
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Hamcrest matcher for dpdk interface.
+ */
+public final class DpdkInterfaceJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNode> {
+ private final Logger log = getLogger(getClass());
+
+ private static final String DEVICE_NAME = "deviceName";
+ private static final String INTF = "intf";
+ private static final String PCI_ADDRESS = "pciAddress";
+ private static final String TYPE = "type";
+ private static final String MTU = "mtu";
+
+ private final DpdkInterface dpdkIntf;
+
+ private DpdkInterfaceJsonMatcher(DpdkInterface dpdkIntf) {
+ this.dpdkIntf = dpdkIntf;
+ }
+
+ @Override
+ protected boolean matchesSafely(JsonNode jsonNode, Description description) {
+
+ // check device name
+ String jsonDeviceName = jsonNode.get(DEVICE_NAME).asText();
+ String deviceName = dpdkIntf.deviceName();
+ if (!jsonDeviceName.equals(deviceName)) {
+ description.appendText("device name was " + jsonDeviceName);
+ return false;
+ }
+
+ String jsonIntf = jsonNode.get(INTF).asText();
+ String intf = dpdkIntf.intf();
+ if (!jsonIntf.equals(intf)) {
+ description.appendText("interface name was " + jsonIntf);
+ return false;
+ }
+
+ String jsonPciAddress = jsonNode.get(PCI_ADDRESS).asText();
+ String pciAddress = dpdkIntf.pciAddress();
+ if (!jsonPciAddress.equals(pciAddress)) {
+ description.appendText("pci address was " + jsonPciAddress);
+ return false;
+ }
+
+ Type jsonType = Type.valueOf(jsonNode.get(TYPE).asText());
+ Type type = dpdkIntf.type();
+ if (!jsonType.equals(type)) {
+ description.appendText("type was " + jsonType.name());
+ return false;
+ }
+
+ JsonNode jsonMtu = jsonNode.get(MTU);
+ if (jsonMtu != null) {
+ Long mtu = dpdkIntf.mtu();
+ if (!jsonMtu.asText().equals(mtu.toString())) {
+ description.appendText("mtu was " + jsonMtu.asText());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(dpdkIntf.toString());
+ }
+
+ /**
+ * Factory to allocate an dpdk interface matcher.
+ *
+ * @param dpdkIntf dpdk interface object we are looking for
+ * @return matcher
+ */
+ public static DpdkInterfaceJsonMatcher matchesDpdkInterface(DpdkInterface dpdkIntf) {
+ return new DpdkInterfaceJsonMatcher(dpdkIntf);
+ }
+}
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeCodecTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeCodecTest.java
index 4268d6c..af5fdf4 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeCodecTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeCodecTest.java
@@ -29,18 +29,24 @@
import org.onosproject.core.CoreService;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.openstacknode.api.DefaultOpenstackAuth;
+import org.onosproject.openstacknode.api.DefaultOpenstackNode;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackPhyInterface;
import org.onosproject.openstacknode.api.OpenstackSshAuth;
-import org.onosproject.openstacknode.api.DefaultOpenstackAuth;
-import org.onosproject.openstacknode.api.DefaultOpenstackNode;
+import org.onosproject.openstacknode.impl.DefaultDpdkConfig;
+import org.onosproject.openstacknode.impl.DefaultDpdkInterface;
import org.onosproject.openstacknode.impl.DefaultOpenstackPhyInterface;
import org.onosproject.openstacknode.impl.DefaultOpenstackSshAuth;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -50,6 +56,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertEquals;
import static org.onosproject.net.NetTestTools.APP_ID;
import static org.onosproject.openstacknode.codec.OpenstackNodeJsonMatcher.matchesOpenstackNode;
@@ -63,6 +70,8 @@
JsonCodec<ControllerInfo> openstackControllerJsonCodec;
JsonCodec<OpenstackAuth> openstackAuthJsonCodec;
JsonCodec<OpenstackSshAuth> openstackSshAuthJsonCodec;
+ JsonCodec<DpdkConfig> dpdkConfigJsonCodec;
+ JsonCodec<DpdkInterface> dpdkInterfaceJsonCodec;
final CoreService mockCoreService = createMock(CoreService.class);
private static final String REST_APP_ID = "org.onosproject.rest";
@@ -75,12 +84,16 @@
openstackControllerJsonCodec = new OpenstackControllerCodec();
openstackAuthJsonCodec = new OpenstackAuthCodec();
openstackSshAuthJsonCodec = new OpenstackSshAuthCodec();
+ dpdkConfigJsonCodec = new DpdkConfigCodec();
+ dpdkInterfaceJsonCodec = new DpdkInterfaceCodec();
assertThat(openstackNodeCodec, notNullValue());
assertThat(openstackPhyIntfJsonCodec, notNullValue());
assertThat(openstackControllerJsonCodec, notNullValue());
assertThat(openstackAuthJsonCodec, notNullValue());
assertThat(openstackSshAuthJsonCodec, notNullValue());
+ assertThat(dpdkConfigJsonCodec, notNullValue());
+ assertThat(dpdkInterfaceJsonCodec, notNullValue());
expect(mockCoreService.registerApplication(REST_APP_ID))
.andReturn(APP_ID).anyTimes();
@@ -119,12 +132,11 @@
.state(NodeState.INIT)
.managementIp(IpAddress.valueOf("10.10.10.1"))
.intgBridge(DeviceId.deviceId("br-int"))
- .vlanIntf("vxlan")
+ .vlanIntf("vlan")
.dataIp(IpAddress.valueOf("20.20.20.2"))
.phyIntfs(ImmutableList.of(phyIntf1, phyIntf2))
.controllers(ImmutableList.of(controller1, controller2))
.sshAuthInfo(sshAuth)
- .socketDir("/var/lib/libvirt/qemu")
.build();
ObjectNode nodeJson = openstackNodeCodec.encode(node, context);
@@ -134,7 +146,7 @@
/**
* Tests the openstack compute node decoding.
*
- * @throws IOException
+ * @throws IOException io exception
*/
@Test
public void testOpenstackComputeNodeDecode() throws IOException {
@@ -150,8 +162,7 @@
assertThat(node.controllers().size(), is(2));
assertThat(node.sshAuthInfo().id(), is("sdn"));
assertThat(node.sshAuthInfo().password(), is("sdn"));
- assertThat(node.datapathType(), is(OpenstackNode.DatapathType.NORMAL));
- assertThat(node.socketDir(), is("/var/lib/libvirt/qemu"));
+ assertThat(node.datapathType(), is(DpdkConfig.DatapathType.NORMAL));
node.phyIntfs().forEach(intf -> {
@@ -171,10 +182,65 @@
assertThat(ctrl.port(), is(6663));
}
});
+ }
- OpenstackNode dpdkNode = getOpenstackNode("OpenstackDpdkComputeNode.json");
+ /**
+ * Tests the openstack compute node encoding with dpdk config.
+ */
+ @Test
+ public void testOpenstackDpdkComputeNodeEncode() {
+ DpdkInterface dpdkInterface1 = DefaultDpdkInterface.builder()
+ .deviceName("br-int")
+ .intf("dpdk0")
+ .mtu(Long.valueOf(1600))
+ .pciAddress("0000:85:00.0")
+ .type(DpdkInterface.Type.DPDK)
+ .build();
- assertThat(dpdkNode.datapathType(), is(OpenstackNode.DatapathType.NETDEV));
+ DpdkInterface dpdkInterface2 = DefaultDpdkInterface.builder()
+ .deviceName("br-tun")
+ .intf("dpdk1")
+ .pciAddress("0000:85:00.1")
+ .type(DpdkInterface.Type.DPDK)
+ .build();
+
+ Collection<DpdkInterface> dpdkInterfaceCollection = new ArrayList<>();
+ dpdkInterfaceCollection.add(dpdkInterface1);
+ dpdkInterfaceCollection.add(dpdkInterface2);
+
+
+ DpdkConfig dpdkConfig = DefaultDpdkConfig.builder()
+ .datapathType(DpdkConfig.DatapathType.NETDEV)
+ .dpdkIntfs(dpdkInterfaceCollection)
+ .build();
+
+ OpenstackNode node = DefaultOpenstackNode.builder()
+ .hostname("compute")
+ .type(OpenstackNode.NodeType.COMPUTE)
+ .state(NodeState.INIT)
+ .managementIp(IpAddress.valueOf("10.10.10.1"))
+ .intgBridge(DeviceId.deviceId("br-int"))
+ .vlanIntf("vlan")
+ .dataIp(IpAddress.valueOf("20.20.20.2"))
+ .dpdkConfig(dpdkConfig)
+ .build();
+
+ ObjectNode nodeJson = openstackNodeCodec.encode(node, context);
+ assertThat(nodeJson, matchesOpenstackNode(node));
+ }
+
+ /**
+ * Tests the openstack compute node decoding with dpdk config.
+ *
+ * @throws IOException io exception
+ */
+ @Test
+ public void testOpenstackDpdkComputeNodeDecode() throws IOException {
+ OpenstackNode node = getOpenstackNode("OpenstackDpdkComputeNode.json");
+
+ assertEquals(node.datapathType(), DpdkConfig.DatapathType.NETDEV);
+ assertEquals(node.socketDir(), "/var/lib/libvirt/qemu");
+ assertEquals(node.dpdkConfig().dpdkIntfs().size(), 2);
}
/**
@@ -277,6 +343,12 @@
if (entityClass == OpenstackSshAuth.class) {
return (JsonCodec<T>) openstackSshAuthJsonCodec;
}
+ if (entityClass == DpdkConfig.class) {
+ return (JsonCodec<T>) dpdkConfigJsonCodec;
+ }
+ if (entityClass == DpdkInterface.class) {
+ return (JsonCodec<T>) dpdkInterfaceJsonCodec;
+ }
return manager.getCodec(entityClass);
}
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeJsonMatcher.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeJsonMatcher.java
index 49c08c6..6e3b473 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeJsonMatcher.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/codec/OpenstackNodeJsonMatcher.java
@@ -20,6 +20,7 @@
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.openstacknode.api.Constants;
+import org.onosproject.openstacknode.api.DpdkConfig;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackPhyInterface;
@@ -38,12 +39,11 @@
private static final String INTEGRATION_BRIDGE = "integrationBridge";
private static final String STATE = "state";
private static final String PHYSICAL_INTERFACES = "phyIntfs";
+ private static final String DPDK_CONFIG = "dpdkConfig";
private static final String CONTROLLERS = "controllers";
private static final String AUTHENTICATION = "authentication";
private static final String END_POINT = "endpoint";
private static final String SSH_AUTH = "sshAuth";
- private static final String DATA_PATH_TYPE = "datapathType";
- private static final String SOCKET_DIR = "socketDir";
private OpenstackNodeJsonMatcher(OpenstackNode node) {
this.node = node;
@@ -135,6 +135,13 @@
}
}
+ // check dpdk config
+ JsonNode jsonDpdkConfig = jsonNode.get(DPDK_CONFIG);
+ if (jsonDpdkConfig != null) {
+ DpdkConfig dpdkConfig = node.dpdkConfig();
+
+ }
+
// check endpoint URL
JsonNode jsonEndpoint = jsonNode.get(END_POINT);
if (jsonEndpoint != null) {
@@ -145,26 +152,6 @@
}
}
- // check datapath type
- JsonNode jsonDatapathType = jsonNode.get(DATA_PATH_TYPE);
- if (jsonDatapathType != null) {
- OpenstackNode.DatapathType datapathType = node.datapathType();
- if (!OpenstackNode.DatapathType.valueOf(jsonDatapathType.asText()).equals(datapathType)) {
- description.appendText("datapathType was " + jsonDatapathType);
- return false;
- }
- }
-
- // check socket directory
- JsonNode jsonSocketDir = jsonNode.get(SOCKET_DIR);
- if (jsonSocketDir != null) {
- String socketDir = node.socketDir();
- if (!jsonSocketDir.asText().equals(socketDir)) {
- description.appendText("socketDir was " + jsonSocketDir);
- return false;
- }
- }
-
// check physical interfaces
JsonNode jsonPhyIntfs = jsonNode.get(PHYSICAL_INTERFACES);
if (jsonPhyIntfs != null) {
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
index 06d29d7b..ebf12c0 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/impl/DefaultOpenstackNodeHandlerTest.java
@@ -70,6 +70,7 @@
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.openstacknode.api.DefaultOpenstackNode;
+import org.onosproject.openstacknode.api.DpdkConfig;
import org.onosproject.openstacknode.api.NodeState;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
@@ -424,7 +425,7 @@
ipAddr,
ipAddr,
null, null, state, phyIntfs, controllers,
- null, null, null, OpenstackNode.DatapathType.NORMAL, null);
+ null, null, null, null);
}
private static OpenstackNode createGatewayNode(String hostname,
@@ -440,7 +441,7 @@
ipAddr,
ipAddr,
null, uplinkPort, state, null, null, null, null, null,
- OpenstackNode.DatapathType.NORMAL, null);
+ null);
}
private static final class TestDevice extends DefaultDevice {
@@ -503,8 +504,7 @@
OpenstackAuth auth,
String endpoint,
OpenstackSshAuth sshAuth,
- DatapathType datapathType,
- String socketDir) {
+ DpdkConfig dpdkConfig) {
super(hostname,
type,
intgBridge,
@@ -518,8 +518,7 @@
auth,
endpoint,
sshAuth,
- datapathType,
- socketDir);
+ dpdkConfig);
}
@Override
diff --git a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegisterTest.java b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegisterTest.java
index e1cfa9b..ad64489 100644
--- a/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegisterTest.java
+++ b/apps/openstacknode/app/src/test/java/org/onosproject/openstacknode/web/OpenstackNodeCodecRegisterTest.java
@@ -22,10 +22,14 @@
import org.onosproject.codec.CodecService;
import org.onosproject.codec.JsonCodec;
import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.openstacknode.api.DpdkConfig;
+import org.onosproject.openstacknode.api.DpdkInterface;
import org.onosproject.openstacknode.api.OpenstackAuth;
import org.onosproject.openstacknode.api.OpenstackNode;
import org.onosproject.openstacknode.api.OpenstackPhyInterface;
import org.onosproject.openstacknode.api.OpenstackSshAuth;
+import org.onosproject.openstacknode.codec.DpdkConfigCodec;
+import org.onosproject.openstacknode.codec.DpdkInterfaceCodec;
import org.onosproject.openstacknode.codec.OpenstackAuthCodec;
import org.onosproject.openstacknode.codec.OpenstackControllerCodec;
import org.onosproject.openstacknode.codec.OpenstackNodeCodec;
@@ -66,6 +70,10 @@
codecService.getCodec(ControllerInfo.class).getClass().getName());
assertEquals(OpenstackSshAuthCodec.class.getName(),
codecService.getCodec(OpenstackSshAuth.class).getClass().getName());
+ assertEquals(DpdkConfigCodec.class.getName(),
+ codecService.getCodec(DpdkConfig.class).getClass().getName());
+ assertEquals(DpdkInterfaceCodec.class.getName(),
+ codecService.getCodec(DpdkInterface.class).getClass().getName());
register.deactivate();
@@ -74,6 +82,8 @@
assertNull(codecService.getCodec(OpenstackPhyInterface.class));
assertNull(codecService.getCodec(ControllerInfo.class));
assertNull(codecService.getCodec(OpenstackSshAuth.class));
+ assertNull(codecService.getCodec(DpdkConfig.class));
+ assertNull(codecService.getCodec(DpdkInterface.class));
}
private static class TestCodecService implements CodecService {
diff --git a/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackComputeNode.json b/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackComputeNode.json
index 0c0f949..0c07798 100644
--- a/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackComputeNode.json
+++ b/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackComputeNode.json
@@ -28,6 +28,5 @@
"ip": "10.10.10.3",
"port": 6663
}
- ],
- "socketDir": "/var/lib/libvirt/qemu"
+ ]
}
\ No newline at end of file
diff --git a/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackDpdkComputeNode.json b/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackDpdkComputeNode.json
index 2313047..3e40a65 100644
--- a/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackDpdkComputeNode.json
+++ b/apps/openstacknode/app/src/test/resources/org/onosproject/openstacknode/codec/OpenstackDpdkComputeNode.json
@@ -3,9 +3,7 @@
"type": "COMPUTE",
"managementIp": "172.16.130.4",
"dataIp": "172.16.130.4",
- "vlanPort": "eth2",
"integrationBridge": "of:00000000000000a1",
- "datapathType" : "netdev",
"phyIntfs": [
{
"network": "mgmtnetwork",
@@ -29,5 +27,25 @@
"ip": "10.10.10.3",
"port": 6663
}
- ]
+ ],
+ "dpdkConfig" : {
+ "datapathType" : "netdev",
+ "socketDir" : "/var/lib/libvirt/qemu",
+ "dpdkIntfs" : [
+ {
+ "intf" : "dpdk0",
+ "mtu" : 1500,
+ "deviceName" : "br-int",
+ "pciAddress" : "0000:85:00.0",
+ "type" : "dpdk"
+ },
+ {
+ "intf" : "dpdk1",
+ "mtu" : 1500,
+ "deviceName" : "br-tun",
+ "pciAddress" : "0000:85:00.0",
+ "type" : "dpdk"
+ }
+ ]
+ }
}
\ No newline at end of file