From 4acf45785f917bb52382202279d5931469198f26 Mon Sep 17 00:00:00 2001 From: Tomas Babej 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 Reviewed-By: Petr Vobornik Reviewed-By: Jan Cholasta --- 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 e9768bf1e87d6679c439b98ed696b720937099d2..7949c49f9fb9e3cd7eceb64a05dd8e550eb48f8b 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) @@ -1909,7 +1909,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) @@ -1945,7 +1945,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 bfbce5604e79008afd2893e406c634718159b1e9..196be85e83de96f501352ca93f2c7ed6876ea641 100644 --- a/VERSION +++ b/VERSION @@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000 # # ######################################################## IPA_API_VERSION_MAJOR=2 -IPA_API_VERSION_MINOR=110 -# Last change: pvoborni - allow to retrieve keytab by hosts +IPA_API_VERSION_MINOR=112 +# 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 39a7d3c25b9cb56fca486b2500da5fe7bd4a6fbc..41710f3b87b5f60ac6e9b0765a25562b7074e2e8 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'), @@ -286,7 +297,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 = { @@ -513,7 +524,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 @@ -949,6 +961,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 @@ -1035,6 +1048,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 @@ -1070,6 +1084,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 -- 2.1.0