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

[device/alibaba]: Update BMC watchdog handler #89

Merged
merged 5 commits into from May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all 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: 0 additions & 26 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ def __init__(self):
self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name
self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name
self.bmc_pwd_path = "/usr/local/etc/bmcpwd"
self.bmc_wdt_ctrl = "/usr/local/etc/bmc_wdt.sh"
self.bmc_wdt_trig = False

def __del__(self):
if self.bmc_wdt_trig:
self.__bmc_watchdog_handler("enable")

def __get_register_value(self, path, register):
cmd = "echo {1} > {0}; cat {0}".format(path, register)
Expand Down Expand Up @@ -78,24 +72,6 @@ def __fpga_pci_rescan(self):
os.system('modprobe switchboard_fpga')
return 0

def __bmc_watchdog_handler(self, state):
command = "systemctl start bmc_wdt.timer"
if state == "disable":
command = "systemctl stop bmc_wdt.timer;sh % s stop" % self.bmc_wdt_ctrl
p = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
json_object = {}
try:
json_object = json.loads(raw_data)
except:
pass
finally:
if json_object.get('result') != "success" and err != '':
print("Warning: %s" % err)
return False
return True

def get_bmc_pass(self):
if os.path.exists(self.bmc_pwd_path):
with open(self.bmc_pwd_path) as file:
Expand Down Expand Up @@ -272,7 +248,6 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
or 'cpld_fan_come_board', etc. If None, upgrade all CPLD/FPGA firmware. for fw_type 'bios' and 'bmc',
value should be one of 'master' or 'slave' or 'both'
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down Expand Up @@ -628,7 +603,6 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
or
self.firmware_program("FPGA", "/fpga.bin")
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ def __init__(self):
self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name
self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name
self.bmc_pwd_path = "/usr/local/etc/bmcpwd"
self.bmc_wdt_ctrl = "/usr/local/etc/bmc_wdt.sh"
self.bmc_wdt_trig = False

def __del__(self):
if self.bmc_wdt_trig:
self.__bmc_watchdog_handler("enable")

def __get_register_value(self, path, register):
cmd = "echo {1} > {0}; cat {0}".format(path, register)
Expand Down Expand Up @@ -78,24 +72,6 @@ def __fpga_pci_rescan(self):
os.system('modprobe switchboard_fpga')
return 0

def __bmc_watchdog_handler(self, state):
command = "systemctl start bmc_wdt.timer"
if state == "disable":
command = "systemctl stop bmc_wdt.timer;sh % s stop" % self.bmc_wdt_ctrl
p = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
json_object = {}
try:
json_object = json.loads(raw_data)
except:
pass
finally:
if json_object.get('result') != "success" and err != '':
print("Warning: %s" % err)
return False
return True

def get_bmc_pass(self):
if os.path.exists(self.bmc_pwd_path):
with open(self.bmc_pwd_path) as file:
Expand Down Expand Up @@ -272,7 +248,6 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
or 'cpld_fan_come_board', etc. If None, upgrade all CPLD/FPGA firmware. for fw_type 'bios' and 'bmc',
value should be one of 'master' or 'slave' or 'both'
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down Expand Up @@ -628,7 +603,6 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
or
self.firmware_program("FPGA", "/fpga.bin")
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down
26 changes: 0 additions & 26 deletions device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ def __init__(self):
self.switchboard_cpld3_path = "/sys/devices/platform/%s.switchboard/CPLD3/getreg" % self.platform_name
self.switchboard_cpld4_path = "/sys/devices/platform/%s.switchboard/CPLD4/getreg" % self.platform_name
self.bmc_pwd_path = "/usr/local/etc/bmcpwd"
self.bmc_wdt_ctrl = "/usr/local/etc/bmc_wdt.sh"
self.bmc_wdt_trig = False

def __del__(self):
if self.bmc_wdt_trig:
self.__bmc_watchdog_handler("enable")

def __get_register_value(self, path, register):
cmd = "echo {1} > {0}; cat {0}".format(path, register)
Expand Down Expand Up @@ -78,24 +72,6 @@ def __fpga_pci_rescan(self):
os.system('modprobe switchboard_fpga')
return 0

def __bmc_watchdog_handler(self, state):
command = "systemctl start bmc_wdt.timer"
if state == "disable":
command = "systemctl stop bmc_wdt.timer;sh % s stop" % self.bmc_wdt_ctrl
p = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
json_object = {}
try:
json_object = json.loads(raw_data)
except:
pass
finally:
if json_object.get('result') != "success" and err != '':
print("Warning: %s" % err)
return False
return True

def get_bmc_pass(self):
if os.path.exists(self.bmc_pwd_path):
with open(self.bmc_pwd_path) as file:
Expand Down Expand Up @@ -272,7 +248,6 @@ def firmware_upgrade(self, fw_type, fw_path, fw_extra=None):
or 'cpld_fan_come_board', etc. If None, upgrade all CPLD/FPGA firmware. for fw_type 'bios' and 'bmc',
value should be one of 'master' or 'slave' or 'both'
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down Expand Up @@ -628,7 +603,6 @@ def firmware_program(self, fw_type, fw_path, fw_extra=None):
or
self.firmware_program("FPGA", "/fpga.bin")
"""
self.bmc_wdt_trig = self.__bmc_watchdog_handler("disable")
fw_type = fw_type.lower()
upgrade_list = []
bmc_pwd = self.get_bmc_pass()
Expand Down