On 05/28/2013 05:32 PM, Ana Krivokapic wrote:
On 05/28/2013 01:20 PM, Tomas Babej wrote:
On 05/27/2013 03:04 PM, Ana Krivokapic wrote:
On 05/27/2013 02:38 PM, Tomas Babej wrote:
Hi,

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

Tomas
The patch causes these two attributes to not be displayed, when --raw
switch is used:

[akrivoka@vm-040 freeipa]$ ipa trust-show addomain.example.com
    Realm name: addomain.example.com
    Domain NetBIOS name: ADDOMAIN
    Domain Security Identifier: S-1-5-21-115633519-1816729995-712395322
    Trust direction: Two-way trust
    Trust type: Active Directory domain

[akrivoka@vm-040 freeipa]$ ipa trust-show addomain.example.com --raw
    cn: addomain.example.com
    ipantflatname: ADDOMAIN
    ipanttrusteddomainsid: S-1-5-21-115633519-1816729995-712395322

Thanks. Updated patch attached.

I modified trust-find according to the new behaviour.

Tomas


Works nicely.

Please just amend the commit message to mention that the trust-find
command is also affected.

ACK.

Commit message ammended.

Tomas
From 41e951e05166b3163eb96ac79f88b0d99163141f Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Mon, 27 May 2013 14:21:57 +0200
Subject: [PATCH] Do not translate trust type and direction with --raw in
 trust_show

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.

The trust_find command has been altered to follow the same
behaviour.

https://fedorahosted.org/freeipa/ticket/3525
---
 ipalib/plugins/trust.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/ipalib/plugins/trust.py b/ipalib/plugins/trust.py
index 9bcfb417a9413faffdeb4009d9de06d6041b223e..3cb0ed98005ae5bd11b39f8ae01c9470d1bfc9c4 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)
-- 
1.8.1.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to