X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Ftranslator%2FPortUpdateTranslator.java;h=686744c50895f4b1916cee303b2963ed96286d59;hb=073bd43ec02317e3bb5f47b37e38c4490c35ecbc;hp=6c35a2a50ec6692c994ef4fe15d72e3329549289;hpb=0f9364b3c813fe3b162c09851261dca33bbda9fc;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java index 6c35a2a50e..686744c508 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java @@ -9,40 +9,49 @@ package org.opendaylight.openflowplugin.impl.translator; import java.util.Collections; import org.opendaylight.openflowplugin.api.OFConstants; -import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; -import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator; -import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil; +import org.opendaylight.openflowplugin.impl.util.PortTranslatorUtil; 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.types.port.rev130925.PortNumberUni; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -/** - * @author tkubas - */ public class PortUpdateTranslator implements MessageTranslator { + private static final Logger LOG = LoggerFactory.getLogger(PortUpdateTranslator.class); @Override public FlowCapableNodeConnector translate(final PortGrouping input, - final DeviceState deviceState, final Object connectionDistinguisher) { + final DeviceInfo deviceInfo, final Object connectionDistinguisher) { final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder(); //OF1.0 - if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_0) { + if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_0) { builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeaturesV10())); builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfigV10())); builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeaturesV10())); builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeaturesV10())); builder.setState(PortTranslatorUtil.translatePortState(input.getStateV10())); builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeaturesV10())); - } else if (deviceState.getVersion() == OFConstants.OFP_VERSION_1_3) { + } else if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_3) { builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeatures())); builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfig())); builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeatures())); builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeatures())); builder.setState(PortTranslatorUtil.translatePortState(input.getState())); builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeatures())); - builder.setQueue(Collections.emptyList()); + builder.setQueue(Collections + .emptyList()); + } + if (input instanceof PortStatusMessage) { + if (((PortStatusMessage) input).getReason() != null) { + builder.setReason(PortReason.forValue(((PortStatusMessage) input).getReason().getIntValue())); + } else { + LOG.debug("PortStatus Message has reason as null"); + } } builder.setCurrentSpeed(input.getCurrSpeed()); builder.setHardwareAddress(input.getHwAddr());