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;
}
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;
}
Aggregations