Search in sources :

Example 1 with ElanSegmentsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegmentsBuilder 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)

Aggregations

ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 SegmentTypeVlan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan)1 ElanSegments (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments)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