mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
Query for server role IPA master
server_find and server_role plugin were hiding IPA master role information. It's now possible to fetch IPA master role information and to filter by IPA master role, e.g. to ignore servers that have some services configured but not (yet) enabled. See: https://pagure.io/freeipa/issue/7566 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
parent
e8d33ccfd1
commit
7c2ca14118
3
API.txt
3
API.txt
@ -4425,9 +4425,10 @@ output: Entry('result')
|
||||
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
||||
output: PrimaryKey('value')
|
||||
command: server_role_find/1
|
||||
args: 1,8,4
|
||||
args: 1,9,4
|
||||
arg: Str('criteria?')
|
||||
option: Flag('all', autofill=True, cli_name='all', default=False)
|
||||
option: Flag('include_master', autofill=True, default=False)
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: Str('role_servrole?', autofill=False, cli_name='role')
|
||||
option: Str('server_server?', autofill=False, cli_name='server')
|
||||
|
@ -205,7 +205,10 @@ class server(LDAPObject):
|
||||
return
|
||||
|
||||
enabled_roles = self.api.Command.server_role_find(
|
||||
server_server=entry_attrs['cn'][0], status=ENABLED)['result']
|
||||
server_server=entry_attrs['cn'][0],
|
||||
status=ENABLED,
|
||||
include_master=True,
|
||||
)['result']
|
||||
|
||||
enabled_role_names = [r[u'role_servrole'] for r in enabled_roles]
|
||||
|
||||
@ -339,7 +342,9 @@ class server_find(LDAPSearch):
|
||||
role_status = self.api.Command.server_role_find(
|
||||
server_server=None,
|
||||
role_servrole=role,
|
||||
status=ENABLED)['result']
|
||||
status=ENABLED,
|
||||
include_master=True,
|
||||
)['result']
|
||||
|
||||
return set(
|
||||
r[u'server_server'] for r in role_status)
|
||||
|
@ -5,7 +5,7 @@
|
||||
from ipalib.crud import Retrieve, Search
|
||||
from ipalib.errors import NotFound
|
||||
from ipalib.frontend import Object
|
||||
from ipalib.parameters import Int, Str, StrEnum
|
||||
from ipalib.parameters import Flag, Int, Str, StrEnum
|
||||
from ipalib.plugable import Registry
|
||||
from ipalib import _, ngettext
|
||||
|
||||
@ -129,6 +129,10 @@ class server_role_find(Search):
|
||||
minvalue=0,
|
||||
autofill=False,
|
||||
),
|
||||
Flag(
|
||||
'include_master',
|
||||
doc=_('Include IPA master entries'),
|
||||
)
|
||||
)
|
||||
|
||||
def execute(self, *keys, **options):
|
||||
@ -151,8 +155,16 @@ class server_role_find(Search):
|
||||
role_servrole=role_name,
|
||||
status=status)
|
||||
|
||||
result = [
|
||||
r for r in role_status if r[u'role_servrole'] != "IPA master"]
|
||||
# Don't display "IPA master" information unless the role is
|
||||
# requested explicitly. All servers are considered IPA masters,
|
||||
# except for replicas during installation.
|
||||
if options.get('include_master') or role_name == "IPA master":
|
||||
result = role_status
|
||||
else:
|
||||
result = [
|
||||
r for r in role_status
|
||||
if r[u'role_servrole'] != "IPA master"
|
||||
]
|
||||
return dict(
|
||||
result=result,
|
||||
count=len(result),
|
||||
|
Loading…
Reference in New Issue
Block a user