Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DellEmc(Z9264f): Bug fix in show platform psustatus cli #3033

Merged
merged 4 commits into from
Jun 28, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,14 +31,24 @@ class PsuUtil(PsuBase):
def __init__(self):
PsuBase.__init__(self)

def isDockerEnv(self):
jleveque marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand All @@ -48,16 +60,14 @@ def get_pmc_register(self, reg_name):
output = item.strip()

if not output:
print('\nFailed to fetch: ' + reg_name + ' sensor ')
print('\nFailed to fetch: ' + reg_name + ' sensor ')
sys.exit(0)

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

logging.basicConfig(level=logging.DEBUG)
return output



def get_num_psus(self):
"""
Retrieves the number of PSUs available on the device
Expand All @@ -74,11 +84,10 @@ def get_psu_status(self, index):
:return: Boolean, True if PSU is operating properly, False if PSU is\
faulty
"""
#Until psu_status is implemented this is hardcoded temporarily
# Until psu_status is implemented this is hardcoded temporarily
jleveque marked this conversation as resolved.
Show resolved Hide resolved

status = 1
return status


def get_psu_presence(self, index):
"""
Expand All @@ -89,9 +98,10 @@ def get_psu_presence(self, index):
"""
status = 0
psu_reg_name = PSU_PRESENCE.format(index)
psu_status = int(self.get_pmc_register(psu_reg_name),16)
psu_status = int(self.get_pmc_register(psu_reg_name), 16)
if (psu_status != 'ERR'):
# Check for PSU presence
if (psu_status):
status = 1
return status