Search in sources :

Example 1 with PortBindingExtension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension in project netvirt by opendaylight.

the class NeutronUtils method isPortVnicTypeNormal.

public static boolean isPortVnicTypeNormal(Port port) {
    PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
    if (portBinding == null || portBinding.getVnicType() == null) {
        // By default, VNIC_TYPE is NORMAL
        return true;
    }
    String vnicType = portBinding.getVnicType().trim().toLowerCase(Locale.getDefault());
    return vnicType.equals(VNIC_TYPE_NORMAL);
}
Also used : PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Example 2 with PortBindingExtension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension in project netvirt by opendaylight.

the class DhcpNeutronPortListener method isVnicTypeDirectOrMacVtap.

private boolean isVnicTypeDirectOrMacVtap(Port port) {
    PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
    if (portBinding == null || portBinding.getVnicType() == null) {
        // By default, VNIC_TYPE is NORMAL
        return false;
    }
    String vnicType = portBinding.getVnicType().trim().toLowerCase(Locale.getDefault());
    return vnicType.equals("direct") || vnicType.equals("macvtap");
}
Also used : PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Example 3 with PortBindingExtension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension in project netvirt by opendaylight.

the class NeutronPortChangeListener method isPortTypeSwitchdev.

private boolean isPortTypeSwitchdev(final Port port) {
    if (!isPortVnicTypeDirect(port)) {
        return false;
    }
    PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
    String profile = portBinding.getProfile();
    if (profile == null || profile.isEmpty()) {
        LOG.debug("Port {} has no binding:profile values", port.getUuid());
        return false;
    }
    Map<String, JsonElement> mapProfile = unmarshal(profile);
    JsonElement capabilities = mapProfile.get(NeutronConstants.BINDING_PROFILE_CAPABILITIES);
    LOG.debug("Port {} capabilities: {}", port.getUuid(), capabilities);
    if (capabilities == null || !capabilities.isJsonArray()) {
        LOG.debug("binding profile capabilities not in array format: {}", capabilities);
        return false;
    }
    JsonArray capabilitiesArray = capabilities.getAsJsonArray();
    Gson gson = new Gson();
    JsonElement switchdevElement = gson.fromJson(NeutronConstants.SWITCHDEV, JsonElement.class);
    return capabilitiesArray.contains(switchdevElement);
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) Gson(com.google.gson.Gson) PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Example 4 with PortBindingExtension

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension in project netvirt by opendaylight.

the class NeutronPortChangeListener method isPortVnicTypeDirect.

private boolean isPortVnicTypeDirect(Port port) {
    PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
    if (portBinding == null || portBinding.getVnicType() == null) {
        // By default, VNIC_TYPE is NORMAL
        return false;
    }
    String vnicType = portBinding.getVnicType().trim().toLowerCase(Locale.getDefault());
    return vnicType.equals(NeutronConstants.VNIC_TYPE_DIRECT);
}
Also used : PortBindingExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)

Aggregations

PortBindingExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension)4 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1