use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.dpn.routers.list.RoutersListBuilder in project netvirt by opendaylight.
the class NatUtil method addToDpnRoutersMap.
public static void addToDpnRoutersMap(DataBroker broker, String routerName, String interfaceName, BigInteger dpId, WriteTransaction writeOperTxn) {
if (dpId.equals(BigInteger.ZERO)) {
LOG.error("addToDpnRoutersMap : Could not retrieve dp id for interface {} to handle router {} " + "association model", interfaceName, routerName);
return;
}
LOG.debug("addToDpnRoutersMap : Adding the DPN {} and router {} for the Interface {} in the ODL-L3VPN : " + "DPNRouters map", dpId, routerName, interfaceName);
InstanceIdentifier<DpnRoutersList> dpnRoutersListIdentifier = getDpnRoutersId(dpId);
Optional<DpnRoutersList> optionalDpnRoutersList = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(broker, LogicalDatastoreType.OPERATIONAL, dpnRoutersListIdentifier);
if (optionalDpnRoutersList.isPresent()) {
RoutersList routersList = new RoutersListBuilder().setKey(new RoutersListKey(routerName)).setRouter(routerName).build();
List<RoutersList> routersListFromDs = optionalDpnRoutersList.get().getRoutersList();
if (!routersListFromDs.contains(routersList)) {
LOG.debug("addToDpnRoutersMap : Router {} not present for the DPN {}" + " in the ODL-L3VPN : DPNRouters map", routerName, dpId);
writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, dpnRoutersListIdentifier.child(RoutersList.class, new RoutersListKey(routerName)), routersList, true);
} else {
LOG.debug("addToDpnRoutersMap : Router {} already mapped to the DPN {} in the ODL-L3VPN : " + "DPNRouters map", routerName, dpId);
}
} else {
LOG.debug("addToDpnRoutersMap : Building new DPNRoutersList for the Router {} present in the DPN {} " + "ODL-L3VPN : DPNRouters map", routerName, dpId);
DpnRoutersListBuilder dpnRoutersListBuilder = new DpnRoutersListBuilder();
dpnRoutersListBuilder.setDpnId(dpId);
RoutersListBuilder routersListBuilder = new RoutersListBuilder();
routersListBuilder.setRouter(routerName);
dpnRoutersListBuilder.setRoutersList(Collections.singletonList(routersListBuilder.build()));
writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, getDpnRoutersId(dpId), dpnRoutersListBuilder.build(), true);
}
}
Aggregations