[lldp]: Get all interfaces from the database (#1069)

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 <shuche@microsoft.com>
This commit is contained in:
Shuotian Cheng 2017-10-23 19:53:10 -07:00 committed by lguohan
parent a4ecade8f6
commit fd34d907ff
3 changed files with 10 additions and 11 deletions

View File

@ -30,7 +30,7 @@ RUN pip install /python-wheels/swsssdk-2.0.1-py2-none-any.whl && \
COPY ["start.sh", "/usr/bin/"] COPY ["start.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] 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.conf.j2", "/usr/share/sonic/templates/"]
COPY ["lldpd", "/etc/default/"] COPY ["lldpd", "/etc/default/"]

View File

@ -2,9 +2,8 @@
set -e set -e
num_of_interfaces=32 # TODO: Listen to state database when it is ready
if_step=4 interfaces=$(sonic-cfggen -d -v "PORT.keys() | join(' ')")
last_if_idx=$((num_of_interfaces*if_step - if_step))
function wait_until_if_exists function wait_until_if_exists
{ {
@ -31,23 +30,23 @@ function wait_until_if_not_exists
while /bin/true ; while /bin/true ;
do do
# wait until all interfaces are created # wait until all interfaces are created
echo Wait until all ifaces are created echo Wait until all interfaces are created
for i in $(seq 0 $if_step $last_if_idx) for i in $interfaces
do do
wait_until_if_exists "Ethernet$i" wait_until_if_exists $i
done done
echo Wait 10 seconds while lldpd finds new interfaces echo Wait 10 seconds while lldpd finds new interfaces
sleep 10 sleep 10
# apply lldpd configuration # apply lldpd configuration
echo apply lldpd configuration echo Apply lldpd configuration
lldpcli -c /etc/lldpd.conf lldpcli -c /etc/lldpd.conf
# wait until all interfaces are destroyed # wait until all interfaces are destroyed
echo Wait until all ifaces are destroyed echo Wait until all ifaces are destroyed
for i in $(seq 0 $if_step $last_if_idx) for i in $interfaces
do do
wait_until_if_not_exists "Ethernet$i" wait_until_if_not_exists $i
done done
done done

View File

@ -33,7 +33,7 @@ stdout_logfile=syslog
stderr_logfile=syslog stderr_logfile=syslog
[program:lldpd-conf-reload] [program:lldpd-conf-reload]
command=/opt/reconfigure.sh command=/usr/bin/reconfigure.sh
priority=150 priority=150
autostart=false autostart=false
autorestart=false autorestart=false