OpenDaylight Controller functional modules.
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / DescStatisticsConverter.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.internal;
11
12 import java.util.List;
13
14 import org.openflow.protocol.statistics.OFDescriptionStatistics;
15 import org.openflow.protocol.statistics.OFStatistics;
16
17 import org.opendaylight.controller.sal.reader.NodeDescription;
18
19 /**
20  * Utility class for converting openflow description statistics
21  * into SAL NodeDescription object
22  *
23  *
24  *
25  */
26 public class DescStatisticsConverter {
27     NodeDescription hwDesc;
28     OFDescriptionStatistics ofDesc;
29
30     public DescStatisticsConverter(List<OFStatistics> statsList) {
31         this.hwDesc = null;
32         this.ofDesc = (OFDescriptionStatistics) statsList.get(0);
33     }
34
35     public NodeDescription getHwDescription() {
36         if (hwDesc == null && ofDesc != null) {
37             hwDesc = new NodeDescription();
38             hwDesc.setManufacturer(ofDesc.getManufacturerDescription());
39             hwDesc.setHardware(ofDesc.getHardwareDescription());
40             hwDesc.setSoftware(ofDesc.getSoftwareDescription());
41             hwDesc.setSdnProtocolDescription(ofDesc.getDatapathDescription());
42             hwDesc.setSerialNumber(ofDesc.getSerialNumber());
43         }
44         return hwDesc;
45     }
46
47 }