Search in sources :

Example 1 with DatapathType

use of org.onosproject.openstacknode.api.DpdkConfig.DatapathType in project onos by opennetworkinglab.

the class DpdkConfigJsonMatcher method matchesSafely.

@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;
}
Also used : DpdkInterface(org.onosproject.openstacknode.api.DpdkInterface) DatapathType(org.onosproject.openstacknode.api.DpdkConfig.DatapathType) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DatapathType (org.onosproject.openstacknode.api.DpdkConfig.DatapathType)1 DpdkInterface (org.onosproject.openstacknode.api.DpdkInterface)1