[Quanta/device] Modify psuutil.py and config.bcm of IX1B (#1985)
* Fix LED activity behavior * Modify psuutil.py and config.bcm of IX1B
This commit is contained in:
parent
83f0822dde
commit
02322182fc
@ -12,8 +12,11 @@ parity_enable=1
|
|||||||
# Control to disable parity correction
|
# Control to disable parity correction
|
||||||
parity_correction=1
|
parity_correction=1
|
||||||
|
|
||||||
l2_mem_entries=<40960>
|
ipv6_lpm_128b_enable=1
|
||||||
l3_mem_entries=<40960>
|
l3_alpm_enable=2
|
||||||
|
|
||||||
|
l2_mem_entries=40960
|
||||||
|
l3_mem_entries=40960
|
||||||
|
|
||||||
portmap_1=1:100
|
portmap_1=1:100
|
||||||
portmap_2=5:100
|
portmap_2=5:100
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import commands
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -17,59 +17,58 @@ DEBUG = False
|
|||||||
|
|
||||||
def show_log(txt):
|
def show_log(txt):
|
||||||
if DEBUG == True:
|
if DEBUG == True:
|
||||||
print "[IX1B]"+txt
|
print("[IX2]"+txt)
|
||||||
return
|
return
|
||||||
|
|
||||||
def exec_cmd(cmd, show):
|
def exec_cmd(cmd, show):
|
||||||
logging.info('Run :'+cmd)
|
logging.info('Run :'+cmd)
|
||||||
status, output = commands.getstatusoutput(cmd)
|
try:
|
||||||
show_log (cmd +"with result:" + str(status))
|
output = subprocess.check_output(cmd, shell=True)
|
||||||
show_log (" output:"+output)
|
show_log (cmd +"output:"+str(output))
|
||||||
if status:
|
except subprocess.CalledProcessError as e:
|
||||||
logging.info('Failed :'+cmd)
|
logging.info("Failed :"+cmd)
|
||||||
if show:
|
if show:
|
||||||
print('Failed :'+cmd)
|
print("Failed :"+cmd +"returncode = {}, err msg: {}".format(e.returncode, e.output))
|
||||||
return status, output
|
return output
|
||||||
|
|
||||||
def my_log(txt):
|
def my_log(txt):
|
||||||
if DEBUG == True:
|
if DEBUG == True:
|
||||||
print "[QUANTA DBG]: "+txt
|
print("[QUANTA DBG]: "+txt)
|
||||||
return
|
return
|
||||||
|
|
||||||
def log_os_system(cmd, show):
|
def log_os_system(cmd, show):
|
||||||
logging.info('Run :'+cmd)
|
logging.info('Run :'+cmd)
|
||||||
status = 1
|
status = 1
|
||||||
output = ""
|
output = ""
|
||||||
status, output = commands.getstatusoutput(cmd)
|
try:
|
||||||
my_log (cmd +"with result:" + str(status))
|
output = subprocess.check_output(cmd, shell=True)
|
||||||
my_log ("cmd:" + cmd)
|
my_log (cmd +"output:"+str(output))
|
||||||
my_log (" output:"+output)
|
except subprocess.CalledProcessError as e:
|
||||||
if status:
|
|
||||||
logging.info('Failed :'+cmd)
|
logging.info('Failed :'+cmd)
|
||||||
if show:
|
if show:
|
||||||
print('Failed :'+cmd)
|
print("Failed :"+cmd +"returncode = {}, err msg: {}".format(e.returncode, e.output))
|
||||||
return status, output
|
return output
|
||||||
|
|
||||||
def gpio16_exist():
|
def gpio16_exist():
|
||||||
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio16", 0)
|
ls = log_os_system("ls /sys/class/gpio/ | grep gpio16", 0)
|
||||||
logging.info('mods:'+ls)
|
logging.info('mods:'+ls)
|
||||||
if len(ls) ==0:
|
if len(ls) ==0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def gpio17_exist():
|
def gpio17_exist():
|
||||||
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio17", 0)
|
ls = log_os_system("ls /sys/class/gpio/ | grep gpio17", 0)
|
||||||
logging.info('mods:'+ls)
|
logging.info('mods:'+ls)
|
||||||
if len(ls) ==0:
|
if len(ls) ==0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def gpio19_exist():
|
def gpio19_exist():
|
||||||
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio19", 0)
|
ls = log_os_system("ls /sys/class/gpio/ | grep gpio19", 0)
|
||||||
logging.info('mods:'+ls)
|
logging.info('mods:'+ls)
|
||||||
if len(ls) ==0:
|
if len(ls) ==0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def gpio20_exist():
|
def gpio20_exist():
|
||||||
ret, ls = log_os_system("ls /sys/class/gpio/ | grep gpio20", 0)
|
ls = log_os_system("ls /sys/class/gpio/ | grep gpio20", 0)
|
||||||
logging.info('mods:'+ls)
|
logging.info('mods:'+ls)
|
||||||
if len(ls) ==0:
|
if len(ls) ==0:
|
||||||
return False
|
return False
|
||||||
@ -86,20 +85,20 @@ class PsuUtil(PsuBase):
|
|||||||
PsuBase.__init__(self)
|
PsuBase.__init__(self)
|
||||||
|
|
||||||
if gpio16_exist() == False:
|
if gpio16_exist() == False:
|
||||||
status, output = exec_cmd("echo 16 > /sys/class/gpio/export ", 1)
|
output = exec_cmd("echo 16 > /sys/class/gpio/export ", 1)
|
||||||
status, output = exec_cmd("echo in > /sys/class/gpio/gpio16/direction ", 1)
|
output = exec_cmd("echo in > /sys/class/gpio/gpio16/direction ", 1)
|
||||||
|
|
||||||
if gpio17_exist() == False:
|
if gpio17_exist() == False:
|
||||||
status, output = exec_cmd("echo 17 > /sys/class/gpio/export ", 1)
|
output = exec_cmd("echo 17 > /sys/class/gpio/export ", 1)
|
||||||
status, output = exec_cmd("echo in > /sys/class/gpio/gpio17/direction ", 1)
|
output = exec_cmd("echo in > /sys/class/gpio/gpio17/direction ", 1)
|
||||||
|
|
||||||
if gpio19_exist() == False:
|
if gpio19_exist() == False:
|
||||||
status, output = exec_cmd("echo 19 > /sys/class/gpio/export ", 1)
|
output = exec_cmd("echo 19 > /sys/class/gpio/export ", 1)
|
||||||
status, output = exec_cmd("echo in > /sys/class/gpio/gpio19/direction ", 1)
|
output = exec_cmd("echo in > /sys/class/gpio/gpio19/direction ", 1)
|
||||||
|
|
||||||
if gpio20_exist() == False:
|
if gpio20_exist() == False:
|
||||||
status, output = exec_cmd("echo 20 > /sys/class/gpio/export ", 1)
|
output = exec_cmd("echo 20 > /sys/class/gpio/export ", 1)
|
||||||
status, output = exec_cmd("echo in > /sys/class/gpio/gpio20/direction ", 1)
|
output = exec_cmd("echo in > /sys/class/gpio/gpio20/direction ", 1)
|
||||||
|
|
||||||
# Get sysfs attribute
|
# Get sysfs attribute
|
||||||
def get_attr_value(self, attr_path):
|
def get_attr_value(self, attr_path):
|
||||||
|
Loading…
Reference in New Issue
Block a user