Skip to content

Commit fd9914c

Browse files
author
dgsudharsan
committed
Merge branch 'master' of https://github.com/Azure/sonic-buildimage into copp_changes
2 parents 599e9c9 + 67dbbb3 commit fd9914c

File tree

209 files changed

+20897
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+20897
-581
lines changed

build_debian.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ set -x -e
3131
CONFIGURED_ARCH=$([ -f .arch ] && cat .arch || echo amd64)
3232

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

4237
## Working directory to prepare the file system
@@ -202,6 +197,10 @@ sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install apt-transport-https \
202197
curl \
203198
gnupg2 \
204199
software-properties-common
200+
if [[ $CONFIGURED_ARCH == armhf ]]; then
201+
# update ssl ca certificates for secure pem
202+
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT c_rehash
203+
fi
205204
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/docker.gpg -fsSL https://download.docker.com/linux/debian/gpg
206205
sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add /tmp/docker.gpg
207206
sudo LANG=C chroot $FILESYSTEM_ROOT rm /tmp/docker.gpg
@@ -278,6 +277,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
278277
python \
279278
python-setuptools \
280279
python3-setuptools \
280+
python-jsonschema \
281281
python-apt \
282282
traceroute \
283283
iputils-ping \

check_install.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

3-
import pexpect
43
import argparse
4+
import pexpect
55
import sys
66
import time
77

8+
89
def main():
910

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

2223
login_prompt = 'sonic login:'
2324
passwd_prompt = 'Password:'
24-
cmd_prompt = "%s@sonic:~\$ $" % args.u
25+
cmd_prompt = "{}@sonic:~\$ $".format(args.u)
2526
grub_selection = "The highlighted entry will be executed"
2627

2728
i = 0
2829
while True:
2930
try:
30-
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout)
31+
p = pexpect.spawn("telnet 127.0.0.1 {}".format(args.p), timeout=600, logfile=sys.stdout, encoding='utf-8')
3132
break
3233
except Exception as e:
33-
print str(e)
34+
print(str(e))
3435
i += 1
3536
if i == 10:
3637
raise

device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-Q32/sai.profile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{# Get sai.profile based on switch_role #}
22
{%- if DEVICE_METADATA is defined -%}
33
{%- set switch_role = DEVICE_METADATA['localhost']['type'] -%}
4-
{%- if switch_role.lower() == 'torrouter' %}
4+
{%- if 'torrouter' in switch_role.lower() %}
55
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-a7060-cx32s-32x40G-t0.config.bcm' -%}
66
{%- else %}
77
{%- set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-a7060-cx32s-32x40G-t1.config.bcm' -%}

device/celestica/x86_64-cel_seastone-r0/Celestica-DX010-C32/sai.profile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{# Get sai.profile based on switch_role #}
22
{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined -%}
33
{%- set switch_role = DEVICE_METADATA['localhost']['type'] -%}
4-
{%- if switch_role.lower() == 'torrouter' %}
4+
{%- if 'torrouter' in switch_role.lower() %}
55
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-seastone-dx010-32x100G-t0.config.bcm' -%}
66
{%- else %}
77
{% set sai_profile_contents = 'SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th-seastone-dx010-32x100G-t1.config.bcm' -%}

device/common/pddf/plugins/eeprom.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
try:
4+
import os
5+
import sys
6+
import json
7+
sys.path.append('/usr/share/sonic/platform/plugins')
8+
import pddfparse
9+
#from sonic_eeprom import eeprom_base
10+
from sonic_eeprom import eeprom_tlvinfo
11+
except ImportError, e:
12+
raise ImportError (str(e) + "- required module not found")
13+
14+
15+
class board(eeprom_tlvinfo.TlvInfoDecoder):
16+
_TLV_INFO_MAX_LEN = 256
17+
def __init__(self, name, path, cpld_root, ro):
18+
global pddf_obj
19+
global plugin_data
20+
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd:
21+
plugin_data = json.load(pd)
22+
23+
pddf_obj = pddfparse.PddfParse()
24+
# system EEPROM always has device name EEPROM1
25+
self.eeprom_path = pddf_obj.get_path("EEPROM1", "eeprom")
26+
super(board, self).__init__(self.eeprom_path, 0, '', True)
27+

device/common/pddf/plugins/fanutil.py

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#!/usr/bin/env python
2+
3+
4+
# Sample pddf_fanutil file
5+
# All the supported FAN SysFS aattributes are
6+
#- fan<idx>_present
7+
#- fan<idx>_direction
8+
#- fan<idx>_input
9+
#- fan<idx>_pwm
10+
#- fan<idx>_fault
11+
# where idx is in the range [1-12]
12+
#
13+
14+
15+
import os.path
16+
import sys
17+
sys.path.append('/usr/share/sonic/platform/plugins')
18+
import pddfparse
19+
import json
20+
21+
try:
22+
from sonic_fan.fan_base import FanBase
23+
except ImportError as e:
24+
raise ImportError (str(e) + "- required module not found")
25+
26+
class FanUtil(FanBase):
27+
"""PDDF generic FAN util class"""
28+
29+
def __init__(self):
30+
FanBase.__init__(self)
31+
global pddf_obj
32+
global plugin_data
33+
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd:
34+
plugin_data = json.load(pd)
35+
36+
pddf_obj = pddfparse.PddfParse()
37+
self.platform = pddf_obj.get_platform()
38+
39+
self.num_fans = (self.platform['num_fantrays'] * self.platform['num_fans_pertray'] )
40+
41+
def get_num_fans(self):
42+
return self.num_fans
43+
44+
def get_presence(self, idx):
45+
# 1 based fan index
46+
if idx<1 or idx>self.num_fans:
47+
print "Invalid fan index %d\n"%idx
48+
return False
49+
50+
attr_name = "fan"+ str(idx) +"_present"
51+
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr_name)
52+
if not output:
53+
return False
54+
55+
mode = output['mode']
56+
presence = output['status'].rstrip()
57+
58+
vmap = plugin_data['FAN']['present'][mode]['valmap']
59+
60+
if presence in vmap:
61+
status = vmap[presence]
62+
else:
63+
status = False
64+
65+
return status
66+
67+
def get_status(self, idx):
68+
# 1 based fan index
69+
if idx<1 or idx>self.num_fans:
70+
print "Invalid fan index %d\n"%idx
71+
return False
72+
73+
speed = self.get_speed(idx)
74+
status = True if (speed != 0) else False
75+
return status
76+
77+
def get_direction(self, idx):
78+
# 1 based fan index
79+
if idx<1 or idx>self.num_fans:
80+
print "Invalid fan index %d\n"%idx
81+
return None
82+
83+
attr = "fan" + str(idx) + "_direction"
84+
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
85+
if not output:
86+
return None
87+
88+
mode = output['mode']
89+
val = output['status']
90+
91+
val = val.rstrip()
92+
vmap = plugin_data['FAN']['direction'][mode]['valmap']
93+
94+
95+
if val in vmap:
96+
direction = vmap[val]
97+
else:
98+
direction = val
99+
100+
return direction
101+
102+
def get_directions(self):
103+
num_fan = self.get_num_fan();
104+
105+
for i in range(1, num_fan+1):
106+
attr = "fan" + str(i) + "_direction"
107+
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
108+
if not output:
109+
return None
110+
111+
mode = output['mode']
112+
val = output['status']
113+
114+
val = val.rstrip()
115+
vmap = plugin_data['FAN']['direction'][mode]['valmap']
116+
117+
direction = vmap[str(val)]
118+
119+
print "FAN-%d direction is %s"%(i, direction)
120+
121+
return 0
122+
123+
def get_speed(self, idx):
124+
# 1 based fan index
125+
if idx<1 or idx>self.num_fans:
126+
print "Invalid fan index %d\n"%idx
127+
return 0
128+
129+
attr = "fan" + str(idx) + "_input"
130+
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr)
131+
if not output:
132+
return 0
133+
134+
#mode = output['mode']
135+
val = output['status'].rstrip()
136+
137+
if val.isalpha():
138+
return 0
139+
else:
140+
rpm_speed = int(float(val))
141+
142+
return rpm_speed
143+
144+
def get_speeds(self):
145+
num_fan = self.get_num_fan();
146+
ret = "FAN_INDEX\t\tRPM\n"
147+
148+
for i in range(1, num_fan+1):
149+
attr1 = "fan" + str(i) + "_input"
150+
output = pddf_obj.get_attr_name_output("FAN-CTRL", attr1)
151+
if not output:
152+
return ""
153+
154+
#mode = output['mode']
155+
val = output['status'].rstrip()
156+
157+
if val.isalpha():
158+
frpm = 0
159+
else:
160+
frpm = int(val)
161+
162+
ret += "FAN-%d\t\t\t%d\n"%(i, frpm)
163+
164+
return ret
165+
166+
def set_speed(self, val):
167+
if val<0 or val>100:
168+
print "Error: Invalid speed %d. Please provide a valid speed percentage"%val
169+
return False
170+
171+
num_fan = self.num_fans
172+
if 'duty_cycle_to_pwm' not in plugin_data['FAN']:
173+
print "Setting fan speed is not allowed !"
174+
return False
175+
else:
176+
duty_cycle_to_pwm = eval(plugin_data['FAN']['duty_cycle_to_pwm'])
177+
pwm = duty_cycle_to_pwm(val)
178+
print "New Speed: %d%% - PWM value to be set is %d\n"%(val,pwm)
179+
180+
for i in range(1, num_fan+1):
181+
attr = "fan" + str(i) + "_pwm"
182+
node = pddf_obj.get_path("FAN-CTRL", attr)
183+
if node is None:
184+
return False
185+
try:
186+
with open(node, 'w') as f:
187+
f.write(str(pwm))
188+
except IOError:
189+
return False
190+
191+
return True
192+
193+
def dump_sysfs(self):
194+
return pddf_obj.cli_dump_dsysfs('fan')
195+
196+
def get_change_event(self):
197+
"""
198+
TODO: This function need to be implemented
199+
when decide to support monitoring FAN(fand)
200+
on this platform.
201+
"""
202+
raise NotImplementedError

device/common/pddf/plugins/ledutil.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
sys.path.append('/usr/share/sonic/platform/plugins')
5+
import pddfparse
6+
7+
class LedUtil:
8+
color_map = {
9+
"STATUS_LED_COLOR_GREEN" : "on",
10+
"STATUS_LED_COLOR_RED" : "faulty",
11+
"STATUS_LED_COLOR_OFF" : "off"
12+
}
13+
14+
def __init__(self):
15+
global pddf_obj
16+
pddf_obj = pddfparse.PddfParse()
17+
self.path="pddf/devices/led"
18+
self.cur_state_path="pddf/devices/led/cur_state"
19+
20+
def set_status_led(self, led_device_name, color, color_state="SOLID"):
21+
if (not led_device_name in pddf_obj.data.keys()):
22+
status="ERROR: " + led_device_name + " is not configured"
23+
return (status)
24+
25+
if (not color in self.color_map.keys()):
26+
status="ERROR: Invalid color"
27+
return (status)
28+
29+
index=pddf_obj.data[led_device_name]['dev_attr']['index']
30+
pddf_obj.create_attr('device_name', led_device_name, self.path)
31+
pddf_obj.create_attr('index', index, self.path)
32+
pddf_obj.create_attr('color', self.color_map[color], self.cur_state_path)
33+
pddf_obj.create_attr('color_state', color_state, self.cur_state_path)
34+
pddf_obj.create_attr('dev_ops', 'set_status', self.path)
35+
return ("Executed")
36+
37+
def get_status_led(self, led_device_name):
38+
if (not led_device_name in pddf_obj.data.keys()):
39+
status="ERROR: " + led_device_name + " is not configured"
40+
return (status)
41+
42+
index=pddf_obj.data[led_device_name]['dev_attr']['index']
43+
pddf_obj.create_attr('device_name', led_device_name, self.path)
44+
pddf_obj.create_attr('index', index, self.path)
45+
pddf_obj.create_attr('dev_ops', 'get_status', self.path)
46+
color_f="/sys/kernel/" + self.cur_state_path +"/color"
47+
color_state_f="/sys/kernel/" + self.cur_state_path +"/color_state"
48+
49+
try:
50+
with open(color_f, 'r') as f:
51+
color = f.read().strip("\r\n")
52+
with open(color_state_f, 'r') as f:
53+
color_state = f.read().strip("\r\n")
54+
except IOError:
55+
status="ERROR :" + color_f + " open failed"
56+
return (status)
57+
status = "%s-%s:\t%s %s\n"%(led_device_name, index, color, color_state)
58+
return (status)

0 commit comments

Comments
 (0)