Use ipaddress module

This patch replaces use of ipaddr python module with
ipaddress module. The ipaddr has been superseded by the
ipaddress module.

Also install python-ipaddress instead of python-ipaddr in
deployed-server bootstrap scripts.

Closes-Bug: #1751934
Change-Id: I63ae89869c8994e17b3460f9ae94e5fa922f6237
This commit is contained in:
Harald Jensas 2018-02-26 23:19:30 +01:00
parent e0f59eefd2
commit d0a03972a6
3 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ set -eux
yum install -y \ yum install -y \
jq \ jq \
python-ipaddr \ python-ipaddress \
puppet-tripleo \ puppet-tripleo \
os-net-config \ os-net-config \
openvswitch \ openvswitch \

View File

@ -4,7 +4,7 @@ set -eux
yum install -y \ yum install -y \
jq \ jq \
python-ipaddr \ python-ipaddress \
puppet-tripleo\ puppet-tripleo\
os-net-config \ os-net-config \
openvswitch \ openvswitch \

View File

@ -33,7 +33,7 @@ function ping_controller_ips() {
networks=$(ip r | grep -v default | cut -d " " -f 1) networks=$(ip r | grep -v default | cut -d " " -f 1)
fi fi
for LOCAL_NETWORK in $networks; do for LOCAL_NETWORK in $networks; do
in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)") in_network=$(python -c "import ipaddress; net=ipaddress.ip_network(unicode('$LOCAL_NETWORK')); addr=ipaddress.ip_address(unicode('$REMOTE_IP')); print(addr in net)")
if [[ $in_network == "True" ]]; then if [[ $in_network == "True" ]]; then
echo "Trying to ping $REMOTE_IP for local network ${LOCAL_NETWORK}." echo "Trying to ping $REMOTE_IP for local network ${LOCAL_NETWORK}."
set +e set +e