Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Azure/sonic-buildimage in…
Browse files Browse the repository at this point in the history
…to copp_changes
  • Loading branch information
dgsudharsan committed Nov 16, 2020
2 parents 599e9c9 + 67dbbb3 commit fd9914c
Show file tree
Hide file tree
Showing 209 changed files with 20,897 additions and 581 deletions.
12 changes: 6 additions & 6 deletions build_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ set -x -e
CONFIGURED_ARCH=$([ -f .arch ] && cat .arch || echo amd64)

## docker engine version (with platform)
if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then
# Version name differs between ARCH, copying same version as in sonic-slave docker
DOCKER_VERSION=18.06.3~ce~3-0~debian
else
DOCKER_VERSION=5:18.09.8~3-0~debian-$IMAGE_DISTRO
fi
DOCKER_VERSION=5:18.09.8~3-0~debian-$IMAGE_DISTRO
LINUX_KERNEL_VERSION=4.19.0-9-2

## Working directory to prepare the file system
Expand Down Expand Up @@ -202,6 +197,10 @@ sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install apt-transport-https \
curl \
gnupg2 \
software-properties-common
if [[ $CONFIGURED_ARCH == armhf ]]; then
# update ssl ca certificates for secure pem
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT c_rehash
fi
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/docker.gpg -fsSL https://download.docker.com/linux/debian/gpg
sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add /tmp/docker.gpg
sudo LANG=C chroot $FILESYSTEM_ROOT rm /tmp/docker.gpg
Expand Down Expand Up @@ -278,6 +277,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
python \
python-setuptools \
python3-setuptools \
python-jsonschema \
python-apt \
traceroute \
iputils-ping \
Expand Down
11 changes: 6 additions & 5 deletions check_install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import pexpect
import argparse
import pexpect
import sys
import time


def main():

parser = argparse.ArgumentParser(description='test_login cmdline parser')
Expand All @@ -21,16 +22,16 @@ def main():

login_prompt = 'sonic login:'
passwd_prompt = 'Password:'
cmd_prompt = "%s@sonic:~\$ $" % args.u
cmd_prompt = "{}@sonic:~\$ $".format(args.u)
grub_selection = "The highlighted entry will be executed"

i = 0
while True:
try:
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout)
p = pexpect.spawn("telnet 127.0.0.1 {}".format(args.p), timeout=600, logfile=sys.stdout, encoding='utf-8')
break
except Exception as e:
print str(e)
print(str(e))
i += 1
if i == 10:
raise
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# Get sai.profile based on switch_role #}
{%- if DEVICE_METADATA is defined -%}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] -%}
{%- if switch_role.lower() == 'torrouter' %}
{%- if 'torrouter' in switch_role.lower() %}
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-a7060-cx32s-32x40G-t0.config.bcm' -%}
{%- else %}
{%- set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-a7060-cx32s-32x40G-t1.config.bcm' -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# Get sai.profile based on switch_role #}
{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined -%}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] -%}
{%- if switch_role.lower() == 'torrouter' %}
{%- if 'torrouter' in switch_role.lower() %}
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-seastone-dx010-32x100G-t0.config.bcm' -%}
{%- else %}
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-seastone-dx010-32x100G-t1.config.bcm' -%}
Expand Down
27 changes: 27 additions & 0 deletions device/common/pddf/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

try:
import os
import sys
import json
sys.path.append('/usr/share/sonic/platform/plugins')
import pddfparse
#from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
except ImportError, e:
raise ImportError (str(e) + "- required module not found")


class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256
def __init__(self, name, path, cpld_root, ro):
global pddf_obj
global plugin_data
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd:
plugin_data = json.load(pd)

pddf_obj = pddfparse.PddfParse()
# system EEPROM always has device name EEPROM1
self.eeprom_path = pddf_obj.get_path("EEPROM1", "eeprom")
super(board, self).__init__(self.eeprom_path, 0, '', True)

202 changes: 202 additions & 0 deletions device/common/pddf/plugins/fanutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#!/usr/bin/env python


# Sample pddf_fanutil file
# All the supported FAN SysFS aattributes are
#- fan<idx>_present
#- fan<idx>_direction
#- fan<idx>_input
#- fan<idx>_pwm
#- fan<idx>_fault
# where idx is in the range [1-12]
#


import os.path
import sys
sys.path.append('/usr/share/sonic/platform/plugins')
import pddfparse
import json

try:
from sonic_fan.fan_base import FanBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

class FanUtil(FanBase):
"""PDDF generic FAN util class"""

def __init__(self):
FanBase.__init__(self)
global pddf_obj
global plugin_data
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd:
plugin_data = json.load(pd)

pddf_obj = pddfparse.PddfParse()
self.platform = pddf_obj.get_platform()

self.num_fans = (self.platform['num_fantrays'] * self.platform['num_fans_pertray'] )

def get_num_fans(self):
return self.num_fans

def get_presence(self, idx):
# 1 based fan index
if idx<1 or idx>self.num_fans:
print "Invalid fan index %d\n"%idx
return False

attr_name = "fan"+ str(idx) +"_present"
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr_name)
if not output:
return False

mode = output['mode']
presence = output['status'].rstrip()

vmap = plugin_data['FAN']['present'][mode]['valmap']

if presence in vmap:
status = vmap[presence]
else:
status = False

return status

def get_status(self, idx):
# 1 based fan index
if idx<1 or idx>self.num_fans:
print "Invalid fan index %d\n"%idx
return False

speed = self.get_speed(idx)
status = True if (speed != 0) else False
return status

def get_direction(self, idx):
# 1 based fan index
if idx<1 or idx>self.num_fans:
print "Invalid fan index %d\n"%idx
return None

attr = "fan" + str(idx) + "_direction"
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
if not output:
return None

mode = output['mode']
val = output['status']

val = val.rstrip()
vmap = plugin_data['FAN']['direction'][mode]['valmap']


if val in vmap:
direction = vmap[val]
else:
direction = val

return direction

def get_directions(self):
num_fan = self.get_num_fan();

for i in range(1, num_fan+1):
attr = "fan" + str(i) + "_direction"
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
if not output:
return None

mode = output['mode']
val = output['status']

val = val.rstrip()
vmap = plugin_data['FAN']['direction'][mode]['valmap']

direction = vmap[str(val)]

print "FAN-%d direction is %s"%(i, direction)

return 0

def get_speed(self, idx):
# 1 based fan index
if idx<1 or idx>self.num_fans:
print "Invalid fan index %d\n"%idx
return 0

attr = "fan" + str(idx) + "_input"
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
if not output:
return 0

#mode = output['mode']
val = output['status'].rstrip()

if val.isalpha():
return 0
else:
rpm_speed = int(float(val))

return rpm_speed

def get_speeds(self):
num_fan = self.get_num_fan();
ret = "FAN_INDEX\t\tRPM\n"

for i in range(1, num_fan+1):
attr1 = "fan" + str(i) + "_input"
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr1)
if not output:
return ""

#mode = output['mode']
val = output['status'].rstrip()

if val.isalpha():
frpm = 0
else:
frpm = int(val)

ret += "FAN-%d\t\t\t%d\n"%(i, frpm)

return ret

def set_speed(self, val):
if val<0 or val>100:
print "Error: Invalid speed %d. Please provide a valid speed percentage"%val
return False

num_fan = self.num_fans
if 'duty_cycle_to_pwm' not in plugin_data['FAN']:
print "Setting fan speed is not allowed !"
return False
else:
duty_cycle_to_pwm = eval(plugin_data['FAN']['duty_cycle_to_pwm'])
pwm = duty_cycle_to_pwm(val)
print "New Speed: %d%% - PWM value to be set is %d\n"%(val,pwm)

for i in range(1, num_fan+1):
attr = "fan" + str(i) + "_pwm"
node = pddf_obj.get_path("FAN-CTRL", attr)
if node is None:
return False
try:
with open(node, 'w') as f:
f.write(str(pwm))
except IOError:
return False

return True

def dump_sysfs(self):
return pddf_obj.cli_dump_dsysfs('fan')

def get_change_event(self):
"""
TODO: This function need to be implemented
when decide to support monitoring FAN(fand)
on this platform.
"""
raise NotImplementedError
58 changes: 58 additions & 0 deletions device/common/pddf/plugins/ledutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

import sys
sys.path.append('/usr/share/sonic/platform/plugins')
import pddfparse

class LedUtil:
color_map = {
"STATUS_LED_COLOR_GREEN" : "on",
"STATUS_LED_COLOR_RED" : "faulty",
"STATUS_LED_COLOR_OFF" : "off"
}

def __init__(self):
global pddf_obj
pddf_obj = pddfparse.PddfParse()
self.path="pddf/devices/led"
self.cur_state_path="pddf/devices/led/cur_state"

def set_status_led(self, led_device_name, color, color_state="SOLID"):
if (not led_device_name in pddf_obj.data.keys()):
status="ERROR: " + led_device_name + " is not configured"
return (status)

if (not color in self.color_map.keys()):
status="ERROR: Invalid color"
return (status)

index=pddf_obj.data[led_device_name]['dev_attr']['index']
pddf_obj.create_attr('device_name', led_device_name, self.path)
pddf_obj.create_attr('index', index, self.path)
pddf_obj.create_attr('color', self.color_map[color], self.cur_state_path)
pddf_obj.create_attr('color_state', color_state, self.cur_state_path)
pddf_obj.create_attr('dev_ops', 'set_status', self.path)
return ("Executed")

def get_status_led(self, led_device_name):
if (not led_device_name in pddf_obj.data.keys()):
status="ERROR: " + led_device_name + " is not configured"
return (status)

index=pddf_obj.data[led_device_name]['dev_attr']['index']
pddf_obj.create_attr('device_name', led_device_name, self.path)
pddf_obj.create_attr('index', index, self.path)
pddf_obj.create_attr('dev_ops', 'get_status', self.path)
color_f="/sys/kernel/" + self.cur_state_path +"/color"
color_state_f="/sys/kernel/" + self.cur_state_path +"/color_state"

try:
with open(color_f, 'r') as f:
color = f.read().strip("\r\n")
with open(color_state_f, 'r') as f:
color_state = f.read().strip("\r\n")
except IOError:
status="ERROR :" + color_f + " open failed"
return (status)
status = "%s-%s:\t%s %s\n"%(led_device_name, index, color, color_state)
return (status)
Loading

0 comments on commit fd9914c

Please sign in to comment.