X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FInventoryServiceShim.java;h=2b26ecb749447aa3e31648c3d425f641a11a82e2;hb=3037a8b4158f8e4dbb891047180c5b1a9a0e053b;hp=f4843cf8283f36f2dc4ae957c2e46c42d363e4d6;hpb=350dbdeb0a3d942ba532ada1d1931baf591bec5b;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java index f4843cf828..2b26ecb749 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.protocol_plugin.openflow.internal; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -238,6 +239,7 @@ public class InventoryServiceShim implements IContainerListener, @Override public void switchAdded(ISwitch sw) { if (sw == null) { + logger.debug("Ignore null switch addition"); return; } Node node = NodeCreator.createOFNode(sw.getId()); @@ -246,17 +248,24 @@ public class InventoryServiceShim implements IContainerListener, return; } - // Add all the nodeConnectors of this switch - Map> ncProps = InventoryServiceHelper - .OFSwitchToProps(sw); - for (Map.Entry> entry : ncProps.entrySet()) { - Set props = new HashSet(); - Set prop = entry.getValue(); - if (prop != null) { - props.addAll(prop); + // Add all the nodeConnectors of this switch if any + Map> ncProps = InventoryServiceHelper.OFSwitchToProps(sw); + if (!ncProps.isEmpty()) { + for (Map.Entry> entry : ncProps.entrySet()) { + Set props = new HashSet(); + Set prop = entry.getValue(); + if (prop != null) { + props.addAll(prop); + } + nodeConnectorProps.put(entry.getKey(), props); + notifyInventoryShimListener(entry.getKey(), UpdateType.ADDED, entry.getValue()); } - nodeConnectorProps.put(entry.getKey(), props); - notifyInventoryShimListener(entry.getKey(), UpdateType.ADDED, entry.getValue()); + } else { + /* + * If no node connector is present, publish the node addition itself + * in order to let Connection Manager properly set the node locality + */ + this.notifyInventoryShimListener(node, UpdateType.ADDED, Collections.emptySet()); } // Add this node