use of org.onosproject.openstacknode.api.DpdkInterface.Type in project onos by opennetworkinglab.
the class DpdkInterfaceCodec method decode.
@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(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
log.error(TYPE + MISSING_MESSAGE);
throw new IllegalArgumentException(e);
}
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();
}
use of org.onosproject.openstacknode.api.DpdkInterface.Type in project onos by opennetworkinglab.
the class DpdkInterfaceJsonMatcher method matchesSafely.
@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;
}
Aggregations