2 * Copyright (c) 2013 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
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11 import java.util.List;
13 import org.opendaylight.controller.sal.reader.NodeDescription;
14 import org.openflow.protocol.statistics.OFDescriptionStatistics;
15 import org.openflow.protocol.statistics.OFStatistics;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * Utility class for converting openflow description statistics into SAL
21 * NodeDescription object
23 public class DescStatisticsConverter {
24 private static final Logger log = LoggerFactory
25 .getLogger(DescStatisticsConverter.class);
26 NodeDescription hwDesc;
27 OFDescriptionStatistics ofDesc;
29 public DescStatisticsConverter(List<OFStatistics> statsList) {
31 this.ofDesc = (statsList == null || statsList.isEmpty())?
32 null : (OFDescriptionStatistics) statsList.get(0);
34 public DescStatisticsConverter(OFDescriptionStatistics desc) {
39 public NodeDescription getHwDescription() {
40 if (hwDesc == null && ofDesc != null) {
41 hwDesc = new NodeDescription();
42 hwDesc.setManufacturer(ofDesc.getManufacturerDescription());
43 hwDesc.setHardware(ofDesc.getHardwareDescription());
44 hwDesc.setSoftware(ofDesc.getSoftwareDescription());
45 hwDesc.setDescription(ofDesc.getDatapathDescription());
46 hwDesc.setSerialNumber(ofDesc.getSerialNumber());
48 log.trace("OFDescriptionStatistics: {}", ofDesc);
49 log.trace("NodeDescription: {}", hwDesc);