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