From b8b573a966f4be268031ccca5abce09767928ff7 Mon Sep 17 00:00:00 2001 From: Ana Krivokapic Date: Fri, 12 Apr 2013 17:38:09 +0200 Subject: Deprecate HBAC source hosts from CLI Hide the commands and options listed below from the CLI, but keep them in the API. When called directly from the API, raise appropriate exceptions informing the user that the functionality has been deprecated. Affected commands: hbacrule_add_sourcehost, hbacrule_remove_sourcehost. Affected options: sourcehostcategory, sourcehost_host and sourcehost_hostgroup (hbacrule); sourcehost (hbactest). https://fedorahosted.org/freeipa/ticket/3528 --- ipalib/plugins/hbactest.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'ipalib/plugins/hbactest.py') diff --git a/ipalib/plugins/hbactest.py b/ipalib/plugins/hbactest.py index 25c64ea4..eeb0281f 100644 --- a/ipalib/plugins/hbactest.py +++ b/ipalib/plugins/hbactest.py @@ -18,7 +18,7 @@ # along with this program. If not, see . from ipalib import api, errors, output, util -from ipalib import Command, Str, Flag, Int +from ipalib import Command, Str, Flag, Int, DeprecatedParam from types import NoneType from ipalib.cli import to_cli from ipalib import _, ngettext @@ -255,10 +255,7 @@ class hbactest(Command): label=_('User name'), primary_key=True, ), - Str('sourcehost?', - cli_name='srchost', - label=_('Source host'), - ), + DeprecatedParam('sourcehost?'), Str('targethost', cli_name='host', label=_('Target host'), @@ -304,7 +301,7 @@ class hbactest(Command): def execute(self, *args, **options): # First receive all needed information: # 1. HBAC rules (whether enabled or disabled) - # 2. Required options are (user, source host, target host, service) + # 2. Required options are (user, target host, service) # 3. Options: rules to test (--rules, --enabled, --disabled), request for detail output rules = [] @@ -436,21 +433,6 @@ class hbactest(Command): except: pass - if options.get('sourcehost'): - warning_flag = True - if options['sourcehost'] != u'all': - try: - request.srchost.name = self.canonicalize(options['sourcehost']) - srchost_result = self.api.Command.host_show(request.srchost.name)['result'] - groups = srchost_result['memberof_hostgroup'] - if 'memberofindirect_hostgroup' in srchost_result: - groups += srchost_result['memberofindirect_hostgroup'] - request.srchost.groups = sorted(set(groups)) - except: - pass - else: - warning_flag = False - if options['targethost'] != u'all': try: request.targethost.name = self.canonicalize(options['targethost']) @@ -477,8 +459,6 @@ class hbactest(Command): matched_rules.append(ipa_rule.name) if res == pyhbac.HBAC_EVAL_DENY: notmatched_rules.append(ipa_rule.name) - if warning_flag: - warning_rules.append(_(u'Sourcehost value of rule "%s" is ignored') % (ipa_rule.name)) except pyhbac.HbacError as (code, rule_name): if code == pyhbac.HBAC_EVAL_ERROR: error_rules.append(rule_name) -- cgit