Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply port configurations after ports are created #49

Merged
merged 3 commits into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dockers/docker-lldp-sv2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ RUN apt-get update && \
rm -rf /deps ~/.cache

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY reconfigure.sh /opt/reconfigure.sh

ENTRYPOINT ["/usr/bin/supervisord"]
53 changes: 53 additions & 0 deletions dockers/docker-lldp-sv2/reconfigure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

set -e

num_of_interfaces=32
if_step=4
last_if_idx=$((num_of_interfaces*if_step - if_step))

function wait_until_if_exists
{
if=$1
while [ ! -L /sys/class/net/"$if" ] ;
do
sleep 1
done
echo interface "$if" is created
}


function wait_until_if_not_exists
{
if=$1
while [ -L /sys/class/net/"$if" ] ;
do
sleep 1
done
echo interface "$if" is destroyed
}


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)
do
wait_until_if_exists "Ethernet$i"
done

echo Wait 10 seconds while lldpd finds new interfaces
sleep 10

# 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)
do
wait_until_if_not_exists "Ethernet$i"
done
done
4 changes: 4 additions & 0 deletions dockers/docker-lldp-sv2/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nodaemon=true
command=/usr/sbin/lldpd -d -I Ethernet*,eth*
priority=100

[program:lldpd-conf-reload]
command=/opt/reconfigure.sh
priority=150

[program:lldp-syncd]
command=/usr/bin/env python2 -m lldp_syncd
priority=200
Expand Down