File: drive.py

package info (click to toggle)
python-pyghmi 1.6.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,432 kB
  • sloc: python: 22,297; sh: 35; makefile: 20
file content (69 lines) | stat: -rwxr-xr-x 2,055 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2015 Lenovo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pyghmi.ipmi.oem.lenovo import inventory

drive_fields = (
    inventory.EntryField("index", "B"),
    inventory.EntryField("VendorID", "64s"),
    inventory.EntryField("Size", "I",
                         valuefunc=lambda v: str(v) + " MB"),
    inventory.EntryField("MediaType", "B", mapper={
        0x00: "HDD",
        0x01: "SSD"
    }),
    inventory.EntryField("InterfaceType", "B", mapper={
        0x00: "Unknown",
        0x01: "ParallelSCSI",
        0x02: "SAS",
        0x03: "SATA",
        0x04: "FC"
    }),
    inventory.EntryField("FormFactor", "B", mapper={
        0x00: "Unknown",
        0x01: "2.5in",
        0x02: "3.5in"
    }),
    inventory.EntryField("LinkSpeed", "B", mapper={
        0x00: "Unknown",
        0x01: "1.5 Gb/s",
        0x02: "3.0 Gb/s",
        0x03: "6.0 Gb/s",
        0x04: "12.0 Gb/s"
    }),
    inventory.EntryField("SlotNumber", "B"),
    inventory.EntryField("ControllerIndex", "B"),
    inventory.EntryField("DeviceState", "B", mapper={
        0x00: "active",
        0x01: "stopped",
        0xff: "transitioning"
    }))


def parse_drive_info(raw):
    return inventory.parse_inventory_category_entry(raw, drive_fields)


def get_categories():
    return {
        "drive": {
            "idstr": "Drive {0}",
            "parser": parse_drive_info,
            "command": {
                "netfn": 0x06,
                "command": 0x59,
                "data": (0x00, 0xc1, 0x04, 0x00)
            }
        }
    }