|
|
86baa9 |
From fc64de3f833ab63f2b2ee8984db95866b3f718a7 Mon Sep 17 00:00:00 2001
|
|
|
86baa9 |
From: Christian Heimes <cheimes@redhat.com>
|
|
|
86baa9 |
Date: Fri, 22 Mar 2019 15:14:06 +0100
|
|
|
86baa9 |
Subject: [PATCH] Add hidden replica feature
|
|
|
86baa9 |
|
|
|
86baa9 |
A hidden replica is a replica that does not advertise its services via
|
|
|
86baa9 |
DNS SRV records, ipa-ca DNS entry, or LDAP. Clients do not auto-select a
|
|
|
86baa9 |
hidden replica, but are still free to explicitly connect to it.
|
|
|
86baa9 |
|
|
|
86baa9 |
Fixes: https://pagure.io/freeipa/issue/7892
|
|
|
86baa9 |
Co-authored-by: Francois Cami <fcami@redhat.com>:
|
|
|
86baa9 |
Signed-off-by: Christian Heimes <cheimes@redhat.com>
|
|
|
86baa9 |
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
|
|
|
86baa9 |
Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
86baa9 |
---
|
|
|
86baa9 |
API.txt | 2 +-
|
|
|
86baa9 |
install/tools/ipactl | 12 ++++-
|
|
|
86baa9 |
ipaserver/install/server/__init__.py | 7 +++
|
|
|
86baa9 |
ipaserver/install/server/replicainstall.py | 11 ++++-
|
|
|
86baa9 |
ipaserver/install/service.py | 57 +++++++++++++++++-----
|
|
|
86baa9 |
ipaserver/masters.py | 46 ++++++++++++-----
|
|
|
86baa9 |
ipaserver/plugins/serverrole.py | 2 +-
|
|
|
86baa9 |
ipaserver/servroles.py | 27 +++++++---
|
|
|
86baa9 |
8 files changed, 131 insertions(+), 33 deletions(-)
|
|
|
86baa9 |
|
|
|
86baa9 |
diff --git a/API.txt b/API.txt
|
|
|
86baa9 |
index b9dc35fb5752ce04f58aa8c4c3e89c7299f34cd7..2135300183e3dc2126309e8f892e79fe6b5178fb 100644
|
|
|
86baa9 |
--- a/API.txt
|
|
|
86baa9 |
+++ b/API.txt
|
|
|
86baa9 |
@@ -4443,7 +4443,7 @@ option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
|
|
86baa9 |
option: Str('role_servrole?', autofill=False, cli_name='role')
|
|
|
86baa9 |
option: Str('server_server?', autofill=False, cli_name='server')
|
|
|
86baa9 |
option: Int('sizelimit?', autofill=False)
|
|
|
86baa9 |
-option: StrEnum('status?', autofill=False, cli_name='status', default=u'enabled', values=[u'enabled', u'configured', u'absent'])
|
|
|
86baa9 |
+option: StrEnum('status?', autofill=False, cli_name='status', default=u'enabled', values=[u'enabled', u'configured', u'hidden', u'absent'])
|
|
|
86baa9 |
option: Int('timelimit?', autofill=False)
|
|
|
86baa9 |
option: Str('version?')
|
|
|
86baa9 |
output: Output('count', type=[<type 'int'>])
|
|
|
86baa9 |
diff --git a/install/tools/ipactl b/install/tools/ipactl
|
|
|
86baa9 |
index 2767a26d1b70337d37dbcd87c707919579fe7e29..f40ea5a6df74f04ec7e6e8959d731553651a81d3 100755
|
|
|
86baa9 |
--- a/install/tools/ipactl
|
|
|
86baa9 |
+++ b/install/tools/ipactl
|
|
|
86baa9 |
@@ -29,6 +29,7 @@ import ldapurl
|
|
|
86baa9 |
from ipaserver.install import service, installutils
|
|
|
86baa9 |
from ipaserver.install.dsinstance import config_dirname
|
|
|
86baa9 |
from ipaserver.install.installutils import is_ipa_configured, ScriptError
|
|
|
86baa9 |
+from ipaserver.masters import ENABLED_SERVICE, HIDDEN_SERVICE
|
|
|
86baa9 |
from ipalib import api, errors
|
|
|
86baa9 |
from ipapython.ipaldap import LDAPClient
|
|
|
86baa9 |
from ipapython.ipautil import wait_for_open_ports, wait_for_open_socket
|
|
|
86baa9 |
@@ -162,7 +163,16 @@ def version_check():
|
|
|
86baa9 |
|
|
|
86baa9 |
def get_config(dirsrv):
|
|
|
86baa9 |
base = DN(('cn', api.env.host), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'), api.env.basedn)
|
|
|
86baa9 |
- srcfilter = '(ipaConfigString=enabledService)'
|
|
|
86baa9 |
+ srcfilter = LDAPClient.combine_filters(
|
|
|
86baa9 |
+ [
|
|
|
86baa9 |
+ LDAPClient.make_filter({'objectClass': 'ipaConfigObject'}),
|
|
|
86baa9 |
+ LDAPClient.make_filter(
|
|
|
86baa9 |
+ {'ipaConfigString': [ENABLED_SERVICE, HIDDEN_SERVICE]},
|
|
|
86baa9 |
+ rules=LDAPClient.MATCH_ANY
|
|
|
86baa9 |
+ ),
|
|
|
86baa9 |
+ ],
|
|
|
86baa9 |
+ rules=LDAPClient.MATCH_ALL
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
attrs = ['cn', 'ipaConfigString']
|
|
|
86baa9 |
if not dirsrv.is_running():
|
|
|
86baa9 |
raise IpactlError("Failed to get list of services to probe status:\n" +
|
|
|
86baa9 |
diff --git a/ipaserver/install/server/__init__.py b/ipaserver/install/server/__init__.py
|
|
|
86baa9 |
index b6c01d0971b827dc1547adcfff48fbcb545f4b18..f20b3dac4c7f79454a2b8871409319578ee2eb9e 100644
|
|
|
86baa9 |
--- a/ipaserver/install/server/__init__.py
|
|
|
86baa9 |
+++ b/ipaserver/install/server/__init__.py
|
|
|
86baa9 |
@@ -240,6 +240,13 @@ class ServerInstallInterface(ServerCertificateInstallInterface,
|
|
|
86baa9 |
)
|
|
|
86baa9 |
master_password = master_install_only(master_password)
|
|
|
86baa9 |
|
|
|
86baa9 |
+ hidden_replica = knob(
|
|
|
86baa9 |
+ None,
|
|
|
86baa9 |
+ cli_names='--hidden-replica',
|
|
|
86baa9 |
+ description="Install a hidden replica",
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
+ hidden_replica = replica_install_only(hidden_replica)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
domain_level = knob(
|
|
|
86baa9 |
int, constants.MAX_DOMAIN_LEVEL,
|
|
|
86baa9 |
description="IPA domain level",
|
|
|
86baa9 |
diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py
|
|
|
86baa9 |
index 37ecbe4146fa908c30fb708037fcaa47af1a258b..7178238bfb996f987b5e3beaebe05fa104ada089 100644
|
|
|
86baa9 |
--- a/ipaserver/install/server/replicainstall.py
|
|
|
86baa9 |
+++ b/ipaserver/install/server/replicainstall.py
|
|
|
86baa9 |
@@ -1055,6 +1055,7 @@ def promote_check(installer):
|
|
|
86baa9 |
config.setup_kra = options.setup_kra
|
|
|
86baa9 |
config.dir = installer._top_dir
|
|
|
86baa9 |
config.basedn = api.env.basedn
|
|
|
86baa9 |
+ config.hidden_replica = options.hidden_replica
|
|
|
86baa9 |
|
|
|
86baa9 |
http_pkcs12_file = None
|
|
|
86baa9 |
http_pkcs12_info = None
|
|
|
86baa9 |
@@ -1579,8 +1580,16 @@ def install(installer):
|
|
|
86baa9 |
remove_replica_info_dir(installer)
|
|
|
86baa9 |
|
|
|
86baa9 |
# Enable configured services and update DNS SRV records
|
|
|
86baa9 |
- service.enable_services(config.host_name)
|
|
|
86baa9 |
+ if options.hidden_replica:
|
|
|
86baa9 |
+ # Set services to hidden
|
|
|
86baa9 |
+ service.hide_services(config.host_name)
|
|
|
86baa9 |
+ else:
|
|
|
86baa9 |
+ # Enable configured services
|
|
|
86baa9 |
+ service.enable_services(config.host_name)
|
|
|
86baa9 |
+ # update DNS SRV records. Although it's only really necessary in
|
|
|
86baa9 |
+ # enabled-service case, also perform update in hidden replica case.
|
|
|
86baa9 |
api.Command.dns_update_system_records()
|
|
|
86baa9 |
+
|
|
|
86baa9 |
ca_servers = find_providing_servers('CA', api.Backend.ldap2, api=api)
|
|
|
86baa9 |
api.Backend.ldap2.disconnect()
|
|
|
86baa9 |
|
|
|
86baa9 |
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
|
|
|
86baa9 |
index 261eedc85be24478b99e5ae8886aec7bc23a80ed..6d7997c559f8d748f00dd9df28371c53bc12ee21 100644
|
|
|
86baa9 |
--- a/ipaserver/install/service.py
|
|
|
86baa9 |
+++ b/ipaserver/install/service.py
|
|
|
86baa9 |
@@ -39,7 +39,7 @@ from ipalib import api, errors
|
|
|
86baa9 |
from ipaplatform import services
|
|
|
86baa9 |
from ipaplatform.paths import paths
|
|
|
86baa9 |
from ipaserver.masters import (
|
|
|
86baa9 |
- CONFIGURED_SERVICE, ENABLED_SERVICE, SERVICE_LIST
|
|
|
86baa9 |
+ CONFIGURED_SERVICE, ENABLED_SERVICE, HIDDEN_SERVICE, SERVICE_LIST
|
|
|
86baa9 |
)
|
|
|
86baa9 |
|
|
|
86baa9 |
logger = logging.getLogger(__name__)
|
|
|
86baa9 |
@@ -180,7 +180,7 @@ def set_service_entry_config(name, fqdn, config_values,
|
|
|
86baa9 |
|
|
|
86baa9 |
|
|
|
86baa9 |
def enable_services(fqdn):
|
|
|
86baa9 |
- """Change all configured services to enabled
|
|
|
86baa9 |
+ """Change all services to enabled state
|
|
|
86baa9 |
|
|
|
86baa9 |
Server.ldap_configure() only marks a service as configured. Services
|
|
|
86baa9 |
are enabled at the very end of installation.
|
|
|
86baa9 |
@@ -189,15 +189,46 @@ def enable_services(fqdn):
|
|
|
86baa9 |
|
|
|
86baa9 |
:param fqdn: hostname of server
|
|
|
86baa9 |
"""
|
|
|
86baa9 |
+ _set_services_state(fqdn, ENABLED_SERVICE)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+def hide_services(fqdn):
|
|
|
86baa9 |
+ """Change all services to hidden state
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ Note: DNS records must be updated with dns_update_system_records, too.
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ :param fqdn: hostname of server
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+ _set_services_state(fqdn, HIDDEN_SERVICE)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+def _set_services_state(fqdn, dest_state):
|
|
|
86baa9 |
+ """Change all services of a host
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ :param fqdn: hostname of server
|
|
|
86baa9 |
+ :param dest_state: destination state
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
ldap2 = api.Backend.ldap2
|
|
|
86baa9 |
search_base = DN(('cn', fqdn), api.env.container_masters, api.env.basedn)
|
|
|
86baa9 |
- search_filter = ldap2.make_filter(
|
|
|
86baa9 |
- {
|
|
|
86baa9 |
- 'objectClass': 'ipaConfigObject',
|
|
|
86baa9 |
- 'ipaConfigString': CONFIGURED_SERVICE
|
|
|
86baa9 |
- },
|
|
|
86baa9 |
- rules='&'
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ source_states = {
|
|
|
86baa9 |
+ CONFIGURED_SERVICE.lower(),
|
|
|
86baa9 |
+ ENABLED_SERVICE.lower(),
|
|
|
86baa9 |
+ HIDDEN_SERVICE.lower()
|
|
|
86baa9 |
+ }
|
|
|
86baa9 |
+ source_states.remove(dest_state.lower())
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ search_filter = ldap2.combine_filters(
|
|
|
86baa9 |
+ [
|
|
|
86baa9 |
+ ldap2.make_filter({'objectClass': 'ipaConfigObject'}),
|
|
|
86baa9 |
+ ldap2.make_filter(
|
|
|
86baa9 |
+ {'ipaConfigString': list(source_states)},
|
|
|
86baa9 |
+ rules=ldap2.MATCH_ANY
|
|
|
86baa9 |
+ ),
|
|
|
86baa9 |
+ ],
|
|
|
86baa9 |
+ rules=ldap2.MATCH_ALL
|
|
|
86baa9 |
)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
entries = ldap2.get_entries(
|
|
|
86baa9 |
search_base,
|
|
|
86baa9 |
filter=search_filter,
|
|
|
86baa9 |
@@ -208,10 +239,10 @@ def enable_services(fqdn):
|
|
|
86baa9 |
name = entry['cn']
|
|
|
86baa9 |
cfgstrings = entry.setdefault('ipaConfigString', [])
|
|
|
86baa9 |
for value in list(cfgstrings):
|
|
|
86baa9 |
- if value.lower() == CONFIGURED_SERVICE.lower():
|
|
|
86baa9 |
+ if value.lower() in source_states:
|
|
|
86baa9 |
cfgstrings.remove(value)
|
|
|
86baa9 |
- if not case_insensitive_attr_has_value(cfgstrings, ENABLED_SERVICE):
|
|
|
86baa9 |
- cfgstrings.append(ENABLED_SERVICE)
|
|
|
86baa9 |
+ if not case_insensitive_attr_has_value(cfgstrings, dest_state):
|
|
|
86baa9 |
+ cfgstrings.append(dest_state)
|
|
|
86baa9 |
|
|
|
86baa9 |
try:
|
|
|
86baa9 |
ldap2.update_entry(entry)
|
|
|
86baa9 |
@@ -221,7 +252,9 @@ def enable_services(fqdn):
|
|
|
86baa9 |
logger.exception("failed to set service %s config values", name)
|
|
|
86baa9 |
raise
|
|
|
86baa9 |
else:
|
|
|
86baa9 |
- logger.debug("Enabled service %s for %s", name, fqdn)
|
|
|
86baa9 |
+ logger.debug(
|
|
|
86baa9 |
+ "Set service %s for %s to %s", name, fqdn, dest_state
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
|
|
|
86baa9 |
|
|
|
86baa9 |
class Service(object):
|
|
|
86baa9 |
diff --git a/ipaserver/masters.py b/ipaserver/masters.py
|
|
|
86baa9 |
index 6fa8f02332ceaa10ec30aa5142912f351fb58936..76c1a9594d8b5f88c503a08b84a17e14ac320df3 100644
|
|
|
86baa9 |
--- a/ipaserver/masters.py
|
|
|
86baa9 |
+++ b/ipaserver/masters.py
|
|
|
86baa9 |
@@ -19,6 +19,7 @@ logger = logging.getLogger(__name__)
|
|
|
86baa9 |
# constants for ipaConfigString
|
|
|
86baa9 |
CONFIGURED_SERVICE = u'configuredService'
|
|
|
86baa9 |
ENABLED_SERVICE = u'enabledService'
|
|
|
86baa9 |
+HIDDEN_SERVICE = u'hiddenService'
|
|
|
86baa9 |
|
|
|
86baa9 |
# The service name as stored in cn=masters,cn=ipa,cn=etc. The values are:
|
|
|
86baa9 |
# 0: systemd service name
|
|
|
86baa9 |
@@ -68,30 +69,53 @@ def find_providing_servers(svcname, conn=None, preferred_hosts=(), api=api):
|
|
|
86baa9 |
conn = api.Backend.ldap2
|
|
|
86baa9 |
|
|
|
86baa9 |
dn = DN(api.env.container_masters, api.env.basedn)
|
|
|
86baa9 |
- query_filter = conn.make_filter(
|
|
|
86baa9 |
- {
|
|
|
86baa9 |
- 'objectClass': 'ipaConfigObject',
|
|
|
86baa9 |
- 'ipaConfigString': ENABLED_SERVICE,
|
|
|
86baa9 |
- 'cn': svcname
|
|
|
86baa9 |
- },
|
|
|
86baa9 |
- rules='&'
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ query_filter = conn.combine_filters(
|
|
|
86baa9 |
+ [
|
|
|
86baa9 |
+ conn.make_filter(
|
|
|
86baa9 |
+ {
|
|
|
86baa9 |
+ 'objectClass': 'ipaConfigObject',
|
|
|
86baa9 |
+ 'cn': svcname
|
|
|
86baa9 |
+ },
|
|
|
86baa9 |
+ rules=conn.MATCH_ALL,
|
|
|
86baa9 |
+ ),
|
|
|
86baa9 |
+ conn.make_filter(
|
|
|
86baa9 |
+ {
|
|
|
86baa9 |
+ 'ipaConfigString': [ENABLED_SERVICE, HIDDEN_SERVICE]
|
|
|
86baa9 |
+ },
|
|
|
86baa9 |
+ rules=conn.MATCH_ANY
|
|
|
86baa9 |
+ ),
|
|
|
86baa9 |
+ ],
|
|
|
86baa9 |
+ rules=conn.MATCH_ALL
|
|
|
86baa9 |
)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
try:
|
|
|
86baa9 |
entries, _trunc = conn.find_entries(
|
|
|
86baa9 |
filter=query_filter,
|
|
|
86baa9 |
- attrs_list=[],
|
|
|
86baa9 |
+ attrs_list=['ipaConfigString'],
|
|
|
86baa9 |
base_dn=dn
|
|
|
86baa9 |
)
|
|
|
86baa9 |
except errors.NotFound:
|
|
|
86baa9 |
return []
|
|
|
86baa9 |
|
|
|
86baa9 |
- # unique list of host names, DNS is case insensitive
|
|
|
86baa9 |
- servers = list(set(entry.dn[1].value.lower() for entry in entries))
|
|
|
86baa9 |
+ # DNS is case insensitive
|
|
|
86baa9 |
+ preferred_hosts = list(host_name.lower() for host_name in preferred_hosts)
|
|
|
86baa9 |
+ servers = []
|
|
|
86baa9 |
+ for entry in entries:
|
|
|
86baa9 |
+ servername = entry.dn[1].value.lower()
|
|
|
86baa9 |
+ cfgstrings = entry.get('ipaConfigString', [])
|
|
|
86baa9 |
+ # always consider enabled services
|
|
|
86baa9 |
+ if ENABLED_SERVICE in cfgstrings:
|
|
|
86baa9 |
+ servers.append(servername)
|
|
|
86baa9 |
+ # use hidden services on preferred hosts
|
|
|
86baa9 |
+ elif HIDDEN_SERVICE in cfgstrings and servername in preferred_hosts:
|
|
|
86baa9 |
+ servers.append(servername)
|
|
|
86baa9 |
+ # unique list of host names
|
|
|
86baa9 |
+ servers = list(set(servers))
|
|
|
86baa9 |
# shuffle the list like DNS SRV would randomize it
|
|
|
86baa9 |
random.shuffle(servers)
|
|
|
86baa9 |
# Move preferred hosts to front
|
|
|
86baa9 |
for host_name in reversed(preferred_hosts):
|
|
|
86baa9 |
- host_name = host_name.lower()
|
|
|
86baa9 |
try:
|
|
|
86baa9 |
servers.remove(host_name)
|
|
|
86baa9 |
except ValueError:
|
|
|
86baa9 |
diff --git a/ipaserver/plugins/serverrole.py b/ipaserver/plugins/serverrole.py
|
|
|
86baa9 |
index 199978000ce8cf783bda50c46b7c9fa109f70ad6..1f6d2dca518d374d7bd07e96019610e3ef6430be 100644
|
|
|
86baa9 |
--- a/ipaserver/plugins/serverrole.py
|
|
|
86baa9 |
+++ b/ipaserver/plugins/serverrole.py
|
|
|
86baa9 |
@@ -70,7 +70,7 @@ class server_role(Object):
|
|
|
86baa9 |
cli_name='status',
|
|
|
86baa9 |
label=_('Role status'),
|
|
|
86baa9 |
doc=_('Status of the role'),
|
|
|
86baa9 |
- values=(u'enabled', u'configured', u'absent'),
|
|
|
86baa9 |
+ values=(u'enabled', u'configured', u'hidden', u'absent'),
|
|
|
86baa9 |
default=u'enabled',
|
|
|
86baa9 |
flags={'virtual_attribute', 'no_create', 'no_update'}
|
|
|
86baa9 |
)
|
|
|
86baa9 |
diff --git a/ipaserver/servroles.py b/ipaserver/servroles.py
|
|
|
86baa9 |
index af4e63710136a15e1673210c3e2207658698fbb5..02a22e77dbb615f735660c53d1b2eb7da022591d 100644
|
|
|
86baa9 |
--- a/ipaserver/servroles.py
|
|
|
86baa9 |
+++ b/ipaserver/servroles.py
|
|
|
86baa9 |
@@ -79,7 +79,7 @@ import six
|
|
|
86baa9 |
|
|
|
86baa9 |
from ipalib import _, errors
|
|
|
86baa9 |
from ipapython.dn import DN
|
|
|
86baa9 |
-from ipaserver.masters import ENABLED_SERVICE
|
|
|
86baa9 |
+from ipaserver.masters import ENABLED_SERVICE, HIDDEN_SERVICE
|
|
|
86baa9 |
|
|
|
86baa9 |
if six.PY3:
|
|
|
86baa9 |
unicode = str
|
|
|
86baa9 |
@@ -87,6 +87,7 @@ if six.PY3:
|
|
|
86baa9 |
|
|
|
86baa9 |
ENABLED = u'enabled'
|
|
|
86baa9 |
CONFIGURED = u'configured'
|
|
|
86baa9 |
+HIDDEN = u'hidden'
|
|
|
86baa9 |
ABSENT = u'absent'
|
|
|
86baa9 |
|
|
|
86baa9 |
|
|
|
86baa9 |
@@ -190,6 +191,7 @@ class BaseServerRole(LDAPBasedProperty):
|
|
|
86baa9 |
:returns: * 'enabled' if the role is enabled on the master
|
|
|
86baa9 |
* 'configured' if it is not enabled but has
|
|
|
86baa9 |
been configured by installer
|
|
|
86baa9 |
+ * 'hidden' if the role is not advertised
|
|
|
86baa9 |
* 'absent' otherwise
|
|
|
86baa9 |
"""
|
|
|
86baa9 |
ldap2 = api_instance.Backend.ldap2
|
|
|
86baa9 |
@@ -442,7 +444,7 @@ class SingleValuedServerAttribute(ServerAttribute):
|
|
|
86baa9 |
return masters
|
|
|
86baa9 |
|
|
|
86baa9 |
|
|
|
86baa9 |
-_Service = namedtuple('Service', ['name', 'enabled'])
|
|
|
86baa9 |
+_Service = namedtuple('Service', ['name', 'enabled', 'hidden'])
|
|
|
86baa9 |
|
|
|
86baa9 |
|
|
|
86baa9 |
class ServiceBasedRole(BaseServerRole):
|
|
|
86baa9 |
@@ -470,8 +472,9 @@ class ServiceBasedRole(BaseServerRole):
|
|
|
86baa9 |
entry_cn = entry['cn'][0]
|
|
|
86baa9 |
|
|
|
86baa9 |
enabled = self._is_service_enabled(entry)
|
|
|
86baa9 |
+ hidden = self._is_service_hidden(entry)
|
|
|
86baa9 |
|
|
|
86baa9 |
- return _Service(name=entry_cn, enabled=enabled)
|
|
|
86baa9 |
+ return _Service(name=entry_cn, enabled=enabled, hidden=hidden)
|
|
|
86baa9 |
|
|
|
86baa9 |
def _is_service_enabled(self, entry):
|
|
|
86baa9 |
"""
|
|
|
86baa9 |
@@ -486,6 +489,15 @@ class ServiceBasedRole(BaseServerRole):
|
|
|
86baa9 |
ipaconfigstring_values = set(entry.get('ipaConfigString', []))
|
|
|
86baa9 |
return ENABLED_SERVICE in ipaconfigstring_values
|
|
|
86baa9 |
|
|
|
86baa9 |
+ def _is_service_hidden(self, entry):
|
|
|
86baa9 |
+ """Determine if service is hidden
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ :param entry: LDAPEntry of the service
|
|
|
86baa9 |
+ :returns: True if the service entry is enabled, False otherwise
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+ ipaconfigstring_values = set(entry.get('ipaConfigString', []))
|
|
|
86baa9 |
+ return HIDDEN_SERVICE in ipaconfigstring_values
|
|
|
86baa9 |
+
|
|
|
86baa9 |
def _get_services_by_masters(self, entries):
|
|
|
86baa9 |
"""
|
|
|
86baa9 |
given list of entries, return a dictionary keyed by master FQDNs which
|
|
|
86baa9 |
@@ -509,9 +521,12 @@ class ServiceBasedRole(BaseServerRole):
|
|
|
86baa9 |
except ValueError:
|
|
|
86baa9 |
continue
|
|
|
86baa9 |
|
|
|
86baa9 |
- status = (
|
|
|
86baa9 |
- ENABLED if all(s.enabled for s in services) else
|
|
|
86baa9 |
- CONFIGURED)
|
|
|
86baa9 |
+ if all(s.enabled for s in services):
|
|
|
86baa9 |
+ status = ENABLED
|
|
|
86baa9 |
+ elif all(s.hidden for s in services):
|
|
|
86baa9 |
+ status = HIDDEN
|
|
|
86baa9 |
+ else:
|
|
|
86baa9 |
+ status = CONFIGURED
|
|
|
86baa9 |
|
|
|
86baa9 |
result.append(self.create_role_status_dict(master, status))
|
|
|
86baa9 |
|
|
|
86baa9 |
--
|
|
|
86baa9 |
2.20.1
|
|
|
86baa9 |
|