Skip to content

Commit

Permalink
[lldp]: Get all interfaces from the database (#1069)
Browse files Browse the repository at this point in the history
The previous implementation only supports EthernetX while X
varies from 0 - 124. Remove such hard coded logics and use
the information from the database instead.

Signed-off-by: Shu0T1an ChenG <[email protected]>
  • Loading branch information
Shuotian Cheng authored and lguohan committed Oct 24, 2017
1 parent a4ecade commit fd34d90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dockers/docker-lldp-sv2/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN pip install /python-wheels/swsssdk-2.0.1-py2-none-any.whl && \

COPY ["start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["reconfigure.sh", "/opt/"]
COPY ["reconfigure.sh", "/usr/bin/"]
COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"]
COPY ["lldpd", "/etc/default/"]

Expand Down
17 changes: 8 additions & 9 deletions dockers/docker-lldp-sv2/reconfigure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set -e

num_of_interfaces=32
if_step=4
last_if_idx=$((num_of_interfaces*if_step - if_step))
# TODO: Listen to state database when it is ready
interfaces=$(sonic-cfggen -d -v "PORT.keys() | join(' ')")

function wait_until_if_exists
{
Expand All @@ -31,23 +30,23 @@ function wait_until_if_not_exists
while /bin/true ;
do
# wait until all interfaces are created
echo Wait until all ifaces are created
for i in $(seq 0 $if_step $last_if_idx)
echo Wait until all interfaces are created
for i in $interfaces
do
wait_until_if_exists "Ethernet$i"
wait_until_if_exists $i
done

echo Wait 10 seconds while lldpd finds new interfaces
sleep 10

# apply lldpd configuration
echo apply lldpd configuration
echo Apply lldpd configuration
lldpcli -c /etc/lldpd.conf

# wait until all interfaces are destroyed
echo Wait until all ifaces are destroyed
for i in $(seq 0 $if_step $last_if_idx)
for i in $interfaces
do
wait_until_if_not_exists "Ethernet$i"
wait_until_if_not_exists $i
done
done
2 changes: 1 addition & 1 deletion dockers/docker-lldp-sv2/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ stdout_logfile=syslog
stderr_logfile=syslog

[program:lldpd-conf-reload]
command=/opt/reconfigure.sh
command=/usr/bin/reconfigure.sh
priority=150
autostart=false
autorestart=false
Expand Down

0 comments on commit fd34d90

Please sign in to comment.