Simplify overlay information mappers and managers
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / manager / VppNodeManager.java
index 7ef74057cfbed59c3e4391d76afd9486f37af073..fb2c35aa0481fd8afd68ee73ae9b15709ffcdd82 100644 (file)
@@ -38,7 +38,8 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.mappers.HostIdToInterfaceInfoMapper;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.HostRelatedInfoContainer;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.info.container.states.PhysicalInterfaces;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.NatUtil;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
 import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppRendererProcessingException;
@@ -96,6 +97,7 @@ public class VppNodeManager {
     private final DataBroker dataBroker;
     private final List<String> requiredCapabilities;
     private final MountPointService mountService;
+    private final HostRelatedInfoContainer hostRelatedInfoContainer = HostRelatedInfoContainer.getInstance();
 
     public VppNodeManager(@Nonnull final DataBroker dataBroker,
             @Nonnull final BindingAwareBroker.ProviderContext session, @Nullable String physicalInterfaces) {
@@ -413,13 +415,20 @@ public class VppNodeManager {
                     phIface.setInterfaceName(iface.getName());
                     phIface.setType(iface.getType());
                     phIface.setAddress(resolveIpAddress(iface.getAugmentation(Interface1.class)));
+                    PhysicalInterfaces physicalInterfaces = hostRelatedInfoContainer
+                                                                        .getPhysicalInterfaceState(nodeId.getValue());
+                    if (physicalInterfaces == null) {
+                        physicalInterfaces = new PhysicalInterfaces();
+                        hostRelatedInfoContainer.setPhysicalInterfaceStateOfHost(nodeId.getValue(), physicalInterfaces);
+                    }
+
 
                     if (extInterfaces.get(nodeId) != null
                             && extInterfaces.get(nodeId).getInterfaceName().equals(phIface.getInterfaceName())) {
                         phIface.setExternal(true);
                         extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
-                        HostIdToInterfaceInfoMapper.getInstance()
-                                .addInterfaceInfo(nodeId.getValue(), HostIdToInterfaceInfoMapper.InterfaceType.PUBLIC,
+                        physicalInterfaces
+                                .addPhysicalInterfaceInfo(PhysicalInterfaces.PhysicalInterfaceType.PUBLIC,
                                         phIface.getInterfaceName(), phIface.getAddress().get(0));
                         LOG.info("Interface {} is marked as public interface based on bundle configuration.",
                                 iface.getName());
@@ -427,8 +436,8 @@ public class VppNodeManager {
                     if (PUBLIC_INTERFACE.equals(iface.getDescription())) {
                         phIface.setExternal(true);
                         extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
-                        HostIdToInterfaceInfoMapper.getInstance()
-                                .addInterfaceInfo(nodeId.getValue(), HostIdToInterfaceInfoMapper.InterfaceType.PUBLIC,
+                        physicalInterfaces
+                                .addPhysicalInterfaceInfo(PhysicalInterfaces.PhysicalInterfaceType.PUBLIC,
                                         phIface.getInterfaceName(), phIface.getAddress().get(0));
                         LOG.info("Interface {} is marked as public interface based on HC configuration.",
                                 iface.getName());