mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-12 08:24:52 -05:00
ipatests: Extend domain object with 'ad' role support and WinHosts
Part of: https://fedorahosted.org/freeipa/ticket/3834
This commit is contained in:
1 parent
69a7c1e2ba
commit
5a9b46c9c5
1 file changed
+24
-19
@@ -27,7 +27,7 @@ import random
|
|||||||
from ipapython import ipautil
|
from ipapython import ipautil
|
||||||
from ipapython.dn import DN
|
from ipapython.dn import DN
|
||||||
from ipapython.ipa_log_manager import log_mgr
|
from ipapython.ipa_log_manager import log_mgr
|
||||||
from ipatests.test_integration.host import Host
|
from ipatests.test_integration.host import BaseHost
|
||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
@@ -253,9 +253,10 @@ def env_normalize(env):
|
|||||||
|
|
||||||
|
|
||||||
class Domain(object):
|
class Domain(object):
|
||||||
"""Configuration for an IPA domain"""
|
"""Configuration for an IPA / AD domain"""
|
||||||
def __init__(self, config, name, index):
|
def __init__(self, config, name, index, domain_type):
|
||||||
self.log = log_mgr.get_logger(self)
|
self.log = log_mgr.get_logger(self)
|
||||||
|
self.type = domain_type
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -268,27 +269,27 @@ class Domain(object):
|
|||||||
self.basedn = DN(*(('dc', p) for p in name.split('.')))
|
self.basedn = DN(*(('dc', p) for p in name.split('.')))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_env(cls, env, config, index):
|
def from_env(cls, env, config, index, domain_type):
|
||||||
try:
|
|
||||||
default_domain = env['DOMAIN']
|
|
||||||
except KeyError:
|
|
||||||
hostname, dot, default_domain = env['MASTER_env1'].partition('.')
|
|
||||||
parts = default_domain.split('.')
|
|
||||||
|
|
||||||
if index == 1:
|
# Roles available in the domain depend on the type of the domain
|
||||||
name = default_domain
|
# Unix machines are added only to the IPA domains, Windows machines
|
||||||
|
# only to the AD domains
|
||||||
|
if domain_type == 'IPA':
|
||||||
|
master_role = 'MASTER'
|
||||||
|
domain_roles = 'master', 'replica', 'client', 'other'
|
||||||
else:
|
else:
|
||||||
# For $DOMAIN = dom.example.com, additional domains are
|
master_role = 'AD'
|
||||||
# dom1.example.com, dom2.example.com, etc.
|
domain_roles = 'ad',
|
||||||
parts[0] += str(index)
|
|
||||||
name = '.'.join(parts)
|
|
||||||
|
|
||||||
self = cls(config, name, index)
|
master_env = '%s_env%s' % (master_role, index)
|
||||||
|
hostname, dot, domain_name = env[master_env].partition('.')
|
||||||
|
self = cls(config, domain_name, index, domain_type)
|
||||||
|
|
||||||
for role in 'master', 'replica', 'client', 'other':
|
for role in domain_roles:
|
||||||
value = env.get('%s%s' % (role.upper(), self._env), '')
|
value = env.get('%s%s' % (role.upper(), self._env), '')
|
||||||
|
|
||||||
for index, hostname in enumerate(value.split(), start=1):
|
for index, hostname in enumerate(value.split(), start=1):
|
||||||
host = Host.from_env(env, self, hostname, role, index)
|
host = BaseHost.from_env(env, self, hostname, role, index)
|
||||||
self.hosts.append(host)
|
self.hosts.append(host)
|
||||||
|
|
||||||
if not self.hosts:
|
if not self.hosts:
|
||||||
@@ -322,10 +323,14 @@ class Domain(object):
|
|||||||
def clients(self):
|
def clients(self):
|
||||||
return [h for h in self.hosts if h.role == 'client']
|
return [h for h in self.hosts if h.role == 'client']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ads(self):
|
||||||
|
return [h for h in self.hosts if h.role == 'ad']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def other_hosts(self):
|
def other_hosts(self):
|
||||||
return [h for h in self.hosts
|
return [h for h in self.hosts
|
||||||
if h.role not in ('master', 'client', 'replica')]
|
if h.role not in ('master', 'client', 'replica', 'ad')]
|
||||||
|
|
||||||
def host_by_name(self, name):
|
def host_by_name(self, name):
|
||||||
for host in self.hosts:
|
for host in self.hosts:
|
||||||
|
|||||||
Reference in new issue
Block a user