- Optional<SubnetOpDataEntry> optionalSubs = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
- subOpIdentifier);
- if (!optionalSubs.isPresent()) {
- LOG.info("{} onPortAddedToSubnet: Port {} is part of a subnet {} that is not in VPN, ignoring",
- LOGGING_PREFIX, portId.getValue(), subnetId.getValue());
- return;
- }
- String vpnName = optionalSubs.get().getVpnName();
- String subnetIp = optionalSubs.get().getSubnetCidr();
- String rd = optionalSubs.get().getVrfId();
- String routeAdvState = optionalSubs.get().getRouteAdvState().toString();
- LOG.info("{} onPortAddedToSubnet: Port {} being added to subnet {} subnetIp {} vpnName {} rd {} "
- + "TaskState {}", LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp,
- vpnName, rd, routeAdvState);
- subOpDpnManager.addPortOpDataEntry(portId.getValue(), subnetId, null);
- Interface intfState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker,portId.getValue());
- if (intfState == null) {
- // Interface State not yet available
- return;
- }
- final BigInteger dpnId;
- try {
- dpnId = InterfaceUtils.getDpIdFromInterface(intfState);
- } catch (Exception e) {
- LOG.error("{} onPortAddedToSubnet: Unable to obtain dpnId for interface {}. subnetroute inclusion"
- + " for this interface failed for subnet {} subnetIp {} vpn {} rd {}",
- LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd, e);
- return;
- }
- if (dpnId.equals(BigInteger.ZERO)) {
- LOG.error("{} onPortAddedToSubnet: Port {} is not assigned DPN yet, ignoring subnetRoute "
- + "inclusion for the interface into subnet {} subnetIp {} vpnName {} rd {}",
- LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd);
- return;
- }
- subOpDpnManager.addPortOpDataEntry(portId.getValue(), subnetId, dpnId);
- if (intfState.getOperStatus() != OperStatus.Up) {
- LOG.error("{} onPortAddedToSubnet: Port {} is not UP yet, ignoring subnetRoute inclusion for "
- + "the interface into subnet {} subnetIp {} vpnName {} rd {}", LOGGING_PREFIX,
- portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd);
- return;
- }
- LOG.debug("{} onPortAddedToSubnet: Port {} added. Updating the SubnetOpDataEntry node for subnet {} "
- + "subnetIp {} vpnName {} rd {} TaskState {}", LOGGING_PREFIX, portId.getValue(),
- subnetId.getValue(), subnetIp, vpnName, rd, routeAdvState);
- SubnetToDpn subDpn = subOpDpnManager.addInterfaceToDpn(subnetId, dpnId, portId.getValue());
- if (subDpn == null) {
- LOG.error("{} onPortAddedToSubnet: subnet-to-dpn list is null for subnetId {}. portId {}, "
- + "vpnName {}, rd {}, subnetIp {}", LOGGING_PREFIX, subnetId.getValue(),
- portId.getValue(), vpnName, rd, subnetIp);
- return;
- }
- SubnetOpDataEntry subnetOpDataEntry = optionalSubs.get();
- SubnetOpDataEntryBuilder subOpBuilder = new SubnetOpDataEntryBuilder(subnetOpDataEntry);
- List<SubnetToDpn> subDpnList = subOpBuilder.getSubnetToDpn();
- subDpnList.add(subDpn);
- subOpBuilder.setSubnetToDpn(subDpnList);
- if (subOpBuilder.getRouteAdvState() != TaskState.Advertised) {
- if (subOpBuilder.getNhDpnId() == null) {
- // No nexthop selected yet, elect one now
- electNewDpnForSubnetRoute(subOpBuilder, null /* oldDpnId */, subnetId,
- subnetmap.getNetworkId(), true);
- } else if (!VpnUtil.isExternalSubnetVpn(subnetOpDataEntry.getVpnName(), subnetId.getValue())) {
- // Already nexthop has been selected, only publishing to bgp required, so publish to bgp
- getNexthopTepAndPublishRoute(subOpBuilder, subnetId);
- }
+ Optional<SubnetOpDataEntry> optionalSubs = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.OPERATIONAL, subOpIdentifier);
+ if (!optionalSubs.isPresent()) {
+ LOG.info("{} onPortAddedToSubnet: Port {} is part of a subnet {} that is not in VPN, ignoring",
+ LOGGING_PREFIX, portId.getValue(), subnetId.getValue());
+ return;
+ }
+ String vpnName = optionalSubs.get().getVpnName();
+ String subnetIp = optionalSubs.get().getSubnetCidr();
+ String rd = optionalSubs.get().getVrfId();
+ String routeAdvState = optionalSubs.get().getRouteAdvState().toString();
+ LOG.info("{} onPortAddedToSubnet: Port {} being added to subnet {} subnetIp {} vpnName {} rd {} "
+ + "TaskState {}", LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp,
+ vpnName, rd, routeAdvState);
+ subOpDpnManager.addPortOpDataEntry(portId.getValue(), subnetId, null);
+ Interface intfState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker,portId.getValue());
+ if (intfState == null) {
+ // Interface State not yet available
+ return;
+ }
+ final BigInteger dpnId;
+ try {
+ dpnId = InterfaceUtils.getDpIdFromInterface(intfState);
+ } catch (Exception e) {
+ LOG.error("{} onPortAddedToSubnet: Unable to obtain dpnId for interface {}. subnetroute inclusion"
+ + " for this interface failed for subnet {} subnetIp {} vpn {} rd {}",
+ LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd, e);
+ return;
+ }
+ if (dpnId.equals(BigInteger.ZERO)) {
+ LOG.error("{} onPortAddedToSubnet: Port {} is not assigned DPN yet, ignoring subnetRoute "
+ + "inclusion for the interface into subnet {} subnetIp {} vpnName {} rd {}",
+ LOGGING_PREFIX, portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd);
+ return;
+ }
+ subOpDpnManager.addPortOpDataEntry(portId.getValue(), subnetId, dpnId);
+ if (intfState.getOperStatus() != OperStatus.Up) {
+ LOG.error("{} onPortAddedToSubnet: Port {} is not UP yet, ignoring subnetRoute inclusion for "
+ + "the interface into subnet {} subnetIp {} vpnName {} rd {}", LOGGING_PREFIX,
+ portId.getValue(), subnetId.getValue(), subnetIp, vpnName, rd);
+ return;
+ }
+ LOG.debug("{} onPortAddedToSubnet: Port {} added. Updating the SubnetOpDataEntry node for subnet {} "
+ + "subnetIp {} vpnName {} rd {} TaskState {}", LOGGING_PREFIX, portId.getValue(),
+ subnetId.getValue(), subnetIp, vpnName, rd, routeAdvState);
+ SubnetToDpn subDpn = subOpDpnManager.addInterfaceToDpn(subnetId, dpnId, portId.getValue());
+ if (subDpn == null) {
+ LOG.error("{} onPortAddedToSubnet: subnet-to-dpn list is null for subnetId {}. portId {}, "
+ + "vpnName {}, rd {}, subnetIp {}", LOGGING_PREFIX, subnetId.getValue(),
+ portId.getValue(), vpnName, rd, subnetIp);
+ return;
+ }
+ SubnetOpDataEntry subnetOpDataEntry = optionalSubs.get();
+ SubnetOpDataEntryBuilder subOpBuilder = new SubnetOpDataEntryBuilder(subnetOpDataEntry);
+ List<SubnetToDpn> subDpnList = subOpBuilder.getSubnetToDpn();
+ subDpnList.add(subDpn);
+ subOpBuilder.setSubnetToDpn(subDpnList);
+ if (subOpBuilder.getRouteAdvState() != TaskState.Advertised) {
+ if (subOpBuilder.getNhDpnId() == null) {
+ // No nexthop selected yet, elect one now
+ electNewDpnForSubnetRoute(subOpBuilder, null /* oldDpnId */, subnetId,
+ subnetmap.getNetworkId(), true);
+ } else if (!VpnUtil.isExternalSubnetVpn(subnetOpDataEntry.getVpnName(), subnetId.getValue())) {
+ // Already nexthop has been selected, only publishing to bgp required, so publish to bgp
+ getNexthopTepAndPublishRoute(subOpBuilder, subnetId);