Skip to content

Commit 8c3fdfd

Browse files
gengankarthikjleveque
authored andcommitted
DellEmc(Z9264f): Bug fix in show platform psustatus cli (#3033)
1 parent dbdc166 commit 8c3fdfd

File tree

1 file changed

+18
-8
lines changed
  • device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins

1 file changed

+18
-8
lines changed

device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/psuutil.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import os.path
88
import logging
99
import commands
10+
import sys
1011

1112

1213
Z9264F_MAX_PSUS = 2
13-
IPMI_SENSOR_DATA = "docker exec -it pmon ipmitool sdr list"
14+
IPMI_PSU_DATA = "docker exec -it pmon ipmitool sdr list"
15+
IPMI_PSU_DATA_DOCKER = "ipmitool sdr list"
1416
PSU_PRESENCE = "PSU{0}_state"
1517
# Use this for older firmware
1618
# PSU_PRESENCE="PSU{0}_prsnt"
@@ -29,14 +31,24 @@ class PsuUtil(PsuBase):
2931
def __init__(self):
3032
PsuBase.__init__(self)
3133

34+
def isDockerEnv(self):
35+
num_docker = open('/proc/self/cgroup', 'r').read().count(":/docker")
36+
if num_docker > 0:
37+
return True
38+
else:
39+
return False
40+
3241
# Fetch a BMC register
3342
def get_pmc_register(self, reg_name):
3443

3544
status = 1
3645
global ipmi_sdr_list
3746
ipmi_dev_node = "/dev/pmi0"
47+
ipmi_cmd = IPMI_PSU_DATA
48+
dockerenv = self.isDockerEnv()
49+
if dockerenv == True:
50+
ipmi_cmd = IPMI_PSU_DATA_DOCKER
3851

39-
ipmi_cmd = IPMI_SENSOR_DATA
4052
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
4153

4254
if status:
@@ -48,16 +60,14 @@ def get_pmc_register(self, reg_name):
4860
output = item.strip()
4961

5062
if not output:
51-
print('\nFailed to fetch: ' + reg_name + ' sensor ')
63+
print('\nFailed to fetch: ' + reg_name + ' sensor ')
5264
sys.exit(0)
5365

5466
output = output.split('|')[1]
5567

5668
logging.basicConfig(level=logging.DEBUG)
5769
return output
5870

59-
60-
6171
def get_num_psus(self):
6272
"""
6373
Retrieves the number of PSUs available on the device
@@ -74,11 +84,10 @@ def get_psu_status(self, index):
7484
:return: Boolean, True if PSU is operating properly, False if PSU is\
7585
faulty
7686
"""
77-
#Until psu_status is implemented this is hardcoded temporarily
87+
# Until psu_status is implemented this is hardcoded temporarily
7888

7989
status = 1
8090
return status
81-
8291

8392
def get_psu_presence(self, index):
8493
"""
@@ -89,9 +98,10 @@ def get_psu_presence(self, index):
8998
"""
9099
status = 0
91100
psu_reg_name = PSU_PRESENCE.format(index)
92-
psu_status = int(self.get_pmc_register(psu_reg_name),16)
101+
psu_status = int(self.get_pmc_register(psu_reg_name), 16)
93102
if (psu_status != 'ERR'):
94103
# Check for PSU presence
95104
if (psu_status):
96105
status = 1
97106
return status
107+

0 commit comments

Comments
 (0)