Null pointer exception handled at neutronvpn exceptions.
Along with that other null ponter also handled seen during CSIT.
Signed-off-by: Nishchya Gupta <nishchyag@altencalsoftlabs.com>
Change-Id: Idac487428c9f557bb4358855c882a56ebb70dec4
interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
} else if (isDhcpServerPort) {
Set<FixedIps> oldIPs = getFixedIpSet(
- new ArrayList<FixedIps>(original.getFixedIps().values()));
+ new ArrayList<FixedIps>(original.nonnullFixedIps().values()));
Set<FixedIps> newIPs = getFixedIpSet(
- new ArrayList<FixedIps>(update.getFixedIps().values()));
+ new ArrayList<FixedIps>(update.nonnullFixedIps().values()));
if (!oldIPs.equals(newIPs)) {
InterfaceAcl infAcl = neutronvpnUtils.getDhcpInterfaceAcl(update);
interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
// populate floating-ip uuid and floating-ip port attributes (uuid, mac and subnet id for the ONLY
// fixed IP) to be used by NAT, depopulated in NATService once mac is retrieved in the removal path
addToFloatingIpPortInfo(new Uuid(update.getDeviceId()), update.getUuid(),
- new ArrayList<FixedIps>(update.getFixedIps().values()).get(0)
+ new ArrayList<FixedIps>(update.nonnullFixedIps().values()).get(0)
.getSubnetId(), update.getMacAddress().getValue());
elanService.addKnownL3DmacAddress(update.getMacAddress().getValue(), update.getNetworkId().getValue());
}
private void handleNeutronPortUpdated(final Port portoriginal, final Port portupdate) {
- final Map<FixedIpsKey, FixedIps> portoriginalIpsMap = portoriginal.getFixedIps();
- final Map<FixedIpsKey, FixedIps> portupdateIpsMap = portupdate.getFixedIps();
+ final Map<FixedIpsKey, FixedIps> portoriginalIpsMap = portoriginal.nonnullFixedIps();
+ final Map<FixedIpsKey, FixedIps> portupdateIpsMap = portupdate.nonnullFixedIps();
if (portoriginalIpsMap == null || portoriginalIpsMap.isEmpty()) {
handleNeutronPortCreated(portupdate);
return;
NeutronvpnUtils.getUpdatedSecurityGroups(interfaceAcl.getSecurityGroups(),
portOriginal.getSecurityGroups(), portUpdated.getSecurityGroups()));
List<AllowedAddressPairs> updatedAddressPairs = NeutronvpnUtils.getUpdatedAllowedAddressPairs(
- new ArrayList<AllowedAddressPairs>(interfaceAcl.getAllowedAddressPairs().values()),
- new ArrayList<>(portOriginal.getAllowedAddressPairs().values()),
+ new ArrayList<AllowedAddressPairs>(interfaceAcl.nonnullAllowedAddressPairs().values()),
+ new ArrayList<>(portOriginal.nonnullAllowedAddressPairs().values()),
new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port
- .attributes.AllowedAddressPairs>(portUpdated.getAllowedAddressPairs().values()));
+ .attributes.AllowedAddressPairs>(portUpdated.nonnullAllowedAddressPairs().values()));
interfaceAclBuilder.setAllowedAddressPairs(NeutronvpnUtils.getAllowedAddressPairsForFixedIps(
updatedAddressPairs, portOriginal.getMacAddress(), portOriginal.getFixedIps(),
- portUpdated.getFixedIps().values()));
+ portUpdated.nonnullFixedIps().values()));
if (portOriginal.getFixedIps() != null
&& !portOriginal.getFixedIps().equals(portUpdated.getFixedIps())) {
on vpn operational data to release Lport tag in case of L3VPN over VxLAN*/
if (input.getExternalGatewayInfo() != null) {
Uuid extNetId = input.getExternalGatewayInfo().getExternalNetworkId();
- List<ExternalFixedIps> externalFixedIps
- = new ArrayList<ExternalFixedIps>(input.getExternalGatewayInfo().getExternalFixedIps().values());
+ List<ExternalFixedIps> externalFixedIps = new ArrayList<ExternalFixedIps>(input
+ .getExternalGatewayInfo().nonnullExternalFixedIps().values());
jobCoordinator.enqueueJob(input.getUuid().toString(), () -> {
nvpnNatManager.removeExternalNetworkFromRouter(extNetId, input, externalFixedIps);
return Collections.emptyList();
Uuid vpnId = input.getVpnId();
Map<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.associaterouter
.input.RouterIdsKey, org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602
- .associaterouter.input.RouterIds> keyRouterIdsMap = input.getRouterIds();
+ .associaterouter.input.RouterIds> keyRouterIdsMap = input.nonnullRouterIds();
Preconditions.checkArgument(!keyRouterIdsMap.isEmpty(), "associateRouter: RouterIds list is empty!");
Preconditions.checkNotNull(vpnId, "associateRouter; VpnId not found!");
Preconditions.checkNotNull(vpnId, "associateRouter; RouterIds not found!");
Uuid vpnId = input.getVpnId();
Map<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.dissociaterouter.input
.RouterIdsKey, org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602
- .dissociaterouter.input.RouterIds> keyRouterIdsMap = input.getRouterIds();
+ .dissociaterouter.input.RouterIds> keyRouterIdsMap = input.nonnullRouterIds();
String routerIdsString = "";
Preconditions.checkArgument(!keyRouterIdsMap.isEmpty(), "dissociateRouter: RouterIds list is empty!");
Preconditions.checkNotNull(vpnId, "dissociateRouter: vpnId not found!");
if (extNetChanged == EXTERNAL_REMOVED) {
origExtNetId = original.getExternalGatewayInfo().getExternalNetworkId();
origExtFixedIps = new ArrayList<ExternalFixedIps>(original.getExternalGatewayInfo()
- .getExternalFixedIps().values());
+ .nonnullExternalFixedIps().values());
LOG.trace("External Network removal detected for router {}", routerId.getValue());
removeExternalNetworkFromRouter(origExtNetId, update, origExtFixedIps);
//gateway mac unset handled as part of gateway clear deleting top-level routers node
origExtNetId = original.getExternalGatewayInfo().getExternalNetworkId();
origExtFixedIps = new ArrayList<ExternalFixedIps>(original.getExternalGatewayInfo()
- .getExternalFixedIps().values());
+ .nonnullExternalFixedIps().values());
updExtNetId = update.getExternalGatewayInfo().getExternalNetworkId();
LOG.trace("External Network changed from {} to {} for router {}",
origExtNetId.getValue(), updExtNetId.getValue(), routerId.getValue());
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
Map<ExternalFixedIpsKey, ExternalFixedIps> keyExternalFixedIpsMap
- = update.getExternalGatewayInfo().getExternalFixedIps();
+ = update.getExternalGatewayInfo().nonnullExternalFixedIps();
try {
Network input = neutronvpnUtils.getNeutronNetwork(extNetId);
if (optionalRouters.isPresent()) {
RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
List<ExternalIps> externalIps = new ArrayList<>();
- for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().getExternalFixedIps().values()) {
+ for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().nonnullExternalFixedIps().values()) {
addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
}
updateExternalSubnetsForRouter(routerId, update.getExternalGatewayInfo().getExternalNetworkId(),
new ArrayList<ExternalFixedIps>(update.getExternalGatewayInfo()
- .getExternalFixedIps().values()));
+ .nonnullExternalFixedIps().values()));
Routers routerss = builder.build();
LOG.trace("Updating external fixed ips for router {} with value {}", routerId.getValue(), routerss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier,
Optional<Adjacencies> optionalAdjacencies = SingleTransactionDataBroker.syncReadOptional(dataBroker,
LogicalDatastoreType.CONFIGURATION, adjacenciesIdentifier);
if (optionalAdjacencies.isPresent()) {
- Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().getAdjacency();
+ Map<AdjacencyKey, Adjacency> keyAdjacencyMap = optionalAdjacencies.get().nonnullAdjacency();
Iterator<Adjacency> adjacencyIter = keyAdjacencyMap.values().iterator();
while (adjacencyIter.hasNext()) {
Adjacency adjacency = adjacencyIter.next();
if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().nonnullVpnMap() != null) {
for (VpnMap vpnMap : new ArrayList<>(optionalVpnMaps.get().nonnullVpnMap().values())) {
Map<RouterIdsKey, org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602
- .vpnmaps.vpnmap.RouterIds> keyRouterIdsMap = vpnMap.getRouterIds();
+ .vpnmaps.vpnmap.RouterIds> keyRouterIdsMap = vpnMap.nonnullRouterIds();
if (keyRouterIdsMap == null || keyRouterIdsMap.isEmpty()) {
continue;
}
if (optionalVpnMap.isPresent()) {
VpnMap vpnMap = optionalVpnMap.get();
return NeutronUtils.getVpnMapRouterIdsListUuid(new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight
- .netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds>(vpnMap.getRouterIds().values()));
+ .netvirt.neutronvpn.rev150602.vpnmaps.vpnmap.RouterIds>(vpnMap.nonnullRouterIds().values()));
}
LOG.error("getRouterIdListforVpn: Failed as VPNMaps DS is absent for VPN {}", vpnId.getValue());
return null;
interfaceAclBuilder.setPortSecurityEnabled(false);
interfaceAclBuilder.setInterfaceType(InterfaceAcl.InterfaceType.DhcpService);
List<AllowedAddressPairs> aclAllowedAddressPairs = NeutronvpnUtils.getAllowedAddressPairsForAclService(
- port.getMacAddress(), new ArrayList<FixedIps>(port.getFixedIps().values()));
+ port.getMacAddress(), new ArrayList<FixedIps>(port.nonnullFixedIps().values()));
interfaceAclBuilder.setAllowedAddressPairs(aclAllowedAddressPairs);
return interfaceAclBuilder.build();
}
interfaceAclBuilder.setSecurityGroups(securityGroups);
}
List<AllowedAddressPairs> aclAllowedAddressPairs = NeutronvpnUtils.getAllowedAddressPairsForAclService(
- port.getMacAddress(), new ArrayList<FixedIps>(port.getFixedIps().values()));
+ port.getMacAddress(), new ArrayList<FixedIps>(port.nonnullFixedIps().values()));
// Update the allowed address pair with the IPv6 LLA that is auto configured on the port.
aclAllowedAddressPairs.add(NeutronvpnUtils.updateIPv6LinkLocalAddressForAclService(port.getMacAddress()));
List<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairs>
// FIXME: why are we not using getNeutronSubnet() here? it does caching for us...
Optional<Subnet> subnet = read(LogicalDatastoreType.CONFIGURATION,
NEUTRON_SUBNETS_IID.child(Subnet.class, new SubnetKey(
- new ArrayList<FixedIps>(port.getFixedIps().values()).get(0).getSubnetId())));
+ new ArrayList<FixedIps>(port.nonnullFixedIps().values()).get(0).getSubnetId())));
if (subnet.isPresent()) {
String cidr = subnet.get().getCidr().stringValue();
// Extract the prefix length from cidr
public static List<StaticMacEntries> buildStaticMacEntry(Port port) {
PhysAddress physAddress = new PhysAddress(port.getMacAddress().getValue());
- Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.getFixedIps();
+ Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
IpAddress ipAddress = null;
if (isNotEmpty(keyFixedIpsMap.values())) {
- ipAddress = new ArrayList<FixedIps>(port.getFixedIps().values()).get(0).getIpAddress();
+ ipAddress = new ArrayList<FixedIps>(port.nonnullFixedIps().values()).get(0).getIpAddress();
}
StaticMacEntriesBuilder staticMacEntriesBuilder = new StaticMacEntriesBuilder();
List<StaticMacEntries> staticMacEntries = new ArrayList<>();