service: handle empty list of services to update their state

When there are no services in LDAP that have specified states, we don't
need to update their state.

Fixes: https://pagure.io/freeipa/issue/8623

Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Alexander Bokovoy 2020-12-17 22:18:47 +02:00
parent 35362d3033
commit b7c00f2a1f

View File

@ -252,12 +252,18 @@ def _set_services_state(fqdn, dest_state):
rules=ldap2.MATCH_ALL
)
try:
entries = ldap2.get_entries(
search_base,
filter=search_filter,
scope=api.Backend.ldap2.SCOPE_ONELEVEL,
attrs_list=['cn', 'ipaConfigString']
)
except errors.EmptyResult:
logger.debug("No services with a state from %s, ignoring",
list(source_states))
return
for entry in entries:
name = entry['cn']
cfgstrings = entry.setdefault('ipaConfigString', [])