Search in sources :

Example 1 with NetworkTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase in project netvirt by opendaylight.

the class NeutronUtils method isNetworkSegmentType.

public static <T extends NetworkTypeBase> boolean isNetworkSegmentType(Network network, Long index, Class<T> expectedNetworkType) {
    Class<? extends NetworkTypeBase> segmentType = null;
    NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
    if (providerExtension != null) {
        List<Segments> providerSegments = providerExtension.getSegments();
        if (providerSegments != null && providerSegments.size() > 0) {
            for (Segments providerSegment : providerSegments) {
                if (Objects.equals(providerSegment.getSegmentationIndex(), index)) {
                    segmentType = providerSegment.getNetworkType();
                    break;
                }
            }
        }
    }
    return segmentType != null && segmentType.isAssignableFrom(expectedNetworkType);
}
Also used : Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 2 with NetworkTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method add.

@Override
public void add(InstanceIdentifier<Network> identifier, Network input) {
    LOG.trace("Adding Network : key: {}, value={}", identifier, input);
    String networkId = input.getUuid().getValue();
    if (!NeutronvpnUtils.isNetworkTypeSupported(input)) {
        LOG.error("Neutronvpn doesn't support the provider type for given network {}", networkId);
        return;
    }
    Class<? extends NetworkTypeBase> networkType = input.augmentation(NetworkProviderExtension.class).getNetworkType();
    if (NeutronvpnUtils.isVlanOrVxlanNetwork(networkType) && NeutronUtils.getSegmentationIdFromNeutronNetwork(input, networkType) == null) {
        LOG.error("Segmentation ID is null for configured provider network {} of type {}. Abandoning any further " + "processing for the network", input.getUuid().getValue(), networkType);
        return;
    }
    neutronvpnUtils.addToNetworkCache(input);
    // Create ELAN instance for this network
    ElanInstance elanInstance = createElanInstance(input);
    if (NeutronvpnUtils.getIsExternal(input)) {
        // Create ELAN interface and IETF interfaces for the physical network
        elanService.createExternalElanNetwork(elanInstance);
        ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
        if (providerNwType == null) {
            LOG.error("Unable to get Network Provider Type for network {}", networkId);
            return;
        }
        LOG.trace("External Network Provider Type for network {} is {}", networkId, providerNwType.getName());
        nvpnNatManager.addExternalNetwork(input);
        if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
            nvpnManager.createL3InternalVpn(input.getUuid(), null, null, null, null, null, null, null);
            nvpnManager.createExternalVpnInterfaces(input.getUuid());
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 3 with NetworkTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase in project netvirt by opendaylight.

the class NeutronUtils method getSegmentationIdFromNeutronNetwork.

public static <T extends NetworkTypeBase> String getSegmentationIdFromNeutronNetwork(Network network, Class<T> networkType) {
    String segmentationId = null;
    NetworkProviderExtension providerExtension = network.augmentation(NetworkProviderExtension.class);
    if (providerExtension != null) {
        segmentationId = providerExtension.getSegmentationId();
        if (segmentationId == null) {
            Map<SegmentsKey, Segments> providerSegmentsMap = providerExtension.getSegments();
            if (providerSegmentsMap != null && providerSegmentsMap.size() > 0) {
                for (Segments providerSegment : providerSegmentsMap.values()) {
                    if (isNetworkSegmentType(providerSegment, networkType)) {
                        segmentationId = providerSegment.getSegmentationId();
                        break;
                    }
                }
            }
        }
    }
    return segmentationId;
}
Also used : SegmentsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.SegmentsKey) Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 4 with NetworkTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase in project netvirt by opendaylight.

the class NeutronvpnUtils method getProviderNetworkType.

@Nullable
static ProviderTypes getProviderNetworkType(Network network) {
    if (network == null) {
        LOG.error("Error in getting provider network type since network is null");
        return null;
    }
    NetworkProviderExtension npe = network.augmentation(NetworkProviderExtension.class);
    if (npe != null) {
        Class<? extends NetworkTypeBase> networkTypeBase = npe.getNetworkType();
        if (networkTypeBase != null) {
            if (networkTypeBase.isAssignableFrom(NetworkTypeFlat.class)) {
                return ProviderTypes.FLAT;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeVlan.class)) {
                return ProviderTypes.VLAN;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeVxlan.class)) {
                return ProviderTypes.VXLAN;
            } else if (networkTypeBase.isAssignableFrom(NetworkTypeGre.class)) {
                return ProviderTypes.GRE;
            }
        }
    }
    LOG.error("Error in getting provider network type since network provider extension is null for network " + "{}", network.getUuid().getValue());
    return null;
}
Also used : NetworkTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeGre) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 5 with NetworkTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase in project netvirt by opendaylight.

the class NeutronvpnUtils method getSegmentationIdFromNeutronNetwork.

public static String getSegmentationIdFromNeutronNetwork(Network network) {
    String segmentationId = null;
    NetworkProviderExtension providerExtension = network.augmentation(NetworkProviderExtension.class);
    if (providerExtension != null) {
        Class<? extends NetworkTypeBase> networkType = providerExtension.getNetworkType();
        segmentationId = NeutronUtils.getSegmentationIdFromNeutronNetwork(network, networkType);
    }
    return segmentationId;
}
Also used : NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Aggregations

NetworkProviderExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)5 Segments (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments)2 Nullable (org.eclipse.jdt.annotation.Nullable)1 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)1 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)1 NetworkTypeGre (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeGre)1 NetworkTypeVlan (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan)1 SegmentsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.SegmentsKey)1