mirror of
https://github.com/GNS3/gns3-registry.git
synced 2024-12-18 20:37:57 +00:00
openvswitch - fix multiple issues, ref #885
This commit is contained in:
parent
1e210bfa72
commit
867d9dffad
@ -16,6 +16,6 @@
|
||||
"docker": {
|
||||
"adapters": 16,
|
||||
"image": "gns3/openvswitch:latest",
|
||||
"environment": "MANAGEMENT_INTERFACE=1"
|
||||
"environment": "MANAGEMENT_INTERFACE=eth0"
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ RUN apk add --no-cache openvswitch nano bash bash-completion
|
||||
RUN sed -i s,/bin/ash,/bin/bash, /etc/passwd
|
||||
|
||||
# Enable bash completion
|
||||
RUN echo -e "source /etc/profile.d/bash_completion.sh" >> ~/.bashrc
|
||||
RUN echo -e "source /etc/bash/bash_completion.sh" >> ~/.bashrc
|
||||
|
||||
# Enable openvswitch bash completion
|
||||
RUN echo -e "source /usr/share/bash-completion/completions/ovs-vsctl-bashcomp.bash" >> ~/.bashrc
|
||||
@ -15,10 +15,8 @@ RUN echo -e "source /usr/share/bash-completion/completions/ovs-appctl-bashcomp.b
|
||||
# Configure the prompt
|
||||
RUN echo -e "PS1='\h:\w\$ '" >> ~/.bashrc
|
||||
|
||||
RUN mkdir /var/run/openvswitch
|
||||
VOLUME [ "/root", "/etc/openvswitch" ]
|
||||
|
||||
VOLUME /etc/openvswitch/
|
||||
ADD init.sh /etc/openvswitch/
|
||||
|
||||
ADD boot.sh /bin/boot.sh
|
||||
|
||||
CMD /bin/bash /bin/boot.sh
|
||||
CMD /etc/openvswitch/init.sh; bash
|
||||
|
18
docker/openvswitch/README.md
Normal file
18
docker/openvswitch/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Docker Open vSwitch for GNS3
|
||||
|
||||
This creates a container for using Open vSwitch in GNS3.
|
||||
|
||||
This container supports ethernet interfaces and comes
|
||||
with bridges from br0 to br3.
|
||||
|
||||
By default, all interfaces are connected to br0.
|
||||
|
||||
If you set the `MANAGEMENT_INTERFACE` environment variable to
|
||||
an interface name, that interface will not be connected to br0.
|
||||
|
||||
|
||||
## Building the container
|
||||
|
||||
```
|
||||
docker build -t gns3/openvswitch .
|
||||
```
|
@ -1,19 +0,0 @@
|
||||
Docker Open vSwitch for GNS3
|
||||
------------------------------
|
||||
|
||||
This make a container for using Open vSwitch in GNS3 1.5 and later.
|
||||
|
||||
This container support 16 ethernet interface and is shipped with
|
||||
bridge from br0 to br3.
|
||||
|
||||
By default all interface are connected to the br0.
|
||||
|
||||
If you set the environnement variable MANAGEMENT_INTERFACE to 1
|
||||
eth0 will not be attach to the container.
|
||||
|
||||
Building the container
|
||||
#######################
|
||||
|
||||
.. code:: bash
|
||||
|
||||
docker build -t gns3/openvswitch .
|
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2024 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
if [[ ! -f "/etc/openvswitch/conf.db" ]]
|
||||
then
|
||||
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
|
||||
|
||||
ovsdb-server --detach --pidfile --remote=punix:/var/run/openvswitch/db.sock
|
||||
ovs-vswitchd --detach --pidfile
|
||||
ovs-vsctl --no-wait init
|
||||
|
||||
x=0
|
||||
until [[ $x = "4" ]]; do
|
||||
ovs-vsctl add-br br$x
|
||||
ovs-vsctl set bridge br$x datapath_type=netdev
|
||||
x=$((x+1))
|
||||
done
|
||||
|
||||
if [[ $MANAGEMENT_INTERFACE == 1 ]]
|
||||
then
|
||||
x=1
|
||||
else
|
||||
x=0
|
||||
fi
|
||||
|
||||
until [[ $x = "16" ]]; do
|
||||
ovs-vsctl add-port br0 eth$x
|
||||
x=$((x+1))
|
||||
done
|
||||
else
|
||||
ovsdb-server --detach --pidfile --remote=punix:/var/run/openvswitch/db.sock
|
||||
ovs-vswitchd --detach --pidfile
|
||||
fi
|
||||
|
||||
|
||||
x=0
|
||||
until [[ $x = "4" ]]; do
|
||||
ip link set dev br$x up
|
||||
x=$((x+1))
|
||||
done
|
||||
|
||||
/bin/bash
|
52
docker/openvswitch/init.sh
Executable file
52
docker/openvswitch/init.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2024 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
firstrun=0
|
||||
[ -f "/etc/openvswitch/conf.db" ] || firstrun=1
|
||||
|
||||
if [ $firstrun -ne 0 ]; then
|
||||
# create database
|
||||
ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
|
||||
fi
|
||||
|
||||
# start openvswitch daemons
|
||||
mkdir -p /var/log/openvswitch /var/run/openvswitch
|
||||
ovsdb-server --detach --pidfile --remote=punix:/var/run/openvswitch/db.sock \
|
||||
--log-file --verbose=off:syslog
|
||||
ovs-vswitchd --detach --pidfile --log-file --verbose=off:syslog
|
||||
|
||||
if [ $firstrun -ne 0 ]; then
|
||||
ovs-vsctl --no-wait init
|
||||
|
||||
# create br0..br3
|
||||
for intf in br0 br1 br2 br3; do
|
||||
ovs-vsctl add-br $intf
|
||||
ovs-vsctl set bridge $intf datapath_type=netdev
|
||||
done
|
||||
|
||||
# add all ethernet interfaces to br0, except MANAGEMENT_INTERFACE
|
||||
[ "$MANAGEMENT_INTERFACE" = 1 ] && MANAGEMENT_INTERFACE=eth0
|
||||
sed -n 's/^ *\(eth[0-9]*\): .*/\1/p' /proc/net/dev | sort -V | \
|
||||
while read -r intf; do
|
||||
[ "$intf" = "$MANAGEMENT_INTERFACE" ] || ovs-vsctl add-port br0 "$intf"
|
||||
done
|
||||
fi
|
||||
|
||||
# activate br0..br3
|
||||
for intf in br0 br1 br2 br3; do
|
||||
ip link set dev $intf up
|
||||
done
|
Loading…
Reference in New Issue
Block a user