summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-02-04 14:03:30 +0100
committerRob Crittenden <rcritten@redhat.com>2011-02-16 10:39:16 -0500
commite5d57d237b4f146faf2e5c27d4e9eb3359dc15b3 (patch)
treec6998fdaf83372e80e107da4d5dfc7246b552ce9
parenta9dc175bc547996646c213661ca42906ffef83ab (diff)
downloadfreeipa-e5d57d237b4f146faf2e5c27d4e9eb3359dc15b3.tar.gz
freeipa-e5d57d237b4f146faf2e5c27d4e9eb3359dc15b3.tar.xz
freeipa-e5d57d237b4f146faf2e5c27d4e9eb3359dc15b3.zip
HBAC plugin inconsistent output
This patch adds a proper summary text to HBAC command which is then printed out in CLI. Now, HBAC plugin output is consistent with other plugins. https://fedorahosted.org/freeipa/ticket/596
-rw-r--r--API.txt12
-rw-r--r--ipalib/plugins/hbacrule.py37
-rw-r--r--ipalib/plugins/hbacsvc.py14
-rw-r--r--ipalib/plugins/hbacsvcgroup.py10
-rw-r--r--tests/test_xmlrpc/test_hbacsvcgroup_plugin.py12
5 files changed, 56 insertions, 29 deletions
diff --git a/API.txt b/API.txt
index 9e34647de..697acb289 100644
--- a/API.txt
+++ b/API.txt
@@ -1035,13 +1035,17 @@ output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly
output: Output('result', <type 'dict'>, 'list of deletions that failed')
output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
command: hbacrule_disable
-args: 1,0,1
+args: 1,0,3
arg: Str('cn', attribute=True, cli_name='name', label=Gettext('Rule name', domain='ipa', localedir=None), multivalue=False, primary_key=True, query=True, required=True)
-output: Output('result', None, None)
+output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
+output: Output('result', <type 'bool'>, 'True means the operation was successful')
+output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
command: hbacrule_enable
-args: 1,0,1
+args: 1,0,3
arg: Str('cn', attribute=True, cli_name='name', label=Gettext('Rule name', domain='ipa', localedir=None), multivalue=False, primary_key=True, query=True, required=True)
-output: Output('result', None, None)
+output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), 'User-friendly description of action performed')
+output: Output('result', <type 'bool'>, 'True means the operation was successful')
+output: Output('value', <type 'unicode'>, "The primary_key value of the entry, e.g. 'jdoe' for a user")
command: hbacrule_find
args: 1,12,4
arg: Str('criteria?')
diff --git a/ipalib/plugins/hbacrule.py b/ipalib/plugins/hbacrule.py
index b834a1410..cb4dbb4f3 100644
--- a/ipalib/plugins/hbacrule.py
+++ b/ipalib/plugins/hbacrule.py
@@ -211,6 +211,9 @@ class hbacrule_add(LDAPCreate):
"""
Create a new HBAC rule.
"""
+
+ msg_summary = _('Added HBAC rule "%(value)s"')
+
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
# HBAC rules are enabled by default
entry_attrs['ipaenabledflag'] = 'TRUE'
@@ -224,6 +227,8 @@ class hbacrule_del(LDAPDelete):
Delete an HBAC rule.
"""
+ msg_summary = _('Deleted HBAC rule "%(value)s"')
+
api.register(hbacrule_del)
@@ -232,6 +237,8 @@ class hbacrule_mod(LDAPUpdate):
Modify an HBAC rule.
"""
+ msg_summary = _('Modified HBAC rule "%(value)s"')
+
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
try:
(dn, entry_attrs) = ldap.get_entry(dn, attrs_list)
@@ -256,6 +263,10 @@ class hbacrule_find(LDAPSearch):
Search for HBAC rules.
"""
+ msg_summary = ngettext(
+ '%(count)d HBAC rule matched', '%(count)d HBAC rules matched', 0
+ )
+
api.register(hbacrule_find)
@@ -271,6 +282,10 @@ class hbacrule_enable(LDAPQuery):
"""
Enable an HBAC rule.
"""
+
+ msg_summary = _('Enabled HBAC rule "%(value)s"')
+ has_output = output.standard_value
+
def execute(self, cn):
ldap = self.obj.backend
@@ -284,11 +299,10 @@ class hbacrule_enable(LDAPQuery):
except errors.NotFound:
self.obj.handle_not_found(cn)
- return dict(result=True)
-
- def output_for_cli(self, textui, result, cn):
- textui.print_name(self.name)
- textui.print_dashed('Enabled HBAC rule "%s".' % cn)
+ return dict(
+ result=True,
+ value=cn,
+ )
api.register(hbacrule_enable)
@@ -297,6 +311,10 @@ class hbacrule_disable(LDAPQuery):
"""
Disable an HBAC rule.
"""
+
+ msg_summary = _('Disabled HBAC rule "%(value)s"')
+ has_output = output.standard_value
+
def execute(self, cn):
ldap = self.obj.backend
@@ -310,11 +328,10 @@ class hbacrule_disable(LDAPQuery):
except errors.NotFound:
self.obj.handle_not_found(cn)
- return dict(result=True)
-
- def output_for_cli(self, textui, result, cn):
- textui.print_name(self.name)
- textui.print_dashed('Disabled HBAC rule "%s".' % cn)
+ return dict(
+ result=True,
+ value=cn,
+ )
api.register(hbacrule_disable)
diff --git a/ipalib/plugins/hbacsvc.py b/ipalib/plugins/hbacsvc.py
index 282f927ca..3fe9f0fb3 100644
--- a/ipalib/plugins/hbacsvc.py
+++ b/ipalib/plugins/hbacsvc.py
@@ -64,14 +64,14 @@ class hbacsvc(LDAPObject):
Str('cn',
cli_name='service',
label=_('Service name'),
- doc=_('HBAC Service'),
+ doc=_('HBAC service'),
primary_key=True,
normalizer=lambda value: value.lower(),
),
Str('description?',
cli_name='desc',
label=_('Description'),
- doc=_('Description of service'),
+ doc=_('HBAC service description'),
),
)
@@ -82,7 +82,7 @@ class hbacsvc_add(LDAPCreate):
"""
Add a new HBAC service.
"""
- msg_summary = _('Added service "%(value)s"')
+ msg_summary = _('Added HBAC service "%(value)s"')
api.register(hbacsvc_add)
@@ -91,7 +91,7 @@ class hbacsvc_del(LDAPDelete):
"""
Delete an existing HBAC service.
"""
- msg_summary = _('Deleted service "%(value)s"')
+ msg_summary = _('Deleted HBAC service "%(value)s"')
api.register(hbacsvc_del)
@@ -101,6 +101,8 @@ class hbacsvc_mod(LDAPUpdate):
Modify an HBAC service.
"""
+ msg_summary = _('Modified HBAC service "%(value)s"')
+
api.register(hbacsvc_mod)
@@ -109,6 +111,10 @@ class hbacsvc_find(LDAPSearch):
Search for HBAC services.
"""
+ msg_summary = ngettext(
+ '%(count)d HBAC service matched', '%(count)d HBAC services matched', 0
+ )
+
api.register(hbacsvc_find)
diff --git a/ipalib/plugins/hbacsvcgroup.py b/ipalib/plugins/hbacsvcgroup.py
index e2568076f..0a66697d9 100644
--- a/ipalib/plugins/hbacsvcgroup.py
+++ b/ipalib/plugins/hbacsvcgroup.py
@@ -61,7 +61,7 @@ class hbacsvcgroup(LDAPObject):
'member': ['hbacsvc'],
}
- label = _('HBAC Service Groups')
+ label = _('HBAC service Groups')
takes_params = (
Str('cn',
@@ -84,7 +84,7 @@ class hbacsvcgroup_add(LDAPCreate):
"""
Add a new HBAC services group.
"""
- msg_summary = _('Added HBAC Service group "%(value)s"')
+ msg_summary = _('Added HBAC service group "%(value)s"')
api.register(hbacsvcgroup_add)
@@ -93,7 +93,7 @@ class hbacsvcgroup_del(LDAPDelete):
"""
Delete an HBAC services group.
"""
- msg_summary = _('Deleted HBAC Service group "%(value)s"')
+ msg_summary = _('Deleted HBAC service group "%(value)s"')
api.register(hbacsvcgroup_del)
@@ -102,7 +102,7 @@ class hbacsvcgroup_mod(LDAPUpdate):
"""
Modify an HBAC services group.
"""
- msg_summary = _('Modified HBAC Service group "%(value)s"')
+ msg_summary = _('Modified HBAC service group "%(value)s"')
api.register(hbacsvcgroup_mod)
@@ -112,7 +112,7 @@ class hbacsvcgroup_find(LDAPSearch):
Search for an HBAC services group.
"""
msg_summary = ngettext(
- '%(count)d group matched', '%(count)d groups matched', 0
+ '%(count)d HBAC service group matched', '%(count)d HBAC service groups matched', 0
)
api.register(hbacsvcgroup_find)
diff --git a/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py b/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py
index c5c02f11c..d2fa7cc8b 100644
--- a/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py
+++ b/tests/test_xmlrpc/test_hbacsvcgroup_plugin.py
@@ -71,7 +71,7 @@ class test_hbacsvcgroup(Declarative):
),
expected=dict(
value=hbacsvcgroup1,
- summary=u'Added HBAC Service group "testhbacsvcgroup1"',
+ summary=u'Added HBAC service group "testhbacsvcgroup1"',
result=dict(
dn=dn1,
cn=[hbacsvcgroup1],
@@ -101,7 +101,7 @@ class test_hbacsvcgroup(Declarative):
),
expected=dict(
value=hbacsvc1,
- summary=u'Added service "%s"' % hbacsvc1,
+ summary=u'Added HBAC service "%s"' % hbacsvc1,
result=dict(
dn=hbacsvc_dn1,
cn=[hbacsvc1],
@@ -157,7 +157,7 @@ class test_hbacsvcgroup(Declarative):
expected=dict(
count=1,
truncated=False,
- summary=u'1 group matched',
+ summary=u'1 HBAC service group matched',
result=[
{
'dn': dn1,
@@ -177,7 +177,7 @@ class test_hbacsvcgroup(Declarative):
),
expected=dict(
value=hbacsvcgroup1,
- summary=u'Modified HBAC Service group "testhbacsvcgroup1"',
+ summary=u'Modified HBAC service group "testhbacsvcgroup1"',
result=dict(
cn=[hbacsvcgroup1],
description=[u'Updated hbacsvcgroup 1'],
@@ -229,7 +229,7 @@ class test_hbacsvcgroup(Declarative):
command=('hbacsvcgroup_del', [hbacsvcgroup1], {}),
expected=dict(
value=hbacsvcgroup1,
- summary=u'Deleted HBAC Service group "testhbacsvcgroup1"',
+ summary=u'Deleted HBAC service group "testhbacsvcgroup1"',
result=dict(failed=u''),
),
),
@@ -240,7 +240,7 @@ class test_hbacsvcgroup(Declarative):
command=('hbacsvc_del', [hbacsvc1], {}),
expected=dict(
value=hbacsvc1,
- summary=u'Deleted service "%s"' % hbacsvc1,
+ summary=u'Deleted HBAC service "%s"' % hbacsvc1,
result=dict(failed=u''),
),
)