forked from alibaba-archive/alibabacloud-tool-bmc-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhal_bmc.py
86 lines (71 loc) · 2.15 KB
/
hal_bmc.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
###############################################################################
#
# Hardware Abstraction Layer APIs -- BMC APIs.
#
# Copyright (C) Alibaba, INC.
#
###############################################################################
"""
class for HAL BMC APIs
"""
class HalBmc(object):
def __init__(self):
pass
def get_info(self):
"""
Get BMC info
@return dict of BMC info or None for failure
{
"Version": "1.1.1", # "N/A"
"Flash": "master", # "N/A"
"Next": "master" # "N/A"
}
"""
def get_version_all(self):
"""
@return dict of BMCs
{
"MasterVersion": "1.1.1", # "N/A"
"SlaveVersion": "1.1.1" # "N/A"
}
"""
pass
def get_status(self):
"""
Get BMC system status
@return dict of system status or None for failure
# "N/A" for invalid outpouts
{
"CPU": {
"StateOutputs": "output of command 'top -bn 1'"
"Usage": "10.0"
},
"MEMORY": {
"StateOutputs": "output of command 'free -m'"
"Usage": "15.0" # caculate: "free -t | grep \"buffers/cache\" | awk '{ printf \"mem usage : %.1f%%\\n\",$3/($3+$4) * 100}'"
},
"DISK": {
"StateOutput": "output of command 'df -h'"
"Usage": "12.5"
}
}
"""
pass
def get_next_boot(self):
"""
Get next booting flash of BMC
@return 'master'/'slave' on success, "N/A" for failure
"""
pass
def set_next_boot(self, flash):
"""
Set flash from which next BMC boot
@param flash Booting flash of BMC, "master" or "slave"
@return 0 on success, -1 for failure
"""
pass
def reboot(self):
"""
Reboot running BMC
"""
pass