diff options
author | Tomas Babej <tbabej@redhat.com> | 2013-05-27 14:21:57 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-05-29 10:11:27 +0200 |
commit | 0b5c0286eda3b9703da110450ec65ef5f2d3ed30 (patch) | |
tree | a0248ed2ea9230e72eebcdbe15cd94ebe2effb6a | |
parent | 1e224c2ea021f546aea83d56779268ca2e099c89 (diff) | |
download | freeipa-0b5c0286eda3b9703da110450ec65ef5f2d3ed30.tar.gz freeipa-0b5c0286eda3b9703da110450ec65ef5f2d3ed30.tar.xz freeipa-0b5c0286eda3b9703da110450ec65ef5f2d3ed30.zip |
Do not translate trust type and direction with --raw in trust_show and trust-find
In trust_show command, make sure that --raw flag is honoured.
Attributes ipanttrusttype and ipanttrustdirection are no longer
translated to strings from their raw ldap values when --raw is
used.
https://fedorahosted.org/freeipa/ticket/3525
-rw-r--r-- | ipalib/plugins/trust.py | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py index 9bcfb417a..3cb0ed980 100644 --- a/ipalib/plugins/trust.py +++ b/ipalib/plugins/trust.py @@ -487,7 +487,8 @@ class trust_mod(LDAPUpdate): class trust_find(LDAPSearch): __doc__ = _('Search for trusts.') - has_output_params = LDAPSearch.has_output_params + trust_output_params + has_output_params = LDAPSearch.has_output_params + trust_output_params +\ + (Str('ipanttrusttype'),) msg_summary = ngettext( '%(count)d trust matched', '%(count)d trusts matched', 0 @@ -505,13 +506,18 @@ class trust_find(LDAPSearch): for entry in entries: (dn, attrs) = entry - attrs['trusttype'] = trust_type_string(attrs['ipanttrusttype'][0]) + + # Translate ipanttrusttype to trusttype if --raw not used + if not options.get('raw', False): + attrs['trusttype'] = trust_type_string(attrs['ipanttrusttype'][0]) + del attrs['ipanttrusttype'] return truncated class trust_show(LDAPRetrieve): __doc__ = _('Display information about a trust.') - has_output_params = LDAPRetrieve.has_output_params + trust_output_params + has_output_params = LDAPRetrieve.has_output_params + trust_output_params +\ + (Str('ipanttrusttype'), Str('ipanttrustdirection')) def execute(self, *keys, **options): error = None @@ -524,9 +530,7 @@ class trust_show(LDAPRetrieve): result = None error = e if result: - result['result']['trusttype'] = [trust_type_string(result['result']['ipanttrusttype'][0])] - result['result']['trustdirection'] = [trust_direction_string(result['result']['ipanttrustdirection'][0])] - break + break if error or not result: self.obj.handle_not_found(*keys) @@ -536,6 +540,24 @@ class trust_show(LDAPRetrieve): assert isinstance(dn, DN) if 'trust_show_type' in options: return make_trust_dn(self.env, options['trust_show_type'], dn) + + return dn + + def post_callback(self, ldap, dn, entry_attrs, *keys, **options): + + # Translate ipanttrusttype to trusttype + # and ipanttrustdirection to trustdirection + # if --raw not used + + if not options.get('raw', False): + type_str = trust_type_string(entry_attrs['ipanttrusttype'][0]) + dir_str = trust_direction_string(entry_attrs['ipanttrustdirection'] + [0]) + entry_attrs['trusttype'] = [type_str] + entry_attrs['trustdirection'] = [dir_str] + del entry_attrs['ipanttrusttype'] + del entry_attrs['ipanttrustdirection'] + return dn api.register(trust) |