kolla/docker/openvswitch/openvswitch-db-server/ovs_ensure_configured.sh
Erik Panter a840ac0d7c relay non-zero exit codes when creating openvswitch bridges
Calls to `ovs-vsctl` in `ovs_ensure_configured.sh` did not get checked
for errors.
This can cause false success statuses when
the script is run by automation tools such as ansible.

Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/870540

Closes-bug: #1999778
Change-Id: Iad83132b61efadbf09aa9aa2edf96235085764c6
2023-01-16 13:25:40 +00:00

23 lines
404 B
Bash

#!/bin/bash
set -o errexit
bridge=$1
port=$2
if ! ip link show $port; then
# fail when device doesn't exist
exit 1
fi
ovs-vsctl br-exists $bridge || if [[ $? -eq 2 ]]; then
changed=changed
ovs-vsctl --no-wait add-br $bridge
fi
if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then
changed=changed
ovs-vsctl --no-wait add-port $bridge $port
fi
echo $changed