Commit a02dbfca authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Add an IPv6 check for the QA test of custom SSH ports



If any of the nodes involved would be reached through IPv6, the test is
skipped. This is because the required testing setup using "iptables" is
suiteble only for IPv4 and doesn't work for IPv6 connections.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent b3ad1889
......@@ -52,6 +52,7 @@ import qa_utils
from ganeti import utils
from ganeti import rapi # pylint: disable=W0611
from ganeti import constants
from ganeti import netutils
from ganeti import pathutils
from ganeti.http.auth import ParsePasswordFile
......@@ -612,9 +613,19 @@ def RunCustomSshPortTests():
if not qa_config.TestEnabled("group-custom-ssh-port"):
return
std_port = netutils.GetDaemonPort(constants.SSH)
port = 211
master = qa_config.GetMasterNode()
with qa_config.AcquireManyNodesCtx(1, exclude=master) as nodes:
# Checks if the node(s) could be contacted through IPv6.
# If yes, better skip the whole test.
for node in nodes:
if qa_utils.UsesIPv6Connection(node.primary, std_port):
print ("Node %s is likely to be reached using IPv6,"
"skipping the test" % (node.primary, ))
return
for node in nodes:
qa_node.NodeRemove(node)
with qa_iptables.RulesContext(nodes) as r:
......
......@@ -28,6 +28,7 @@ import operator
import os
import random
import re
import socket
import subprocess
import sys
import tempfile
......@@ -906,3 +907,10 @@ def ParseIPolicy(policy):
else:
ret_policy[key] = val
return (ret_policy, ret_specs)
def UsesIPv6Connection(host, port):
"""Returns True if the connection to a given host/port could go through IPv6.
"""
return any(t[0] == socket.AF_INET6 for t in socket.getaddrinfo(host, port))
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