mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Integration test config: Make it possible to specify host IP
This commit is contained in:
@@ -85,6 +85,8 @@ class Config(object):
|
||||
CLIENT_env1: space-separated FQDNs of the clients
|
||||
OTHER_env1: space-separated FQDNs of other hosts
|
||||
(same for _env2, _env3, etc)
|
||||
BEAKERREPLICA1_IP_env1: IP address of replica 1 in env 1
|
||||
(same for MASTER, CLIENT)
|
||||
|
||||
Also see env_normalize() for alternate variable names
|
||||
"""
|
||||
@@ -165,9 +167,10 @@ class Config(object):
|
||||
# tests. This means no _env<NUM> suffix.
|
||||
if self.domains:
|
||||
default_domain = self.domains[0]
|
||||
env['MASTER'] = default_domain.master.hostname
|
||||
env['BEAKERMASTER'] = default_domain.master.external_hostname
|
||||
env['MASTERIP'] = default_domain.master.ip
|
||||
if default_domain.master:
|
||||
env['MASTER'] = default_domain.master.hostname
|
||||
env['BEAKERMASTER'] = default_domain.master.external_hostname
|
||||
env['MASTERIP'] = default_domain.master.ip
|
||||
env['SLAVE'] = env['REPLICA'] = env['REPLICA_env1']
|
||||
env['BEAKERSLAVE'] = env['BEAKERREPLICA_env1']
|
||||
env['SLAVEIP'] = env['BEAKERREPLICA_IP_env1']
|
||||
@@ -258,8 +261,8 @@ class Domain(object):
|
||||
|
||||
for role in 'master', 'replica', 'client', 'other':
|
||||
value = env.get('%s%s' % (role.upper(), self._env), '')
|
||||
for hostname in value.split():
|
||||
host = Host.from_env(env, self, hostname, role, 1)
|
||||
for index, hostname in enumerate(value.split(), start=1):
|
||||
host = Host.from_env(env, self, hostname, role, index)
|
||||
self.hosts.append(host)
|
||||
|
||||
if not self.hosts:
|
||||
@@ -300,7 +303,7 @@ class Domain(object):
|
||||
|
||||
def host_by_name(self, name):
|
||||
for host in self.hosts:
|
||||
if host.hostname == name or host.external_hostname == name:
|
||||
if name in (host.hostname, host.external_hostname, host.shortname):
|
||||
return host
|
||||
raise LookupError(name)
|
||||
|
||||
|
@@ -119,7 +119,7 @@ class RemoteCommand(object):
|
||||
|
||||
class Host(object):
|
||||
"""Representation of a remote IPA host"""
|
||||
def __init__(self, domain, hostname, role, index):
|
||||
def __init__(self, domain, hostname, role, index, ip=None):
|
||||
self.domain = domain
|
||||
self.role = role
|
||||
self.index = index
|
||||
@@ -133,20 +133,23 @@ class Host(object):
|
||||
self.__module__, type(self).__name__, shortname)
|
||||
self.log = log_mgr.get_logger(self.logger_name)
|
||||
|
||||
if self.config.ipv6:
|
||||
# $(dig +short $M $rrtype|tail -1)
|
||||
stdout, stderr, returncode = ipautil.run(
|
||||
['dig', '+short', self.external_hostname, 'AAAA'])
|
||||
self.ip = stdout.splitlines()[-1].strip()
|
||||
if ip:
|
||||
self.ip = ip
|
||||
else:
|
||||
try:
|
||||
self.ip = socket.gethostbyname(self.external_hostname)
|
||||
except socket.gaierror:
|
||||
self.ip = None
|
||||
if self.config.ipv6:
|
||||
# $(dig +short $M $rrtype|tail -1)
|
||||
stdout, stderr, returncode = ipautil.run(
|
||||
['dig', '+short', self.external_hostname, 'AAAA'])
|
||||
self.ip = stdout.splitlines()[-1].strip()
|
||||
else:
|
||||
try:
|
||||
self.ip = socket.gethostbyname(self.external_hostname)
|
||||
except socket.gaierror:
|
||||
self.ip = None
|
||||
|
||||
if not self.ip:
|
||||
self.ip = ''
|
||||
self.role = 'other'
|
||||
if not self.ip:
|
||||
raise RuntimeError('Could not determine IP address of %s' %
|
||||
self.external_hostname)
|
||||
|
||||
self.root_password = self.config.root_password
|
||||
self.root_ssh_key_filename = self.config.root_ssh_key_filename
|
||||
@@ -164,7 +167,9 @@ class Host(object):
|
||||
|
||||
@classmethod
|
||||
def from_env(cls, env, domain, hostname, role, index):
|
||||
self = cls(domain, hostname, role, index)
|
||||
ip = env.get('BEAKER%s%s_IP_env%s' %
|
||||
(role.upper(), index, domain.index), None)
|
||||
self = cls(domain, hostname, role, index, ip)
|
||||
return self
|
||||
|
||||
@property
|
||||
|
Reference in New Issue
Block a user