2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.translator;
10 import java.util.Collections;
11 import org.opendaylight.openflowplugin.api.OFConstants;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
13 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
14 import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
23 public class PortUpdateTranslator implements MessageTranslator<PortGrouping, FlowCapableNodeConnector> {
26 public FlowCapableNodeConnector translate(final PortGrouping input,
27 final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
28 final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
30 if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_0) {
31 builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeaturesV10()));
32 builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfigV10()));
33 builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeaturesV10()));
34 builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeaturesV10()));
35 builder.setState(PortTranslatorUtil.translatePortState(input.getStateV10()));
36 builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeaturesV10()));
37 } else if (deviceInfo.getVersion() == OFConstants.OFP_VERSION_1_3) {
38 builder.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(input.getAdvertisedFeatures()));
39 builder.setConfiguration(PortTranslatorUtil.translatePortConfig(input.getConfig()));
40 builder.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(input.getCurrentFeatures()));
41 builder.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(input.getPeerFeatures()));
42 builder.setState(PortTranslatorUtil.translatePortState(input.getState()));
43 builder.setSupported(PortTranslatorUtil.translatePortFeatures(input.getSupportedFeatures()));
44 builder.setQueue(Collections.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue>emptyList());
46 builder.setCurrentSpeed(input.getCurrSpeed());
47 builder.setHardwareAddress(input.getHwAddr());
48 builder.setMaximumSpeed(input.getMaxSpeed());
49 builder.setName(input.getName());
50 builder.setPortNumber(new PortNumberUni(input.getPortNo()));
52 return builder.build();