DellEmc(Z9264f): Bug fix in show platform psustatus cli (#3033)
This commit is contained in:
parent
dbdc166f6f
commit
8c3fdfd079
@ -7,10 +7,12 @@
|
||||
import os.path
|
||||
import logging
|
||||
import commands
|
||||
import sys
|
||||
|
||||
|
||||
Z9264F_MAX_PSUS = 2
|
||||
IPMI_SENSOR_DATA = "docker exec -it pmon ipmitool sdr list"
|
||||
IPMI_PSU_DATA = "docker exec -it pmon ipmitool sdr list"
|
||||
IPMI_PSU_DATA_DOCKER = "ipmitool sdr list"
|
||||
PSU_PRESENCE = "PSU{0}_state"
|
||||
# Use this for older firmware
|
||||
# PSU_PRESENCE="PSU{0}_prsnt"
|
||||
@ -29,14 +31,24 @@ class PsuUtil(PsuBase):
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
def isDockerEnv(self):
|
||||
num_docker = open('/proc/self/cgroup', 'r').read().count(":/docker")
|
||||
if num_docker > 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# Fetch a BMC register
|
||||
def get_pmc_register(self, reg_name):
|
||||
|
||||
status = 1
|
||||
global ipmi_sdr_list
|
||||
ipmi_dev_node = "/dev/pmi0"
|
||||
ipmi_cmd = IPMI_PSU_DATA
|
||||
dockerenv = self.isDockerEnv()
|
||||
if dockerenv == True:
|
||||
ipmi_cmd = IPMI_PSU_DATA_DOCKER
|
||||
|
||||
ipmi_cmd = IPMI_SENSOR_DATA
|
||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
||||
|
||||
if status:
|
||||
@ -56,8 +68,6 @@ class PsuUtil(PsuBase):
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
return output
|
||||
|
||||
|
||||
|
||||
def get_num_psus(self):
|
||||
"""
|
||||
Retrieves the number of PSUs available on the device
|
||||
@ -79,7 +89,6 @@ class PsuUtil(PsuBase):
|
||||
status = 1
|
||||
return status
|
||||
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
"""
|
||||
Retrieves the presence status of power supply unit (PSU) defined
|
||||
@ -95,3 +104,4 @@ class PsuUtil(PsuBase):
|
||||
if (psu_status):
|
||||
status = 1
|
||||
return status
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user