Commit 5866dda7 authored by ssrq's avatar ssrq

[type/__bridge] Make --port optional

…to support a new use case: only create the bridge using cdist but add ports
later using other software.
parent 6d057bbb
Pipeline #2752 passed with stage
in 1 minute and 13 seconds
......@@ -37,13 +37,13 @@ in
;;
esac
bridge_ports= # space-separated list
bridge_stp='off'
cd "${__object:?}/parameter"
for param in *
do
case $param
case ${param}
in
(bootproto)
bootproto=$(cat "${__object:?}/parameter/bootproto")
......@@ -54,7 +54,7 @@ do
exit 1
;;
(port)
case $systype
case ${systype}
in
(redhat)
# TOOD
......@@ -67,13 +67,10 @@ do
printf 'Invalid bridge port name: %s\n' "${_port}" >&2
exit 1
}
set -- "$@" "${_port}"
printf ' %s' "${_port}"
done <"${__object:?}/parameter/port"
echo "$*"
)
set -- "$@" --extra-config "BRIDGE_PORTS='${bridge_ports}'"
unset bridge_ports
bridge_ports=${bridge_ports# }
;;
esac
;;
......@@ -90,6 +87,8 @@ do
esac
done
# Set bridge ports
set -- "$@" --extra-config "BRIDGE_PORTS='${bridge_ports}'"
# Set boolean options
case $systype
......
......@@ -22,19 +22,20 @@
__package_apt bridge-utils
export require=__package_apt/bridge-utils
bridge_ports='none' # space-separated list
bridge_stp='off'
enable_hotplug=no
cd "${__object:?}/parameter"
for param in *
do
case $param
case ${param}
in
(bootproto)
bootproto=$(cat "${__object:?}/parameter/bootproto")
set -- "$@" --bootproto "${bootproto}"
case $bootproto
case ${bootproto}
in
(manual)
# if set to manual, there is nothing to wait for…
......@@ -49,19 +50,18 @@ do
enable_hotplug=yes
;;
(port)
while read -r _port
do
test -z "$(echo "${_port}" | tr -d 'A-Za-z0-9')" || {
printf 'Invalid bridge port name: %s\n' "${_port}" >&2
exit 1
}
bridge_ports=$(
while read -r _port
do
test -z "$(echo "${_port}" | tr -d 'A-Za-z0-9')" || {
printf 'Invalid bridge port name: %s\n' "${_port}" >&2
exit 1
}
bridge_ports="${bridge_ports-} ${_port}"
done <"${__object:?}/parameter/port"
unset _port
set -- "$@" --extra-config "bridge_ports${bridge_ports}"
unset bridge_ports
printf ' %s' "${_port}"
done <"${__object:?}/parameter/port"
)
bridge_ports=${bridge_ports# }
;;
(stp)
bridge_stp='on'
......@@ -77,6 +77,9 @@ do
done
# Set bridge ports
set -- "$@" --extra-config "bridge_ports ${bridge_ports}"
# Set boolean options
set -- "$@" --extra-config "bridge_stp ${bridge_stp}"
test "${bridge_stp}" = 'on' || set -- "$@" --extra-config 'bridge_fd 0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment