mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-24 15:16:40 -06:00
Code cleanup: remove unused stuff, take 1.
This commit is contained in:
parent
9873ec1ca3
commit
41312ca166
@ -100,9 +100,6 @@ class automountlocation(LDAPObject):
|
||||
object_name_plural = 'automount locations'
|
||||
object_class = ['nscontainer']
|
||||
default_attributes = ['cn']
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
}
|
||||
|
||||
takes_params = (
|
||||
Str('cn',
|
||||
@ -220,9 +217,6 @@ class automountmap(LDAPObject):
|
||||
object_name_plural = 'automount maps'
|
||||
object_class = ['automountmap']
|
||||
default_attributes = ['automountmapname', 'description']
|
||||
attribute_names = {
|
||||
'automountmapname': 'name',
|
||||
}
|
||||
|
||||
takes_params = (
|
||||
Str('automountmapname',
|
||||
@ -305,11 +299,6 @@ class automountkey(LDAPObject):
|
||||
default_attributes = [
|
||||
'automountkey', 'automountinformation', 'description'
|
||||
]
|
||||
attribute_names = {
|
||||
'automountkey': 'key',
|
||||
'automountinformation': 'mount information',
|
||||
}
|
||||
attribute_order = ['automountkey', 'automountinformation']
|
||||
|
||||
takes_params = (
|
||||
Str('automountkey',
|
||||
|
@ -69,8 +69,6 @@ class LDAPObject(Object):
|
||||
default_attributes = []
|
||||
hidden_attributes = ['objectclass', 'aci']
|
||||
uuid_attribute = ''
|
||||
attribute_names = {}
|
||||
attribute_order = []
|
||||
attribute_members = {}
|
||||
|
||||
def get_dn(self, *keys, **kwargs):
|
||||
@ -109,26 +107,6 @@ class LDAPObject(Object):
|
||||
)
|
||||
del entry_attrs[attr]
|
||||
|
||||
def print_entry(self, textui, entry, *keys, **options):
|
||||
if options.get('raw', False):
|
||||
textui.print_attribute('dn', entry[0])
|
||||
textui.print_entry1(entry[1], attr_order=self.attribute_order)
|
||||
else:
|
||||
if self.primary_key and keys[-1] is not None:
|
||||
textui.print_attribute(
|
||||
self.object_name.capitalize(), keys[-1], indent=0
|
||||
)
|
||||
else:
|
||||
textui.print_plain(self.object_name.capitalize())
|
||||
entry_attrs = entry[1]
|
||||
for a in self.hidden_attributes:
|
||||
if a in entry_attrs:
|
||||
del entry_attrs[a]
|
||||
textui.print_entry1(
|
||||
entry_attrs, attr_map=self.attribute_names,
|
||||
attr_order=self.attribute_order, one_value_per_line=False
|
||||
)
|
||||
|
||||
|
||||
# Options used by create and update.
|
||||
_attr_options = (
|
||||
@ -197,24 +175,6 @@ class LDAPCreate(crud.Create):
|
||||
return dict(result=entry_attrs, value=keys[-1])
|
||||
return dict(result=entry_attrs, value=u'')
|
||||
|
||||
def dont_output_for_cli(self, textui, entry, *keys, **options):
|
||||
textui.print_name(self.name)
|
||||
self.obj.print_entry(textui, entry, *keys, **options)
|
||||
if len(keys) > 1:
|
||||
textui.print_dashed(
|
||||
'Created %s "%s" in %s "%s".' % (
|
||||
self.obj.object_name, keys[-1],
|
||||
self.api.Object[self.obj.parent_object].object_name,
|
||||
keys[-2]
|
||||
)
|
||||
)
|
||||
elif len(keys) == 1:
|
||||
textui.print_dashed(
|
||||
'Created %s "%s".' % (self.obj.object_name, keys[-1])
|
||||
)
|
||||
else:
|
||||
textui.print_dashed('Created %s.' % self.obj.object_name)
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
return dn
|
||||
|
||||
@ -261,10 +221,6 @@ class LDAPRetrieve(LDAPQuery):
|
||||
return dict(result=entry_attrs, value=keys[-1])
|
||||
return dict(result=entry_attrs, value=u'')
|
||||
|
||||
def dont_output_for_cli(self, textui, entry, *keys, **options):
|
||||
textui.print_name(self.name)
|
||||
self.obj.print_entry(textui, entry, *keys, **options)
|
||||
|
||||
def pre_callback(self, ldap, dn, attrs_list, *keys, **options):
|
||||
return dn
|
||||
|
||||
@ -327,24 +283,6 @@ class LDAPUpdate(LDAPQuery, crud.Update):
|
||||
return dict(result=entry_attrs, value=keys[-1])
|
||||
return dict(result=entry_attrs, value=u'')
|
||||
|
||||
def dont_output_for_cli(self, textui, entry, *keys, **options):
|
||||
textui.print_name(self.name)
|
||||
self.obj.print_entry(textui, entry, *keys, **options)
|
||||
if len(keys) > 1:
|
||||
textui.print_dashed(
|
||||
'Modified %s "%s" in %s "%s".' % (
|
||||
self.obj.object_name, keys[-1],
|
||||
self.api.Object[self.obj.parent_object].object_name,
|
||||
keys[-2]
|
||||
)
|
||||
)
|
||||
elif len(keys) == 1:
|
||||
textui.print_dashed(
|
||||
'Modified %s "%s".' % (self.obj.object_name, keys[-1])
|
||||
)
|
||||
else:
|
||||
textui.print_dashed('Modified %s.' % self.obj.object_name)
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
return dn
|
||||
|
||||
@ -387,23 +325,6 @@ class LDAPDelete(LDAPQuery):
|
||||
return dict(result=result, value=keys[-1])
|
||||
return dict(result=result, value=u'')
|
||||
|
||||
def dont_output_for_cli(self, textui, result, *keys, **options):
|
||||
textui.print_name(self.name)
|
||||
if len(keys) > 1:
|
||||
textui.print_dashed(
|
||||
'Deleted %s "%s" in %s "%s".' % (
|
||||
self.obj.object_name, keys[-1],
|
||||
self.api.Object[self.obj.parent_object].object_name,
|
||||
keys[-2]
|
||||
)
|
||||
)
|
||||
elif len(keys) == 1:
|
||||
textui.print_dashed(
|
||||
'Deleted %s "%s".' % (self.obj.object_name, keys[-1])
|
||||
)
|
||||
else:
|
||||
textui.print_dashed('Deleted %s.' % self.obj.object_name)
|
||||
|
||||
def pre_callback(self, ldap, dn, *keys, **options):
|
||||
return dn
|
||||
|
||||
@ -448,23 +369,6 @@ class LDAPModMember(LDAPQuery):
|
||||
failed[attr][ldap_obj_name].append(name)
|
||||
return (dns, failed)
|
||||
|
||||
def dont_output_for_cli(self, textui, result, *keys, **options):
|
||||
(completed, failed, entry) = result
|
||||
|
||||
for (attr, objs) in failed.iteritems():
|
||||
for ldap_obj_name in objs:
|
||||
if failed[attr][ldap_obj_name]:
|
||||
failed_string = ','.join(failed[attr][ldap_obj_name])
|
||||
textui.print_plain('%ss failed: %s' % (
|
||||
to_cli(ldap_obj_name), failed_string
|
||||
)
|
||||
)
|
||||
textui.print_name(self.name)
|
||||
self.obj.print_entry(textui, entry, *keys, **options)
|
||||
textui.print_count(
|
||||
completed, self.member_count_out[0], self.member_count_out[1]
|
||||
)
|
||||
|
||||
|
||||
class LDAPAddMember(LDAPModMember):
|
||||
"""
|
||||
@ -681,27 +585,6 @@ class LDAPSearch(crud.Search):
|
||||
truncated=truncated,
|
||||
)
|
||||
|
||||
def dont_output_for_cli(self, textui, result, *args, **options):
|
||||
(entries, truncated) = result
|
||||
|
||||
textui.print_name(self.name)
|
||||
for e in entries:
|
||||
self.obj.print_entry(textui, e, e[0], **options)
|
||||
textui.print_plain('')
|
||||
textui.print_count(
|
||||
len(entries),
|
||||
'%i ' + self.obj.object_name + ' matched.',
|
||||
'%i ' + self.obj.object_name_plural + ' matched.',
|
||||
)
|
||||
if truncated:
|
||||
textui.print_dashed('These results are truncated.', below=False)
|
||||
textui.print_dashed(
|
||||
'Please refine your search and try again.', above=False
|
||||
)
|
||||
elif len(entries) == 0:
|
||||
# nothing was found, return error code 1
|
||||
return 1
|
||||
|
||||
def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
|
||||
return filter
|
||||
|
||||
|
@ -38,19 +38,6 @@ class config(LDAPObject):
|
||||
'ipasearchrecordslimit', 'ipausersearchfields', 'ipagroupsearchfields',
|
||||
'ipamigrationenabled', 'ipacertificatesubjectbase',
|
||||
]
|
||||
attribute_names = {
|
||||
'ipamaxusernamelength': 'maximum username length',
|
||||
'ipahomesrootdir': 'root of home directories',
|
||||
'ipadefaultloginshell': 'default login shell',
|
||||
'ipadefaultprimarygroup': 'default primary group',
|
||||
'ipadefaultdomain': 'default e-mail domain',
|
||||
'ipasearchtimelimit': 'time limit for search queries',
|
||||
'ipasearchrecordslimit': 'result count limit for search queries',
|
||||
'ipausersearchfields': 'search fields for users',
|
||||
'ipagroupsearchfields': 'search fields for groups',
|
||||
'ipamigrationenabled': 'enable migration mode',
|
||||
'ipacertificatesubjectbase': 'base for certificate subjects',
|
||||
}
|
||||
|
||||
takes_params = (
|
||||
Int('ipamaxusernamelength?',
|
||||
|
@ -40,16 +40,6 @@ class group(LDAPObject):
|
||||
'cn', 'description', 'gidnumber', 'member', 'memberof'
|
||||
]
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'gidnumber': 'group id',
|
||||
'member_user': 'member users',
|
||||
'member_group': 'member groups',
|
||||
'memberof_group': 'member of groups',
|
||||
'memberof_netgroup': 'member of netgroups',
|
||||
'memberof_rolegroup': 'member of rolegroup',
|
||||
'memberof_taskgroup': 'member of taskgroup',
|
||||
}
|
||||
attribute_members = {
|
||||
'member': ['user', 'group'],
|
||||
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
|
||||
|
@ -39,20 +39,6 @@ class hbac(LDAPObject):
|
||||
|
||||
]
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'accessruletype': 'type',
|
||||
'ipaenabledflag': 'enabled',
|
||||
'servicename': 'service',
|
||||
'ipauniqueid': 'unique id',
|
||||
'memberuser user': 'affected users',
|
||||
'memberuser group': 'affected groups',
|
||||
'memberhost host': 'affected hosts',
|
||||
'memberhost hostgroup': 'affected hostgroups',
|
||||
'sourcehost host': 'affected source hosts',
|
||||
'sourcehost hostgroup': 'affected source hostgroups',
|
||||
}
|
||||
attribute_order = ['cn', 'accessruletype', 'ipaenabledflag', 'servicename']
|
||||
attribute_members = {
|
||||
'memberuser': ['user', 'group'],
|
||||
'memberhost': ['host', 'hostgroup'],
|
||||
|
@ -58,22 +58,6 @@ class host(LDAPObject):
|
||||
'nshardwareplatform', 'nsosversion', 'usercertificate', 'memberof',
|
||||
]
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'fqdn': 'hostname',
|
||||
'localityname': 'locality',
|
||||
'l': 'locality',
|
||||
'nshostlocation': 'location',
|
||||
'nshardwareplatform': 'platform',
|
||||
'nsosversion': 'operating system',
|
||||
'serverhostname': 'server hostname',
|
||||
'enrolledby user': 'enrolled by',
|
||||
'krbprincipalname': 'kerberos principal',
|
||||
'ipauniqueid': 'unique identifier',
|
||||
'memberof_hostgroup': 'member of hostgroups',
|
||||
'memberof_netgroup': 'member of netgroups',
|
||||
'memberof_rolegroup': 'member of rolegroups',
|
||||
}
|
||||
attribute_members = {
|
||||
'enrolledby': ['user'],
|
||||
'memberof': ['hostgroup', 'netgroup', 'rolegroup'],
|
||||
|
@ -35,12 +35,6 @@ class hostgroup(LDAPObject):
|
||||
object_class = ['ipaobject', 'ipahostgroup']
|
||||
default_attributes = ['cn', 'description', 'member', 'memberof']
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'cn': 'names',
|
||||
'member_host': 'member hosts',
|
||||
'member_hostgroup': 'member hostgroups',
|
||||
'memberof_hostgroup': 'member of hostgroup',
|
||||
}
|
||||
attribute_members = {
|
||||
'member': ['host', 'hostgroup'],
|
||||
'memberof': ['hostgroup'],
|
||||
|
@ -40,10 +40,6 @@ class krbtpolicy(LDAPObject):
|
||||
container_dn = 'cn=%s,cn=kerberos' % api.env.realm
|
||||
object_name = 'kerberos ticket policy settings'
|
||||
default_attributes = ['krbmaxticketlife', 'krbmaxrenewableage']
|
||||
attribute_names = {
|
||||
'krbmaxticketlife': 'maximum life',
|
||||
'krbmaxrenewableage': 'maximum renewable age',
|
||||
}
|
||||
|
||||
takes_params = (
|
||||
Str('uid?',
|
||||
|
@ -39,16 +39,6 @@ class netgroup(LDAPObject):
|
||||
'nisdomainname',
|
||||
]
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'member_user': 'member users',
|
||||
'member_group': 'member groups',
|
||||
'member_host': 'member hosts',
|
||||
'member_hostgroup': 'member hostgroups',
|
||||
'member_netgroup': 'member netgroups',
|
||||
'memberof_netgroup': 'member of netgroups',
|
||||
'externalhost': 'externalhost',
|
||||
}
|
||||
attribute_members = {
|
||||
'member': ['user', 'group', 'host', 'hostgroup', 'netgroup'],
|
||||
'memberof': ['netgroup'],
|
||||
|
@ -34,14 +34,6 @@ class rolegroup(LDAPObject):
|
||||
object_name_plural = 'rolegroups'
|
||||
object_class = ['groupofnames', 'nestedgroup']
|
||||
default_attributes = ['cn', 'description', 'member', 'memberof']
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'member_user': 'member users',
|
||||
'member_group': 'member groups',
|
||||
'member_host': 'member hosts',
|
||||
'member_hostgroup': 'member hostgroups',
|
||||
'memberof_taskgroup': 'member of taskgroup',
|
||||
}
|
||||
attribute_members = {
|
||||
'member': ['user', 'group', 'host', 'hostgroup'],
|
||||
'memberof': ['taskgroup'],
|
||||
|
@ -109,12 +109,6 @@ class service(LDAPObject):
|
||||
]
|
||||
default_attributes = ['krbprincipalname', 'usercertificate', 'managedby']
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'krbprincipalname': 'kerberos principal',
|
||||
'usercertificate': 'user certificate',
|
||||
'ipauniqueid': 'unique identifier',
|
||||
'managedby': 'managed by',
|
||||
}
|
||||
attribute_members = {
|
||||
'managedby': ['host'],
|
||||
}
|
||||
|
@ -35,13 +35,6 @@ class taskgroup(LDAPObject):
|
||||
object_name_plural = 'taskgroups'
|
||||
object_class = ['groupofnames']
|
||||
default_attributes = ['cn', 'description', 'member', 'memberof']
|
||||
attribute_names = {
|
||||
'cn': 'name',
|
||||
'member_user': 'member users',
|
||||
'member_group': 'member groups',
|
||||
'member_rolegroup': 'member rolegroups',
|
||||
# FIXME: 'memberof ???': 'member of ???'
|
||||
}
|
||||
attribute_members = {
|
||||
'member': ['user', 'group', 'rolegroup'],
|
||||
# FIXME: taskgroup can be member of ???
|
||||
|
@ -41,29 +41,6 @@ class user(LDAPObject):
|
||||
'telephonenumber', 'title', 'memberof',
|
||||
]
|
||||
uuid_attribute = 'ipauniqueid'
|
||||
attribute_names = {
|
||||
'uid': 'user id',
|
||||
'cn': 'full name',
|
||||
'givenname': 'first name',
|
||||
'sn': 'last name',
|
||||
'homedirectory': 'home directory',
|
||||
'loginshell': 'login shell',
|
||||
'krbprincipalname': 'kerberos principal',
|
||||
'krblastpwdchange': 'last password change',
|
||||
'krbpasswordexpiration': 'password expiration',
|
||||
'uidnumber': 'uid number',
|
||||
'gidnumber': 'gid number',
|
||||
'memberof_group': 'member of groups',
|
||||
'memberof_netgroup': 'member of netgroups',
|
||||
'memberof_rolegroup': 'member of rolegroups',
|
||||
'memberof_taskgroup': 'member of taskgroups',
|
||||
'ipauniqueid': 'unique identifier'
|
||||
}
|
||||
attribute_order = [
|
||||
'uid', 'cn', 'givenname', 'sn', 'title', 'telephonenumber', 'ou',
|
||||
'homedirectory', 'loginshell', 'uidnumber', 'gidnumber', 'gecos',
|
||||
'krbprincipalname', 'krblastpwdchange', 'krbpasswordexpiration',
|
||||
]
|
||||
attribute_members = {
|
||||
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
|
||||
}
|
||||
@ -132,6 +109,18 @@ class user(LDAPObject):
|
||||
label=_('Groups'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
),
|
||||
Str('memberof_netgroup?',
|
||||
label=_('Netgroups'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
),
|
||||
Str('memberof_rolegroup?',
|
||||
label=_('Rolegroups'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
),
|
||||
Str('memberof_taskgroup?',
|
||||
label=_('Taskgroups'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
),
|
||||
)
|
||||
|
||||
api.register(user)
|
||||
|
Loading…
Reference in New Issue
Block a user