This is a patch from Martin Kosek, annotated to explain how to add an
LDAP attribute to IPA. You can find the change as commit
5af2e17
in the IPA source tree.
First, we need to add the attribute to the LDAP schema, so it is
available for new installs. Locate the appropriate objectclass
definition in install/share/, and add the desired attribute.
The next step is to add a parameter definition to the appropriate
framework object. In addition to the big takes_params list, there
may also be other lists of parameters (such as default_attributes
whose members are shown by *-find and *-show commands by
default). Update these lists as appropriate.
`` diff –git a/API.txt b/API.txt``
`` index 3e01fdc3611b5bc71e1a4ee185af63f7c4b07c06..c2400e901345a70e0236d1c02979220c19ece9a5 100644``
`` — a/API.txt``
`` +++ b/API.txt``
`` @@ -1723,7 +1723,7 @@ output: Output(‘summary’, (<type ‘unicode’>, <type ‘NoneType’>), None)``
`` output: Output(‘value’, <type ‘bool’>, None)``
`` output: Output(‘warning’, (<type ‘list’>, <type ‘tuple’>, <type ‘NoneType’>), None)``
`` command: host_add``
`` -args: 1,20,3``
`` +args: 1,21,3``
`` arg: Str(‘fqdn’, attribute=True, cli_name=’hostname’, multivalue=False, primary_key=True, required=True)``
`` option: Str(‘addattr*’, cli_name=’addattr’, exclude=’webui’)``
`` option: Flag(‘all’, autofill=True, cli_name=’all’, default=False, exclude=’webui’)``
`` @@ -1743,6 +1743,7 @@ option: Flag(‘random’, attribute=False, autofill=True, cli_name=’random’, defaul``
`` option: Flag(‘raw’, autofill=True, cli_name=’raw’, default=False, exclude=’webui’)``
`` option: Str(‘setattr*’, cli_name=’setattr’, exclude=’webui’)``
`` option: Bytes(‘usercertificate’, attribute=True, cli_name=’certificate’, multivalue=False, required=False)``
`` +option: Str(‘userclass’, attribute=True, cli_name=’class’, multivalue=True, required=False)``
`` option: Str(‘userpassword’, attribute=True, cli_name=’password’, multivalue=False, required=False)``
`` option: Str(‘version?’, exclude=’webui’)``
`` output: Entry(‘result’, <type ‘dict’>, Gettext(‘A dictionary representing an LDAP entry’, domain=’ipa’, localedir=None))``
`` @@ -1774,7 +1775,7 @@ output: Output(‘result’, <type ‘bool’>, None)``
`` output: Output(‘summary’, (<type ‘unicode’>, <type ‘NoneType’>), None)``
`` output: Output(‘value’, <type ‘unicode’>, None)``
`` command: host_find``
`` -args: 1,31,4``
`` +args: 1,32,4``
`` arg: Str(‘criteria?’, noextrawhitespace=False)``
`` option: Flag(‘all’, autofill=True, cli_name=’all’, default=False, exclude=’webui’)``
`` option: Str(‘description’, attribute=True, autofill=False, cli_name=’desc’, multivalue=False, query=True, required=False)``
`` @@ -1805,6 +1806,7 @@ option: Flag(‘raw’, autofill=True, cli_name=’raw’, default=False, exclude=’webui``
`` option: Int(‘sizelimit?’, autofill=False, minvalue=0)``
`` option: Int(‘timelimit?’, autofill=False, minvalue=0)``
`` option: Bytes(‘usercertificate’, attribute=True, autofill=False, cli_name=’certificate’, multivalue=False, query=True, required=False)``
`` +option: Str(‘userclass’, attribute=True, autofill=False, cli_name=’class’, multivalue=True, query=True, required=False)``
`` option: Str(‘userpassword’, attribute=True, autofill=False, cli_name=’password’, multivalue=False, query=True, required=False)``
`` option: Str(‘version?’, exclude=’webui’)``
`` output: Output(‘count’, <type ‘int’>, None)``
`` @@ -1812,7 +1814,7 @@ output: ListOfEntries(‘result’, (<type ‘list’>, <type ‘tuple’>), Gettext(‘A list``
`` output: Output(‘summary’, (<type ‘unicode’>, <type ‘NoneType’>), None)``
`` output: Output(‘truncated’, <type ‘bool’>, None)``
`` command: host_mod``
`` -args: 1,21,3``
`` +args: 1,22,3``
`` arg: Str(‘fqdn’, attribute=True, cli_name=’hostname’, multivalue=False, primary_key=True, query=True, required=True)``
`` option: Str(‘addattr*’, cli_name=’addattr’, exclude=’webui’)``
`` option: Flag(‘all’, autofill=True, cli_name=’all’, default=False, exclude=’webui’)``
`` @@ -1833,6 +1835,7 @@ option: Flag(‘rights’, autofill=True, default=False)``
`` option: Str(‘setattr*’, cli_name=’setattr’, exclude=’webui’)``
`` option: Flag(‘updatedns?’, autofill=True, default=False)``
`` option: Bytes(‘usercertificate’, attribute=True, autofill=False, cli_name=’certificate’, multivalue=False, required=False)``
`` +option: Str(‘userclass’, attribute=True, autofill=False, cli_name=’class’, multivalue=True, required=False)``
`` option: Str(‘userpassword’, attribute=True, autofill=False, cli_name=’password’, multivalue=False, required=False)``
`` option: Str(‘version?’, exclude=’webui’)``
`` output: Entry(‘result’, <type ‘dict’>, Gettext(‘A dictionary representing an LDAP entry’, domain=’ipa’, localedir=None))``
With every update of the API, you must bump the API version. When adding
parameters calls, only bump the minor version number.
And of course, every code change should be accompanied by a test.
`` diff –git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py``
`` index f788dc6bc6d55f46856ada4b816997bfb517d8c4..07faf77607284b2193716854b287208f563d9472 100644``
`` — a/tests/test_xmlrpc/test_host_plugin.py``
`` +++ b/tests/test_xmlrpc/test_host_plugin.py``
`` @@ -700,6 +700,7 @@ class test_host(Declarative):``
`` dict(``
`` description=u’Test host 2’,``
`` l=u’Undisclosed location 2’,``
`` + userclass=[u’webserver’, u’mailserver’],``
`` force=True,``
`` ),``
`` ),``
`` @@ -715,6 +716,7 @@ class test_host(Declarative):``
`` objectclass=objectclasses.host,``
`` ipauniqueid=[fuzzy_uuid],``
`` managedby_host=[fqdn2],``
`` + userclass=[u’webserver’, u’mailserver’],``
`` has_keytab=False,``
`` has_password=False,``
`` ),``
`` @@ -722,6 +724,27 @@ class test_host(Declarative):``
`` ),``
`` ``
`` ``
`` + dict(``
`` + desc=’Retrieve %r’ % fqdn2,``
`` + command=(‘host_show’, [fqdn2], {}),``
`` + expected=dict(``
`` + value=fqdn2,``
`` + summary=None,``
`` + result=dict(``
`` + dn=dn2,``
`` + fqdn=[fqdn2],``
`` + description=[u’Test host 2’],``
`` + l=[u’Undisclosed location 2’],``
`` + krbprincipalname=[
u’host/%s@%s’ % (fqdn2, api.env.realm)],``
`` + has_keytab=False,``
`` + has_password=False,``
`` + managedby_host=[fqdn2],``
`` + userclass=[u’webserver’, u’mailserver’],``
`` + ),``
`` + ),``
`` + ),``
`` +``
`` +``
`` # This test will only succeed when running against lite-server.py``
`` # on same box as IPA install.``
`` dict(``
`` – ``
`` 1.8.1.4``