Hi,

Makes ipaassignedidview a default attribute and takes care about the
conversion from the DN to the proper ID view name.

https://fedorahosted.org/freeipa/ticket/4774

-- 
Tomas Babej
Associate Software Engineer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org 


>From 1af1922f27a29ead65629b3919e4a2aaeacc03c9 Mon Sep 17 00:00:00 2001
From: Tomas Babej <[email protected]>
Date: Tue, 2 Dec 2014 15:40:40 +0100
Subject: [PATCH] hosts: Display assigned ID view by default in host-find and
 show commands

Makes ipaassignedidview a default attribute and takes care about the
conversion from the DN to the proper ID view name.

https://fedorahosted.org/freeipa/ticket/4774
---
 ipalib/plugins/host.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index c4d4bdf6473e0f34c8c68754d6c98e93d173d8fa..d53b6a06da10f8a4bcda9b7241f3e99bbb84e9b8 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -162,6 +162,17 @@ def update_sshfp_record(zone, record, entry_attrs):
     except errors.EmptyModlist:
         pass
 
+
+def convert_ipaassignedidview_post(entry_attrs, options):
+    """
+    Converts the ID View DN to its name for the better looking output.
+    """
+
+    if 'ipaassignedidview' in entry_attrs and not options.get('raw'):
+        idview_name = entry_attrs.single_value['ipaassignedidview'][0].value
+        entry_attrs['ipaassignedidview'] = idview_name
+
+
 host_output_params = (
     Flag('has_keytab',
         label=_('Keytab'),
@@ -274,7 +285,7 @@ class host(LDAPObject):
         'fqdn', 'description', 'l', 'nshostlocation', 'krbprincipalname',
         'nshardwareplatform', 'nsosversion', 'usercertificate', 'memberof',
         'managedby', 'memberindirect', 'memberofindirect', 'macaddress',
-        'userclass', 'ipaallowedtoperform'
+        'userclass', 'ipaallowedtoperform', 'ipaassignedidview',
     ]
     uuid_attribute = 'ipauniqueid'
     attribute_members = {
@@ -502,6 +513,7 @@ class host(LDAPObject):
                   'local interpretation)'),
         ),
         DNParam('ipaassignedidview?',
+            label=_('Assigned ID View'),
             flags=['no_option'],
         ),
     ) + ticket_flags_params
@@ -1023,6 +1035,7 @@ class host_find(LDAPSearch):
                 entry_attrs['managing'] = self.obj.get_managed_hosts(entry_attrs.dn)
 
             convert_sshpubkey_post(ldap, entry_attrs.dn, entry_attrs)
+            convert_ipaassignedidview_post(entry_attrs, options)
 
         return truncated
 
@@ -1058,6 +1071,7 @@ class host_show(LDAPRetrieve):
         self.obj.suppress_netgroup_memberof(ldap, entry_attrs)
 
         convert_sshpubkey_post(ldap, dn, entry_attrs)
+        convert_ipaassignedidview_post(entry_attrs, options)
 
         return dn
 
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to