Use "ip addr replace" when adding IP addresses
Uses the idempotent "replace" action while adding IP addresses. This way the action will not fail if this IP already exists on the interface. Change-Id: I2cbe40a3686335896889dda86bc1b0326eb2e066 Signed-off-by: Stanislav Datskevych <me@nek0.net>
This commit is contained in:
@@ -117,15 +117,15 @@ function migrate_ip_from_nic {
|
||||
if [[ -n "${ip}" && -n "${prefix}" ]]; then
|
||||
ip addr flush dev ${src_nic}
|
||||
if [ $? -ne 0 ] ; then
|
||||
ip addr add ${ip}/${prefix} dev ${src_nic}
|
||||
ip addr replace ${ip}/${prefix} dev ${src_nic}
|
||||
echo "Error while flushing IP from ${src_nic}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ip addr add ${ip}/${prefix} dev "${bridge_name}"
|
||||
ip addr replace ${ip}/${prefix} dev "${bridge_name}"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Error assigning IP to bridge "${bridge_name}"."
|
||||
ip addr add ${ip}/${prefix} dev ${src_nic}
|
||||
ip addr replace ${ip}/${prefix} dev ${src_nic}
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "${bridge_ip}" && -n "${bridge_prefix}" ]]; then
|
||||
|
||||
@@ -54,15 +54,15 @@ function migrate_ip_from_nic {
|
||||
if [[ -n "${ip}" && -n "${prefix}" ]]; then
|
||||
ip addr flush dev ${src_nic}
|
||||
if [ $? -ne 0 ] ; then
|
||||
ip addr add ${ip}/${prefix} dev ${src_nic}
|
||||
ip addr replace ${ip}/${prefix} dev ${src_nic}
|
||||
echo "Error while flushing IP from ${src_nic}."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ip addr add ${ip}/${prefix} dev "${bridge_name}"
|
||||
ip addr replace ${ip}/${prefix} dev "${bridge_name}"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Error assigning IP to bridge "${bridge_name}"."
|
||||
ip addr add ${ip}/${prefix} dev ${src_nic}
|
||||
ip addr replace ${ip}/${prefix} dev ${src_nic}
|
||||
exit 1
|
||||
fi
|
||||
elif [[ -n "${bridge_ip}" && -n "${bridge_prefix}" ]]; then
|
||||
|
||||
13
releasenotes/notes/neutron-2af36e49a0a377c3.yaml
Normal file
13
releasenotes/notes/neutron-2af36e49a0a377c3.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# To create a new release note related to a specific chart:
|
||||
# reno new <chart_name>
|
||||
#
|
||||
# To create a new release note for a common change (when multiple charts
|
||||
# are changed):
|
||||
# reno new common
|
||||
neutron:
|
||||
- |
|
||||
Use `ip add replace` instead of `ip addr add` in the init script to
|
||||
make it idempotent and avoid errors when the script tries to assign
|
||||
the same IP address to the interface on subsequent runs.
|
||||
...
|
||||
13
releasenotes/notes/ovn-ffd84bb8c9e73b64.yaml
Normal file
13
releasenotes/notes/ovn-ffd84bb8c9e73b64.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
# To create a new release note related to a specific chart:
|
||||
# reno new <chart_name>
|
||||
#
|
||||
# To create a new release note for a common change (when multiple charts
|
||||
# are changed):
|
||||
# reno new common
|
||||
ovn:
|
||||
- |
|
||||
Use `ip add replace` instead of `ip addr add` in the init script to
|
||||
make it idempotent and avoid errors when the script tries to assign
|
||||
the same IP address to the interface on subsequent runs.
|
||||
...
|
||||
Reference in New Issue
Block a user