- At switch connection, InventoryServiceShim mistakenly skips to
inform the global listeners if no ports are configured on the switch.
This is not visible with software switches because they always
advertise they have the OFLocal port active.
Being Connection Service a listener of global inventory service,
it will not get to know about the switch presence, and in subsequent
queries from InventoryServiceShim it will reply the switch is not
locally connected to this controller, causing Inventory Shim to
not inform its upper layer listeners about the switch. Therefore
no other controller service will get to know the switch is conencted.
Change-Id: I29f658cc2a84ab7aab2c19ae9fe4d5a33c0afe0c
Signed-off-by: Alessandro Boch <aboch@cisco.com>
package org.opendaylight.controller.protocol_plugin.openflow.internal;
import java.util.ArrayList;
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;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@Override
public void switchAdded(ISwitch sw) {
if (sw == null) {
@Override
public void switchAdded(ISwitch sw) {
if (sw == null) {
+ logger.debug("Ignore null switch addition");
return;
}
Node node = NodeCreator.createOFNode(sw.getId());
return;
}
Node node = NodeCreator.createOFNode(sw.getId());
- // Add all the nodeConnectors of this switch
- Map<NodeConnector, Set<Property>> ncProps = InventoryServiceHelper
- .OFSwitchToProps(sw);
- for (Map.Entry<NodeConnector, Set<Property>> entry : ncProps.entrySet()) {
- Set<Property> props = new HashSet<Property>();
- Set<Property> prop = entry.getValue();
- if (prop != null) {
- props.addAll(prop);
+ // Add all the nodeConnectors of this switch if any
+ Map<NodeConnector, Set<Property>> ncProps = InventoryServiceHelper.OFSwitchToProps(sw);
+ if (!ncProps.isEmpty()) {
+ for (Map.Entry<NodeConnector, Set<Property>> entry : ncProps.entrySet()) {
+ Set<Property> props = new HashSet<Property>();
+ Set<Property> 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.<Property>emptySet());