Commit 9769bb78 authored by Manuel Franceschini's avatar Manuel Franceschini
Browse files

Rename some constants to facilitate IPv6 support


Signed-off-by: default avatarManuel Franceschini <livewire@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent e0dbb89b
......@@ -701,13 +701,13 @@ def main():
# If RAPI isn't responding to queries, try one restart.
logging.debug("Attempting to talk with RAPI.")
if not IsRapiResponding(constants.LOCALHOST_IP_ADDRESS):
if not IsRapiResponding(constants.IP4_ADDRESS_LOCALHOST):
logging.warning("Couldn't get answer from Ganeti RAPI daemon."
" Restarting Ganeti RAPI.")
utils.StopDaemon(constants.RAPI)
utils.EnsureDaemon(constants.RAPI)
logging.debug("Second attempt to talk with RAPI")
if not IsRapiResponding(constants.LOCALHOST_IP_ADDRESS):
if not IsRapiResponding(constants.IP4_ADDRESS_LOCALHOST):
logging.fatal("RAPI is not responding. Please investigate.")
logging.debug("Successfully talked to RAPI.")
......
......@@ -539,7 +539,7 @@ def VerifyNode(what, cluster_name):
# rest of the function)
master_name, master_ip = what[constants.NV_MASTERIP]
if master_name == my_name:
source = constants.LOCALHOST_IP_ADDRESS
source = constants.IP4_ADDRESS_LOCALHOST
else:
source = None
result[constants.NV_MASTERIP] = utils.TcpPing(master_ip, port,
......
......@@ -434,11 +434,11 @@ MAX_TAGS_PER_OBJ = 4096
# others
DEFAULT_BRIDGE = "xen-br0"
SYNC_SPEED = 60 * 1024
LOCALHOST_IP_ADDRESS = "127.0.0.1"
IP4_ADDRESS_LOCALHOST = "127.0.0.1"
IP4_ADDRESS_ANY = "0.0.0.0"
TCP_PING_TIMEOUT = 10
GANETI_RUNAS = "root"
DEFAULT_VG = "xenvg"
BIND_ADDRESS_GLOBAL = "0.0.0.0"
MIN_VG_SIZE = 20480
DEFAULT_MAC_PREFIX = "aa:00:00"
LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
......@@ -635,7 +635,7 @@ HTS_REQ_PORT = frozenset([HT_XEN_HVM, HT_KVM])
VNC_BASE_PORT = 5900
VNC_PASSWORD_FILE = CONF_DIR + "/vnc-cluster-password"
VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
VNC_DEFAULT_BIND_ADDRESS = IP4_ADDRESS_ANY
# NIC types
HT_NIC_RTL8139 = "rtl8139"
......@@ -833,7 +833,7 @@ HVC_DEFAULTS = {
HV_CDROM_IMAGE_PATH: '',
HV_NIC_TYPE: HT_NIC_RTL8139,
HV_DISK_TYPE: HT_DISK_PARAVIRTUAL,
HV_VNC_BIND_ADDRESS: '0.0.0.0',
HV_VNC_BIND_ADDRESS: IP4_ADDRESS_ANY,
HV_VNC_PASSWORD_FILE: VNC_PASSWORD_FILE,
HV_ACPI: True,
HV_PAE: True,
......
......@@ -1740,7 +1740,7 @@ def OwnIpAddress(address):
"""
return TcpPing(address, constants.DEFAULT_NODED_PORT,
source=constants.LOCALHOST_IP_ADDRESS)
source=constants.IP4_ADDRESS_LOCALHOST)
def ListVisibleFiles(path):
......
......@@ -1187,7 +1187,7 @@ def ShowInstanceConfig(opts, args):
if vnc_bind_address:
port = instance["network_port"]
display = int(port) - constants.VNC_BASE_PORT
if display > 0 and vnc_bind_address == constants.BIND_ADDRESS_GLOBAL:
if display > 0 and vnc_bind_address == constants.IP4_ADDRESS_ANY:
vnc_console_port = "%s:%s (display %s)" % (instance["pnode"],
port,
display)
......
......@@ -73,7 +73,7 @@ class TestX509Certificates(unittest.TestCase):
class TestNodeVerify(testutils.GanetiTestCase):
def testMasterIPLocalhost(self):
# this a real functional test, but requires localhost to be reachable
local_data = (utils.HostInfo().name, constants.LOCALHOST_IP_ADDRESS)
local_data = (utils.HostInfo().name, constants.IP4_ADDRESS_LOCALHOST)
result = backend.VerifyNode({constants.NV_MASTERIP: local_data}, None)
self.failUnless(constants.NV_MASTERIP in result,
"Master IP data not returned")
......
......@@ -60,7 +60,7 @@ class TestConfigRunner(unittest.TestCase):
def _init_cluster(self, cfg):
"""Initializes the cfg object"""
me = utils.HostInfo()
ip = constants.LOCALHOST_IP_ADDRESS
ip = constants.IP4_ADDRESS_LOCALHOST
cluster_config = objects.Cluster(
serial_no=1,
......
......@@ -1169,7 +1169,7 @@ class TestTcpPing(unittest.TestCase):
def setUp(self):
self.listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.listener.bind((constants.LOCALHOST_IP_ADDRESS, 0))
self.listener.bind((constants.IP4_ADDRESS_LOCALHOST, 0))
self.listenerport = self.listener.getsockname()[1]
self.listener.listen(1)
......@@ -1179,15 +1179,15 @@ class TestTcpPing(unittest.TestCase):
del self.listenerport
def testTcpPingToLocalHostAccept(self):
self.assert_(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.assert_(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.listenerport,
timeout=10,
live_port_needed=True,
source=constants.LOCALHOST_IP_ADDRESS,
source=constants.IP4_ADDRESS_LOCALHOST,
),
"failed to connect to test listener")
self.assert_(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.assert_(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.listenerport,
timeout=10,
live_port_needed=True,
......@@ -1200,7 +1200,7 @@ class TestTcpPingDeaf(unittest.TestCase):
def setUp(self):
self.deaflistener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.deaflistener.bind((constants.LOCALHOST_IP_ADDRESS, 0))
self.deaflistener.bind((constants.IP4_ADDRESS_LOCALHOST, 0))
self.deaflistenerport = self.deaflistener.getsockname()[1]
def tearDown(self):
......@@ -1208,15 +1208,15 @@ class TestTcpPingDeaf(unittest.TestCase):
del self.deaflistenerport
def testTcpPingToLocalHostAcceptDeaf(self):
self.failIf(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.failIf(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.deaflistenerport,
timeout=constants.TCP_PING_TIMEOUT,
live_port_needed=True,
source=constants.LOCALHOST_IP_ADDRESS,
source=constants.IP4_ADDRESS_LOCALHOST,
), # need successful connect(2)
"successfully connected to deaf listener")
self.failIf(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.failIf(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.deaflistenerport,
timeout=constants.TCP_PING_TIMEOUT,
live_port_needed=True,
......@@ -1224,15 +1224,15 @@ class TestTcpPingDeaf(unittest.TestCase):
"successfully connected to deaf listener (no source addr)")
def testTcpPingToLocalHostNoAccept(self):
self.assert_(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.assert_(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.deaflistenerport,
timeout=constants.TCP_PING_TIMEOUT,
live_port_needed=False,
source=constants.LOCALHOST_IP_ADDRESS,
source=constants.IP4_ADDRESS_LOCALHOST,
), # ECONNREFUSED is OK
"failed to ping alive host on deaf port")
self.assert_(TcpPing(constants.LOCALHOST_IP_ADDRESS,
self.assert_(TcpPing(constants.IP4_ADDRESS_LOCALHOST,
self.deaflistenerport,
timeout=constants.TCP_PING_TIMEOUT,
live_port_needed=False,
......@@ -1245,7 +1245,7 @@ class TestOwnIpAddress(unittest.TestCase):
def testOwnLoopback(self):
"""check having the loopback ip"""
self.failUnless(OwnIpAddress(constants.LOCALHOST_IP_ADDRESS),
self.failUnless(OwnIpAddress(constants.IP4_ADDRESS_LOCALHOST),
"Should own the loopback address")
def testNowOwnAddress(self):
......
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