abad0b2ab5d5984cee70063697f9109b297602ac
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / DescStatisticsConverter.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
10
11 import java.util.List;
12
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;
18
19 /**
20  * Utility class for converting openflow description statistics into SAL
21  * NodeDescription object
22  * 
23  * 
24  * 
25  */
26 public class DescStatisticsConverter {
27     private static final Logger log = LoggerFactory
28             .getLogger(DescStatisticsConverter.class);
29     NodeDescription hwDesc;
30     OFDescriptionStatistics ofDesc;
31
32     public DescStatisticsConverter(List<OFStatistics> statsList) {
33         this.hwDesc = null;
34         this.ofDesc = (OFDescriptionStatistics) statsList.get(0);
35     }
36
37     public NodeDescription getHwDescription() {
38         if (hwDesc == null && ofDesc != null) {
39             hwDesc = new NodeDescription();
40             hwDesc.setManufacturer(ofDesc.getManufacturerDescription());
41             hwDesc.setHardware(ofDesc.getHardwareDescription());
42             hwDesc.setSoftware(ofDesc.getSoftwareDescription());
43             hwDesc.setDescription(ofDesc.getDatapathDescription());
44             hwDesc.setSerialNumber(ofDesc.getSerialNumber());
45         }
46         log.trace("OFDescriptionStatistics: {}", ofDesc);
47         log.trace("NodeDescription: {}", hwDesc);
48         return hwDesc;
49     }
50
51 }