On 12/02/2014 05:23 PM, Jan Cholasta wrote: > Dne 2.12.2014 v 17:01 Tomas Babej napsal(a): >> >> On 12/02/2014 04:14 PM, Jan Cholasta wrote: >>> Hi, >>> >>> Dne 2.12.2014 v 15:43 Tomas Babej napsal(a): >>>> 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 >>> >>> Since you are converting the value from DN to primary key string, the >>> type of the ipassignedview param should be changed to Str, for >>> consistency with existing code. >>> >>> Honza >>> >> >> I see. Actually during the development, I craved for simple >> output_normalizer option in the Param itself, which would apply the >> output normalization funtion after the post_callback, >> instead of having to mangle the entry_attrs in the post callback of each >> command (and could potentionally apply on the client). Would there a be >> not-so-hard way to do this in the framework? My understanding is that >> Output classes are quite decoupled from the Params they resulted from, >> and at the point we're printing the information via the textui, we're no >> longer aware what Param instance it originated from. > > This wouldn't solve the real problem in this case, which is that we do > not support one-to-many relationships between objects in the framework > (and our support for many-to-many relationships is clunky). I plan to > fix this with <https://fedorahosted.org/freeipa/ticket/3932>. > >> >> Updated patch attached. >> > >
Updated patch with fixed WebUI bits. -- Tomas Babej Associate Software Engineer | Red Hat | Identity Management RHCE | Brno Site | IRC: tbabej | freeipa.org
>From eeec6d3470a6eafff4dac0988520012f4fea0d8e Mon Sep 17 00:00:00 2001 From: Tomas Babej <tba...@redhat.com> 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 --- API.txt | 6 +++--- VERSION | 4 ++-- install/ui/src/freeipa/host.js | 1 - ipalib/plugins/host.py | 21 ++++++++++++++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/API.txt b/API.txt index 2a63f1e2349f0df69433fa7cb742e269cd42d79f..dcb655d87f0495b65b8d743ab477d59ad1963b36 100644 --- a/API.txt +++ b/API.txt @@ -1793,7 +1793,7 @@ option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui option: Str('description', attribute=True, cli_name='desc', multivalue=False, required=False) option: Flag('force', autofill=True, default=False) option: Str('ip_address?') -option: DNParam('ipaassignedidview', attribute=True, cli_name='ipaassignedidview', multivalue=False, required=False) +option: Str('ipaassignedidview', attribute=True, cli_name='ipaassignedidview', multivalue=False, required=False) option: Bool('ipakrbokasdelegate', attribute=False, cli_name='ok_as_delegate', multivalue=False, required=False) option: Bool('ipakrbrequirespreauth', attribute=False, cli_name='requires_pre_auth', multivalue=False, required=False) option: Str('ipasshpubkey', attribute=True, cli_name='sshpubkey', csv=True, multivalue=True, required=False) @@ -1901,7 +1901,7 @@ option: Str('in_hostgroup*', cli_name='in_hostgroups', csv=True) option: Str('in_netgroup*', cli_name='in_netgroups', csv=True) option: Str('in_role*', cli_name='in_roles', csv=True) option: Str('in_sudorule*', cli_name='in_sudorules', csv=True) -option: DNParam('ipaassignedidview', attribute=True, autofill=False, cli_name='ipaassignedidview', multivalue=False, query=True, required=False) +option: Str('ipaassignedidview', attribute=True, autofill=False, cli_name='ipaassignedidview', multivalue=False, query=True, required=False) option: Str('l', attribute=True, autofill=False, cli_name='locality', multivalue=False, query=True, required=False) option: Str('macaddress', attribute=True, autofill=False, cli_name='macaddress', csv=True, multivalue=True, pattern='^([a-fA-F0-9]{2}[:|\\-]?){5}[a-fA-F0-9]{2}$', query=True, required=False) option: Str('man_by_host*', cli_name='man_by_hosts', csv=True) @@ -1937,7 +1937,7 @@ option: Str('addattr*', cli_name='addattr', exclude='webui') option: Flag('all', autofill=True, cli_name='all', default=False, exclude='webui') option: Str('delattr*', cli_name='delattr', exclude='webui') option: Str('description', attribute=True, autofill=False, cli_name='desc', multivalue=False, required=False) -option: DNParam('ipaassignedidview', attribute=True, autofill=False, cli_name='ipaassignedidview', multivalue=False, required=False) +option: Str('ipaassignedidview', attribute=True, autofill=False, cli_name='ipaassignedidview', multivalue=False, required=False) option: Bool('ipakrbokasdelegate', attribute=False, autofill=False, cli_name='ok_as_delegate', multivalue=False, required=False) option: Bool('ipakrbrequirespreauth', attribute=False, autofill=False, cli_name='requires_pre_auth', multivalue=False, required=False) option: Str('ipasshpubkey', attribute=True, autofill=False, cli_name='sshpubkey', csv=True, multivalue=True, required=False) diff --git a/VERSION b/VERSION index bae782a4ec4333f8fdb610465a7b9ea3877c990e..5b426ddf1a3b7f9e6b202fd7d9f6b6025acc0370 100644 --- a/VERSION +++ b/VERSION @@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000 # # ######################################################## IPA_API_VERSION_MAJOR=2 -IPA_API_VERSION_MINOR=109 -# Last change: npmccallum - display qrcode by default +IPA_API_VERSION_MINOR=110 +# Last change: tbabej - change ipaassignedidview to Str diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js index 455ff8f50ec58104d4e046ec0fabf2a7e89eeeb2..1120c82e708f20081ee9ec5f5c1b4c349d101b15 100644 --- a/install/ui/src/freeipa/host.js +++ b/install/ui/src/freeipa/host.js @@ -117,7 +117,6 @@ return { name: 'ipaassignedidview', $type: 'link', label: '@i18n:objects.idview.ipaassignedidview', - ui_formatter: 'dn', other_entity: 'idview' } ] diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index c4d4bdf6473e0f34c8c68754d6c98e93d173d8fa..32bf41c7d5c5401c2069dc791e6cd99ce70b91e5 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -22,7 +22,7 @@ from nss.error import NSPRError import string from ipalib import api, errors, util -from ipalib import Str, Flag, Bytes, DNParam +from ipalib import Str, Flag, Bytes from ipalib.plugable import Registry from ipalib.plugins.baseldap import (LDAPQuery, LDAPObject, LDAPCreate, LDAPDelete, LDAPUpdate, LDAPSearch, @@ -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.single_value['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 = { @@ -501,7 +512,8 @@ class host(LDAPObject): doc=_('Host category (semantics placed on this attribute are for ' 'local interpretation)'), ), - DNParam('ipaassignedidview?', + Str('ipaassignedidview?', + label=_('Assigned ID View'), flags=['no_option'], ), ) + ticket_flags_params @@ -937,6 +949,7 @@ class host_mod(LDAPUpdate): self.obj.suppress_netgroup_memberof(ldap, entry_attrs) convert_sshpubkey_post(ldap, dn, entry_attrs) + convert_ipaassignedidview_post(entry_attrs, options) return dn @@ -1023,6 +1036,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 +1072,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 Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel