Remove requirement on system oslo.utils
This was only working because the noVNC package on Ubuntu pulls in oslo.utils. Change-Id: I3733df3e2667f16082b3ff57d39cf086d81fbe02 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
41
tools/verify-ipv6-address.py
Normal file
41
tools/verify-ipv6-address.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import ipaddress
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Check if a given string is a valid IPv6 address.",
|
||||||
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"address",
|
||||||
|
help=(
|
||||||
|
"The IPv6 address string to validate.\n"
|
||||||
|
"Examples:\n"
|
||||||
|
" 2001:0db8:85a3:0000:0000:8a2e:0370:7334\n"
|
||||||
|
" 2001:db8::1\n"
|
||||||
|
" ::1\n"
|
||||||
|
" fe80::1%eth0 (scope IDs are handled)"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# try to create a IPv6Address: if we fail to parse or get an
|
||||||
|
# IPv4Address then die
|
||||||
|
ip_obj = ipaddress.ip_address(args.address.strip('[]'))
|
||||||
|
if isinstance(ip_obj, ipaddress.IPv6Address):
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
sys.exit(1)
|
||||||
|
except ValueError:
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An unexpected error occurred during validation: {e}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -33,28 +33,23 @@ function verify_devstack_ipv6_setting {
|
|||||||
echo $TUNNEL_IP_VERSION "TUNNEL_IP_VERSION is not set to 6 so TUNNEL_ENDPOINT_IP cannot be an IPv6 address."
|
echo $TUNNEL_IP_VERSION "TUNNEL_IP_VERSION is not set to 6 so TUNNEL_ENDPOINT_IP cannot be an IPv6 address."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
is_service_host_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_host'"))')
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$_service_host"; then
|
||||||
if [[ "$is_service_host_ipv6" != "True" ]]; then
|
|
||||||
echo $SERVICE_HOST "SERVICE_HOST is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
echo $SERVICE_HOST "SERVICE_HOST is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
is_host_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_host_ipv6'"))')
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$_host_ipv6"; then
|
||||||
if [[ "$is_host_ipv6" != "True" ]]; then
|
|
||||||
echo $HOST_IPV6 "HOST_IPV6 is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
echo $HOST_IPV6 "HOST_IPV6 is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
is_service_listen_address=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_listen_address'"))')
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$_service_listen_address"; then
|
||||||
if [[ "$is_service_listen_address" != "True" ]]; then
|
|
||||||
echo $SERVICE_LISTEN_ADDRESS "SERVICE_LISTEN_ADDRESS is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
echo $SERVICE_LISTEN_ADDRESS "SERVICE_LISTEN_ADDRESS is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
is_service_local_host=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_service_local_host'"))')
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$_service_local_host"; then
|
||||||
if [[ "$is_service_local_host" != "True" ]]; then
|
|
||||||
echo $SERVICE_LOCAL_HOST "SERVICE_LOCAL_HOST is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
echo $SERVICE_LOCAL_HOST "SERVICE_LOCAL_HOST is not IPv6 which means devstack cannot deploy services on IPv6 addresses."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
is_tunnel_endpoint_ip=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$_tunnel_endpoint_ip'"))')
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$_tunnel_endpoint_ip"; then
|
||||||
if [[ "$is_tunnel_endpoint_ip" != "True" ]]; then
|
|
||||||
echo $TUNNEL_ENDPOINT_IP "TUNNEL_ENDPOINT_IP is not IPv6 which means devstack will not deploy with an IPv6 endpoint address."
|
echo $TUNNEL_ENDPOINT_IP "TUNNEL_ENDPOINT_IP is not IPv6 which means devstack will not deploy with an IPv6 endpoint address."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -63,8 +58,7 @@ function verify_devstack_ipv6_setting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sanity_check_system_ipv6_enabled {
|
function sanity_check_system_ipv6_enabled {
|
||||||
system_ipv6_enabled=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_ipv6_enabled())')
|
if [ ! -f "/proc/sys/net/ipv6/conf/default/disable_ipv6" ] || [ "$(cat /proc/sys/net/ipv6/conf/default/disable_ipv6)" -ne "0" ]; then
|
||||||
if [[ $system_ipv6_enabled != "True" ]]; then
|
|
||||||
echo "IPv6 is disabled in system"
|
echo "IPv6 is disabled in system"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -78,10 +72,8 @@ function verify_service_listen_address_is_ipv6 {
|
|||||||
for endpoint in ${endpoints}; do
|
for endpoint in ${endpoints}; do
|
||||||
local endpoint_address=''
|
local endpoint_address=''
|
||||||
endpoint_address=$(echo "$endpoint" | awk -F/ '{print $3}' | awk -F] '{print $1}')
|
endpoint_address=$(echo "$endpoint" | awk -F/ '{print $3}' | awk -F] '{print $1}')
|
||||||
endpoint_address=$(echo $endpoint_address | tr -d [])
|
endpoint_address=$(echo $endpoint_address | tr -d '[]')
|
||||||
local is_endpoint_ipv6=''
|
if ! python3 ${TOP_DIR}/tools/verify-ipv6-address.py "$endpoint_address"; then
|
||||||
is_endpoint_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$endpoint_address'"))')
|
|
||||||
if [[ "$is_endpoint_ipv6" != "True" ]]; then
|
|
||||||
all_ipv6=False
|
all_ipv6=False
|
||||||
echo $endpoint ": This is not an IPv6 endpoint which means corresponding service is not listening on an IPv6 address."
|
echo $endpoint ": This is not an IPv6 endpoint which means corresponding service is not listening on an IPv6 address."
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user