@Test public void testCreateBridgeDomain_vlanNetwork() { netExtBuilder.setNetworkType(NetworkTypeVlan.class); netExtBuilder.setSegmentationId("2016"); Network vlanNetwork = createTestNetwork("VlanNet", netExtBuilder.build()); GbpBridgeDomain bridgeDomain = networkAware.createGbpBridgeDomain(vlanNetwork); assertEquals(bridgeDomain.getId(), vlanNetwork.getUuid().getValue()); assertEquals(bridgeDomain.getDescription(), vlanNetwork.getName()); assertEquals(bridgeDomain.getType(), VlanNetwork.class); assertEquals(bridgeDomain.getVlan(), new VlanId(Integer.valueOf(2016))); }
@VisibleForTesting GbpBridgeDomain createGbpBridgeDomain(Network network) { GbpBridgeDomainBuilder bridgeDomainBuilder = new GbpBridgeDomainBuilder(); String description = (network.getName() != null) ? network.getName() : "Neutron network"; bridgeDomainBuilder.setDescription(description); bridgeDomainBuilder.setId(network.getUuid().getValue()); NetworkProviderExtension providerAug = network.getAugmentation(NetworkProviderExtension.class); if (providerAug == null || providerAug.getNetworkType() == null) { LOG.warn("Cannot create VPP bridge domain. Network type not specified in neutron network: {}", network); return null; } Class<? extends NetworkTypeBase> netType = convertNetworkType(providerAug.getNetworkType()); if (netType == null) { return null; } bridgeDomainBuilder.setPhysicalLocationRef(resolveDomainLocations(providerAug)); bridgeDomainBuilder.setType(netType); if (providerAug.getNetworkType().isAssignableFrom(NetworkTypeVlan.class) && providerAug.getSegmentationId() != null) { try { bridgeDomainBuilder.setVlan(new VlanId(Integer.valueOf(providerAug.getSegmentationId()))); } catch (NumberFormatException e) { LOG.error("Neutron network {}. Cannot create VLAN ID from segmentation-id: {}. {}", providerAug.getSegmentationId(), network.getUuid(), e); return null; } } return bridgeDomainBuilder.build(); }
NetworkAware implements MappingProvider<Network> { @VisibleForTesting GbpBridgeDomain createGbpBridgeDomain(Network network) { GbpBridgeDomainBuilder bridgeDomainBuilder = new GbpBridgeDomainBuilder(); String description = (network.getName() != null) ? network.getName() : "Neutron network"; bridgeDomainBuilder.setDescription(description); bridgeDomainBuilder.setId(network.getUuid().getValue()); NetworkProviderExtension providerAug = network.getAugmentation(NetworkProviderExtension.class); if (providerAug == null || providerAug.getNetworkType() == null) { LOG.warn("Cannot create VPP bridge domain. Network type not specified in neutron network: {}", network); return null; } Class<? extends NetworkTypeBase> netType = convertNetworkType(providerAug.getNetworkType()); if (netType == null) { return null; } bridgeDomainBuilder.setPhysicalLocationRef(resolveDomainLocations(providerAug)); bridgeDomainBuilder.setType(netType); if (providerAug.getNetworkType().isAssignableFrom(NetworkTypeVlan.class) && providerAug.getSegmentationId() != null) { try { bridgeDomainBuilder.setVlan(new VlanId(Integer.valueOf(providerAug.getSegmentationId()))); } catch (NumberFormatException e) { LOG.error("Neutron network {}. Cannot create VLAN ID from segmentation-id: {}. {}", providerAug.getSegmentationId(), network.getUuid(), e); return null; } } return bridgeDomainBuilder.build(); } }
NetworkAware implements MappingProvider<Network> { @VisibleForTesting GbpBridgeDomain createGbpBridgeDomain(Network network) { GbpBridgeDomainBuilder bridgeDomainBuilder = new GbpBridgeDomainBuilder(); String description = (network.getName() != null) ? network.getName() : "Neutron network"; bridgeDomainBuilder.setDescription(description); bridgeDomainBuilder.setId(network.getUuid().getValue()); NetworkProviderExtension providerAug = network.getAugmentation(NetworkProviderExtension.class); if (providerAug == null || providerAug.getNetworkType() == null) { LOG.warn("Cannot create VPP bridge domain. Network type not specified in neutron network: {}", network); return null; } Class<? extends NetworkTypeBase> netType = convertNetworkType(providerAug.getNetworkType()); if (netType == null) { return null; } bridgeDomainBuilder.setPhysicalLocationRef(resolveDomainLocations(providerAug)); bridgeDomainBuilder.setType(netType); if (providerAug.getNetworkType().isAssignableFrom(NetworkTypeVlan.class) && providerAug.getSegmentationId() != null) { try { bridgeDomainBuilder.setVlan(new VlanId(Integer.valueOf(providerAug.getSegmentationId()))); } catch (NumberFormatException e) { LOG.error("Neutron network {}. Cannot create VLAN ID from segmentation-id: {}. {}", providerAug.getSegmentationId(), network.getUuid(), e); return null; } } return bridgeDomainBuilder.build(); } NetworkAware(DataBroker dataBroker); }
NetworkAware implements MappingProvider<Network> { @VisibleForTesting GbpBridgeDomain createGbpBridgeDomain(Network network) { GbpBridgeDomainBuilder bridgeDomainBuilder = new GbpBridgeDomainBuilder(); String description = (network.getName() != null) ? network.getName() : "Neutron network"; bridgeDomainBuilder.setDescription(description); bridgeDomainBuilder.setId(network.getUuid().getValue()); NetworkProviderExtension providerAug = network.getAugmentation(NetworkProviderExtension.class); if (providerAug == null || providerAug.getNetworkType() == null) { LOG.warn("Cannot create VPP bridge domain. Network type not specified in neutron network: {}", network); return null; } Class<? extends NetworkTypeBase> netType = convertNetworkType(providerAug.getNetworkType()); if (netType == null) { return null; } bridgeDomainBuilder.setPhysicalLocationRef(resolveDomainLocations(providerAug)); bridgeDomainBuilder.setType(netType); if (providerAug.getNetworkType().isAssignableFrom(NetworkTypeVlan.class) && providerAug.getSegmentationId() != null) { try { bridgeDomainBuilder.setVlan(new VlanId(Integer.valueOf(providerAug.getSegmentationId()))); } catch (NumberFormatException e) { LOG.error("Neutron network {}. Cannot create VLAN ID from segmentation-id: {}. {}", providerAug.getSegmentationId(), network.getUuid(), e); return null; } } return bridgeDomainBuilder.build(); } NetworkAware(DataBroker dataBroker); @Override InstanceIdentifier<Network> getNeutronDtoIid(); @Override void processCreatedNeutronDto(Network network); static Class<? extends NetworkTypeBase> convertNetworkType(
            Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase> base); @Override void processUpdatedNeutronDto(Network originalNetwork, Network updatedNetwork); @Override void processDeletedNeutronDto(Network network); }
NetworkAware implements MappingProvider<Network> { @VisibleForTesting GbpBridgeDomain createGbpBridgeDomain(Network network) { GbpBridgeDomainBuilder bridgeDomainBuilder = new GbpBridgeDomainBuilder(); String description = (network.getName() != null) ? network.getName() : "Neutron network"; bridgeDomainBuilder.setDescription(description); bridgeDomainBuilder.setId(network.getUuid().getValue()); NetworkProviderExtension providerAug = network.getAugmentation(NetworkProviderExtension.class); if (providerAug == null || providerAug.getNetworkType() == null) { LOG.warn("Cannot create VPP bridge domain. Network type not specified in neutron network: {}", network); return null; } Class<? extends NetworkTypeBase> netType = convertNetworkType(providerAug.getNetworkType()); if (netType == null) { return null; } bridgeDomainBuilder.setPhysicalLocationRef(resolveDomainLocations(providerAug)); bridgeDomainBuilder.setType(netType); if (providerAug.getNetworkType().isAssignableFrom(NetworkTypeVlan.class) && providerAug.getSegmentationId() != null) { try { bridgeDomainBuilder.setVlan(new VlanId(Integer.valueOf(providerAug.getSegmentationId()))); } catch (NumberFormatException e) { LOG.error("Neutron network {}. Cannot create VLAN ID from segmentation-id: {}. {}", providerAug.getSegmentationId(), network.getUuid(), e); return null; } } return bridgeDomainBuilder.build(); } NetworkAware(DataBroker dataBroker); @Override InstanceIdentifier<Network> getNeutronDtoIid(); @Override void processCreatedNeutronDto(Network network); static Class<? extends NetworkTypeBase> convertNetworkType(
            Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeBase> base); @Override void processUpdatedNeutronDto(Network originalNetwork, Network updatedNetwork); @Override void processDeletedNeutronDto(Network network);  }