Search in sources :

Example 1 with ElanSegments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method buildSegments.

@Nonnull
private List<ElanSegments> buildSegments(Network input) {
    Long numSegments = NeutronUtils.getNumberSegmentsFromNeutronNetwork(input);
    List<ElanSegments> segments = new ArrayList<>();
    for (long index = 0L; index < numSegments; index++) {
        ElanSegmentsBuilder elanSegmentsBuilder = new ElanSegmentsBuilder();
        elanSegmentsBuilder.setSegmentationId(0L);
        if (NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index) != null) {
            try {
                elanSegmentsBuilder.setSegmentationId(Long.valueOf(NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index)));
            } catch (NumberFormatException error) {
                LOG.error("Failed to get the segment id for network {}", input);
            }
        }
        if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVxlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVxlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeFlat.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeFlat.class);
        }
        elanSegmentsBuilder.setSegmentationIndex(index);
        segments.add(elanSegmentsBuilder.build());
        LOG.debug("Added segment {} to ELANInstance", segments.get((int) index - 1));
    }
    return segments;
}
Also used : SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) ElanSegments(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments) ElanSegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegmentsBuilder) ArrayList(java.util.ArrayList) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Nonnull(javax.annotation.Nonnull)

Example 2 with ElanSegments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method createElanInstanceBuilder.

private ElanInstanceBuilder createElanInstanceBuilder(String elanInstanceName, Class<? extends SegmentTypeBase> segmentType, String segmentationId, String physicalNetworkName, Network network) {
    Boolean isExternal = NeutronvpnUtils.getIsExternal(network);
    List<ElanSegments> segments = buildSegments(network);
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName);
    if (segmentType != null) {
        elanInstanceBuilder.setSegmentType(segmentType);
        if (segmentationId != null) {
            elanInstanceBuilder.setSegmentationId(Long.valueOf(segmentationId));
        }
        if (physicalNetworkName != null) {
            elanInstanceBuilder.setPhysicalNetworkName(physicalNetworkName);
        }
    }
    elanInstanceBuilder.setElanSegments(segments);
    elanInstanceBuilder.setExternal(isExternal);
    elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
    return elanInstanceBuilder;
}
Also used : ElanSegments(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Aggregations

ElanSegments (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 SegmentTypeVlan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan)1 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)1 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)1 ElanSegmentsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegmentsBuilder)1 NetworkTypeVlan (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan)1