[barefoot][platform] Refactor legacy scripts (#6871)
Removed or adapted obsolete code Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
This commit is contained in:
parent
d88e8cf87b
commit
8c4fd2b73b
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
python3 -m sonic_platform.bfn_extensions.platform_fancontrol "$@"
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@"
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@"
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@"
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@"
|
|
@ -7,6 +7,5 @@ if [ -t 1 ] ; then
|
|||||||
DOCKER_EXEC_FLAGS+="t"
|
DOCKER_EXEC_FLAGS+="t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@"
|
python3 -m sonic_platform.bfn_extensions.platform_sensors "$@"
|
||||||
|
docker exec -$DOCKER_EXEC_FLAGS pmon sensors "$@"
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
echo "test"
|
|
@ -12,7 +12,8 @@ setup(
|
|||||||
maintainer_email='',
|
maintainer_email='',
|
||||||
packages=[
|
packages=[
|
||||||
'sonic_platform',
|
'sonic_platform',
|
||||||
'sonic_platform/pltfm_mgr_rpc'
|
'sonic_platform/pltfm_mgr_rpc',
|
||||||
|
'sonic_platform/bfn_extensions',
|
||||||
],
|
],
|
||||||
package_data = {'sonic_platform':['logging.conf']},
|
package_data = {'sonic_platform':['logging.conf']},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
__all__ = [
|
||||||
|
'platform_sensors',
|
||||||
|
'platform_fancontrol',
|
||||||
|
]
|
@ -0,0 +1,59 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
from sonic_platform.platform_thrift_client import thrift_try
|
||||||
|
|
||||||
|
_MAX_FAN = 10
|
||||||
|
|
||||||
|
def fan_speed_set(fan, percent):
|
||||||
|
def set_fan_speed(client):
|
||||||
|
return client.pltfm_mgr.pltfm_mgr_fan_speed_set(fan, percent)
|
||||||
|
return thrift_try(set_fan_speed)
|
||||||
|
|
||||||
|
def fan_speed_info_get():
|
||||||
|
for fan_num in range(1, _MAX_FAN + 1):
|
||||||
|
def get_data(client, fan_num=fan_num):
|
||||||
|
return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num)
|
||||||
|
fan_info = thrift_try(get_data)
|
||||||
|
if fan_info.fan_num == fan_num:
|
||||||
|
yield fan_info
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
def print_usage():
|
||||||
|
print("Usage: platform_fancontrol.py <function> <param list> ", file=sys.stderr)
|
||||||
|
print(" function: fan_speed_set <fan #> <percent> ", file=sys.stderr)
|
||||||
|
print(" fan_speed_info_get ", file=sys.stderr)
|
||||||
|
|
||||||
|
argc = len(sys.argv)
|
||||||
|
if argc == 1:
|
||||||
|
print_usage()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if sys.argv[1] == "fan_speed_set":
|
||||||
|
if argc != 4:
|
||||||
|
print_usage()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
fan = int(sys.argv[2])
|
||||||
|
percent = int(sys.argv[3])
|
||||||
|
|
||||||
|
if (fan > _MAX_FAN) | (fan < 0):
|
||||||
|
print("Invalid value for fan #.\n", file=sys.stderr)
|
||||||
|
print_usage()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if (percent > 100) | (percent < 0):
|
||||||
|
print("Invalid value for precent\n", file=sys.stderr)
|
||||||
|
print_usage()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
fan_speed_set(fan, percent)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if sys.argv[1] == "fan_speed_info_get":
|
||||||
|
for fan_info in fan_speed_info_get():
|
||||||
|
print("fan number: %d front rpm: %d rear rpm: %d percent: %d%% " %
|
||||||
|
(fan_info.fan_num, fan_info.front_rpm, fan_info.rear_rpm, fan_info.percent))
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
print_usage()
|
@ -0,0 +1,26 @@
|
|||||||
|
import sys
|
||||||
|
import codecs
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
from sonic_platform.platform_thrift_client import thrift_try
|
||||||
|
|
||||||
|
def platform_sensors_get(args):
|
||||||
|
options = ""
|
||||||
|
if len(args)!=0:
|
||||||
|
options = urllib.quote(" ".join(args))
|
||||||
|
def get_data(client):
|
||||||
|
return client.pltfm_mgr.pltfm_mgr_sensor_info_get(options)
|
||||||
|
raw_out = thrift_try(get_data)
|
||||||
|
raw_list = raw_out.split('\"')
|
||||||
|
if len(raw_list) >= 2:
|
||||||
|
sensors_out = raw_list[1]
|
||||||
|
sensors_out = codecs.decode(sensors_out, "unicode_escape")
|
||||||
|
return sensors_out
|
||||||
|
return None
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
data = platform_sensors_get(sys.argv[1:])
|
||||||
|
if data:
|
||||||
|
print(data)
|
||||||
|
else:
|
||||||
|
print("No sensors info available", file=sys.stderr)
|
1
platform/barefoot/sonic-platform-modules-bfn-newport/scripts
Symbolic link
1
platform/barefoot/sonic-platform-modules-bfn-newport/scripts
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../sonic-platform-modules-bfn-montara/scripts
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@"
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@"
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@"
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@"
|
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@"
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
echo "test"
|
|
1
platform/barefoot/sonic-platform-modules-bfn/scripts
Symbolic link
1
platform/barefoot/sonic-platform-modules-bfn/scripts
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../sonic-platform-modules-bfn-montara/scripts
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@"
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@"
|
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@"
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@"
|
|
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
DOCKER_EXEC_FLAGS="i"
|
|
||||||
|
|
||||||
# Determine whether stdout is on a terminal
|
|
||||||
if [ -t 1 ] ; then
|
|
||||||
DOCKER_EXEC_FLAGS+="t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@"
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
echo "test"
|
|
Loading…
Reference in New Issue
Block a user