|
|
95ea96 |
From ef7fe9e24844f73a27650d4d2a4f118cc364caac Mon Sep 17 00:00:00 2001
|
|
|
2737e7 |
From: Christian Heimes <cheimes@redhat.com>
|
|
|
2737e7 |
Date: Thu, 5 Jul 2018 23:50:37 +0200
|
|
|
2737e7 |
Subject: [PATCH] Query for server role IPA master
|
|
|
2737e7 |
|
|
|
2737e7 |
server_find and server_role plugin were hiding IPA master role
|
|
|
2737e7 |
information. It's now possible to fetch IPA master role information and
|
|
|
2737e7 |
to filter by IPA master role, e.g. to ignore servers that have some
|
|
|
2737e7 |
services configured but not (yet) enabled.
|
|
|
2737e7 |
|
|
|
2737e7 |
See: https://pagure.io/freeipa/issue/7566
|
|
|
2737e7 |
Signed-off-by: Christian Heimes <cheimes@redhat.com>
|
|
|
2737e7 |
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
2737e7 |
---
|
|
|
2737e7 |
API.txt | 3 ++-
|
|
|
2737e7 |
ipaserver/plugins/server.py | 9 +++++++--
|
|
|
2737e7 |
ipaserver/plugins/serverrole.py | 18 +++++++++++++++---
|
|
|
2737e7 |
3 files changed, 24 insertions(+), 6 deletions(-)
|
|
|
2737e7 |
|
|
|
2737e7 |
diff --git a/API.txt b/API.txt
|
|
|
95ea96 |
index 96c1548331750577e899f397f6f5a9a9d863248a..0e09e58a6ecaa4f724fb0c92b4faaf64df9fab5a 100644
|
|
|
2737e7 |
--- a/API.txt
|
|
|
2737e7 |
+++ b/API.txt
|
|
|
2737e7 |
@@ -4421,9 +4421,10 @@ output: Entry('result')
|
|
|
2737e7 |
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
|
|
2737e7 |
output: PrimaryKey('value')
|
|
|
2737e7 |
command: server_role_find/1
|
|
|
2737e7 |
-args: 1,8,4
|
|
|
2737e7 |
+args: 1,9,4
|
|
|
2737e7 |
arg: Str('criteria?')
|
|
|
2737e7 |
option: Flag('all', autofill=True, cli_name='all', default=False)
|
|
|
2737e7 |
+option: Flag('include_master', autofill=True, default=False)
|
|
|
2737e7 |
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
|
|
2737e7 |
option: Str('role_servrole?', autofill=False, cli_name='role')
|
|
|
2737e7 |
option: Str('server_server?', autofill=False, cli_name='server')
|
|
|
2737e7 |
diff --git a/ipaserver/plugins/server.py b/ipaserver/plugins/server.py
|
|
|
95ea96 |
index 4ea6f5b4b458db701c6c041d1c05cf4a7c6bc8a4..e265883e3637938e3df5ecf132f4add62413a997 100644
|
|
|
2737e7 |
--- a/ipaserver/plugins/server.py
|
|
|
2737e7 |
+++ b/ipaserver/plugins/server.py
|
|
|
95ea96 |
@@ -205,7 +205,10 @@ class server(LDAPObject):
|
|
|
2737e7 |
return
|
|
|
2737e7 |
|
|
|
2737e7 |
enabled_roles = self.api.Command.server_role_find(
|
|
|
2737e7 |
- server_server=entry_attrs['cn'][0], status=ENABLED)['result']
|
|
|
2737e7 |
+ server_server=entry_attrs['cn'][0],
|
|
|
2737e7 |
+ status=ENABLED,
|
|
|
2737e7 |
+ include_master=True,
|
|
|
2737e7 |
+ )['result']
|
|
|
2737e7 |
|
|
|
2737e7 |
enabled_role_names = [r[u'role_servrole'] for r in enabled_roles]
|
|
|
2737e7 |
|
|
|
95ea96 |
@@ -339,7 +342,9 @@ class server_find(LDAPSearch):
|
|
|
2737e7 |
role_status = self.api.Command.server_role_find(
|
|
|
2737e7 |
server_server=None,
|
|
|
2737e7 |
role_servrole=role,
|
|
|
2737e7 |
- status=ENABLED)['result']
|
|
|
2737e7 |
+ status=ENABLED,
|
|
|
2737e7 |
+ include_master=True,
|
|
|
2737e7 |
+ )['result']
|
|
|
2737e7 |
|
|
|
2737e7 |
return set(
|
|
|
2737e7 |
r[u'server_server'] for r in role_status)
|
|
|
2737e7 |
diff --git a/ipaserver/plugins/serverrole.py b/ipaserver/plugins/serverrole.py
|
|
|
95ea96 |
index 1b19c7e867a0223d1c2e72372d9f3dc65fc5f771..5b7ccfb342d0a54bfd6f2cdc53c7d31201ed5989 100644
|
|
|
2737e7 |
--- a/ipaserver/plugins/serverrole.py
|
|
|
2737e7 |
+++ b/ipaserver/plugins/serverrole.py
|
|
|
2737e7 |
@@ -5,7 +5,7 @@
|
|
|
2737e7 |
from ipalib.crud import Retrieve, Search
|
|
|
2737e7 |
from ipalib.errors import NotFound
|
|
|
2737e7 |
from ipalib.frontend import Object
|
|
|
2737e7 |
-from ipalib.parameters import Int, Str, StrEnum
|
|
|
2737e7 |
+from ipalib.parameters import Flag, Int, Str, StrEnum
|
|
|
2737e7 |
from ipalib.plugable import Registry
|
|
|
2737e7 |
from ipalib import _, ngettext
|
|
|
2737e7 |
|
|
|
2737e7 |
@@ -129,6 +129,10 @@ class server_role_find(Search):
|
|
|
2737e7 |
minvalue=0,
|
|
|
2737e7 |
autofill=False,
|
|
|
2737e7 |
),
|
|
|
2737e7 |
+ Flag(
|
|
|
2737e7 |
+ 'include_master',
|
|
|
2737e7 |
+ doc=_('Include IPA master entries'),
|
|
|
2737e7 |
+ )
|
|
|
2737e7 |
)
|
|
|
2737e7 |
|
|
|
2737e7 |
def execute(self, *keys, **options):
|
|
|
2737e7 |
@@ -151,8 +155,16 @@ class server_role_find(Search):
|
|
|
2737e7 |
role_servrole=role_name,
|
|
|
2737e7 |
status=status)
|
|
|
2737e7 |
|
|
|
2737e7 |
- result = [
|
|
|
2737e7 |
- r for r in role_status if r[u'role_servrole'] != "IPA master"]
|
|
|
2737e7 |
+ # Don't display "IPA master" information unless the role is
|
|
|
2737e7 |
+ # requested explicitly. All servers are considered IPA masters,
|
|
|
2737e7 |
+ # except for replicas during installation.
|
|
|
2737e7 |
+ if options.get('include_master') or role_name == "IPA master":
|
|
|
2737e7 |
+ result = role_status
|
|
|
2737e7 |
+ else:
|
|
|
2737e7 |
+ result = [
|
|
|
2737e7 |
+ r for r in role_status
|
|
|
2737e7 |
+ if r[u'role_servrole'] != "IPA master"
|
|
|
2737e7 |
+ ]
|
|
|
2737e7 |
return dict(
|
|
|
2737e7 |
result=result,
|
|
|
2737e7 |
count=len(result),
|
|
|
2737e7 |
--
|
|
|
2737e7 |
2.17.1
|
|
|
2737e7 |
|