If user removed port from openflow switch, it generated port status message with reason - DELETE
But this message is not properly hooked to onNodeUpdateRemoved notification defined in inventory
models. This patch fixes the issue.
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
addMessagePopListener(TableFeaturesErrorNotification.class, notificationPopListener);
addMessagePopListener(TableModErrorNotification.class, notificationPopListener);
addMessagePopListener(NodeConnectorUpdated.class,notificationPopListener);
+ addMessagePopListener(NodeConnectorRemoved.class,notificationPopListener);
addMessagePopListener(PacketReceived.class,notificationPopListener);
addMessagePopListener(TransmitPacketInput.class, notificationPopListener);
addMessagePopListener(NodeUpdated.class, notificationPopListener);
import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.LoggerFactory;
/**
- * translates {@link PortStatusMessage} from OF-API model to MD-SAL model,
+ * translates {@link PortStatusMessage} from OF-API model to MD-SAL model,
* supports OF-{1.0; 1.3}
*/
public class PortStatusMessageToNodeConnectorUpdatedTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
BigInteger datapathId = sc.getFeatures().getDatapathId();
Long portNo = port.getPortNo();
Short version = port.getVersion();
- LOG.debug("PortStatusMessage: version {} dataPathId {} portNo {}",version, datapathId,portNo);
- list.add(PortTranslatorUtil.translatePort(version, datapathId, portNo, port));
+ if(port.getReason() == PortReason.OFPPRDELETE){
+ LOG.debug("PortStatusMessage: version {} dataPathId {} portNo {} reason {}",version, datapathId,portNo,port.getReason());
+ list.add(PortTranslatorUtil.translatePortRemoved(version, datapathId, portNo, port));
+
+ }else{
+ LOG.debug("PortStatusMessage: version {} dataPathId {} portNo {}",version, datapathId,portNo);
+ list.add(PortTranslatorUtil.translatePort(version, datapathId, portNo, port));
+ }
return list;
} else {
// TODO - Do something smarter than returning null if translation fails... what Exception should we throw here?
package org.opendaylight.openflowplugin.openflow.md.util;
import java.math.BigInteger;
+
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemovedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdatedBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
builder.addAugmentation(FlowCapableNodeConnectorUpdated.class, fcncub.build());
return builder.build();
}
+
+ public static NodeConnectorRemoved translatePortRemoved(Short version, BigInteger datapathId, Long portNumber, PortGrouping port) {
+ OpenflowVersion ofVersion = OpenflowVersion.get(version);
+ NodeConnectorRemovedBuilder builder = new NodeConnectorRemovedBuilder();
+ builder.setNodeConnectorRef(InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(datapathId, portNumber, ofVersion));
+ return builder.build();
+ }
}