mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib: replace DeprecatedParam with deprecated
Param argument
Introduce new `deprecated` Param keywork argument. Setting it to True on a param has the same effect as using DeprecatedParam. This allows deprecating params while retaining their type information. Revert all DeprecatedParam params back to their original definition and set `deprecated` to True. Remove the now unused DeprecatedParam class. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
28
API.txt
28
API.txt
@@ -941,7 +941,7 @@ option: Str('delattr*', cli_name='delattr')
|
||||
option: Bool('idnsallowsyncptr?', autofill=False, cli_name='allow_sync_ptr')
|
||||
option: Str('idnsforwarders*', autofill=False, cli_name='forwarder')
|
||||
option: StrEnum('idnsforwardpolicy?', autofill=False, cli_name='forward_policy', values=[u'only', u'first', u'none'])
|
||||
option: DeprecatedParam('idnszonerefresh?', autofill=False, cli_name='zone_refresh')
|
||||
option: Int('idnszonerefresh?', autofill=False, cli_name='zone_refresh', deprecated=True)
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: Flag('rights', autofill=True, default=False)
|
||||
option: Str('setattr*', cli_name='setattr')
|
||||
@@ -1662,7 +1662,7 @@ output: Entry('result')
|
||||
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
||||
output: PrimaryKey('value')
|
||||
command: hbacrule_add
|
||||
args: 1,16,3
|
||||
args: 1,14,3
|
||||
arg: Str('cn', cli_name='name')
|
||||
option: StrEnum('accessruletype', autofill=True, cli_name='type', default=u'allow', values=[u'allow', u'deny'])
|
||||
option: Str('addattr*', cli_name='addattr')
|
||||
@@ -1675,9 +1675,7 @@ option: Flag('no_members', autofill=True, default=False)
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: StrEnum('servicecategory?', cli_name='servicecat', values=[u'all'])
|
||||
option: Str('setattr*', cli_name='setattr')
|
||||
option: DeprecatedParam('sourcehost_host?')
|
||||
option: DeprecatedParam('sourcehost_hostgroup?')
|
||||
option: DeprecatedParam('sourcehostcategory?')
|
||||
option: StrEnum('sourcehostcategory?', cli_name='srchostcat', deprecated=True, values=[u'all'])
|
||||
option: StrEnum('usercategory?', cli_name='usercat', values=[u'all'])
|
||||
option: Str('version?')
|
||||
output: Entry('result')
|
||||
@@ -1754,7 +1752,7 @@ output: Output('result', type=[<type 'bool'>])
|
||||
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
||||
output: PrimaryKey('value')
|
||||
command: hbacrule_find
|
||||
args: 1,18,4
|
||||
args: 1,16,4
|
||||
arg: Str('criteria?')
|
||||
option: StrEnum('accessruletype?', autofill=False, cli_name='type', default=u'allow', values=[u'allow', u'deny'])
|
||||
option: Flag('all', autofill=True, cli_name='all', default=False)
|
||||
@@ -1768,9 +1766,7 @@ option: Flag('pkey_only?', autofill=True, default=False)
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: StrEnum('servicecategory?', autofill=False, cli_name='servicecat', values=[u'all'])
|
||||
option: Int('sizelimit?', autofill=False)
|
||||
option: DeprecatedParam('sourcehost_host?', autofill=False)
|
||||
option: DeprecatedParam('sourcehost_hostgroup?', autofill=False)
|
||||
option: DeprecatedParam('sourcehostcategory?', autofill=False)
|
||||
option: StrEnum('sourcehostcategory?', autofill=False, cli_name='srchostcat', deprecated=True, values=[u'all'])
|
||||
option: Int('timelimit?', autofill=False)
|
||||
option: StrEnum('usercategory?', autofill=False, cli_name='usercat', values=[u'all'])
|
||||
option: Str('version?')
|
||||
@@ -1779,7 +1775,7 @@ output: ListOfEntries('result')
|
||||
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
||||
output: Output('truncated', type=[<type 'bool'>])
|
||||
command: hbacrule_mod
|
||||
args: 1,18,3
|
||||
args: 1,16,3
|
||||
arg: Str('cn', cli_name='name')
|
||||
option: StrEnum('accessruletype?', autofill=False, cli_name='type', default=u'allow', values=[u'allow', u'deny'])
|
||||
option: Str('addattr*', cli_name='addattr')
|
||||
@@ -1794,9 +1790,7 @@ option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: Flag('rights', autofill=True, default=False)
|
||||
option: StrEnum('servicecategory?', autofill=False, cli_name='servicecat', values=[u'all'])
|
||||
option: Str('setattr*', cli_name='setattr')
|
||||
option: DeprecatedParam('sourcehost_host?', autofill=False)
|
||||
option: DeprecatedParam('sourcehost_hostgroup?', autofill=False)
|
||||
option: DeprecatedParam('sourcehostcategory?', autofill=False)
|
||||
option: StrEnum('sourcehostcategory?', autofill=False, cli_name='srchostcat', deprecated=True, values=[u'all'])
|
||||
option: StrEnum('usercategory?', autofill=False, cli_name='usercat', values=[u'all'])
|
||||
option: Str('version?')
|
||||
output: Entry('result')
|
||||
@@ -2017,7 +2011,7 @@ option: Flag('nodetail?', autofill=True, cli_name='nodetail', default=False)
|
||||
option: Str('rules*', cli_name='rules')
|
||||
option: Str('service', cli_name='service')
|
||||
option: Int('sizelimit?', autofill=False)
|
||||
option: DeprecatedParam('sourcehost?')
|
||||
option: Str('sourcehost?', cli_name='srchost', deprecated=True)
|
||||
option: Str('targethost', cli_name='host')
|
||||
option: Str('user', cli_name='user')
|
||||
option: Str('version?')
|
||||
@@ -2608,8 +2602,8 @@ option: Str('delattr*', cli_name='delattr')
|
||||
option: Int('ipabaseid?', autofill=False, cli_name='base_id')
|
||||
option: Int('ipabaserid?', autofill=False, cli_name='rid_base')
|
||||
option: Int('ipaidrangesize?', autofill=False, cli_name='range_size')
|
||||
option: DeprecatedParam('ipanttrusteddomainname?')
|
||||
option: DeprecatedParam('ipanttrusteddomainsid?')
|
||||
option: Str('ipanttrusteddomainname?', autofill=False, cli_name='dom_name', deprecated=True)
|
||||
option: Str('ipanttrusteddomainsid?', autofill=False, cli_name='dom_sid', deprecated=True)
|
||||
option: Int('ipasecondarybaserid?', autofill=False, cli_name='secondary_rid_base')
|
||||
option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
||||
option: Flag('rights', autofill=True, default=False)
|
||||
@@ -4266,7 +4260,7 @@ option: Str('displayname?', autofill=True)
|
||||
option: Str('employeenumber?')
|
||||
option: Str('employeetype?')
|
||||
option: Str('facsimiletelephonenumber*', cli_name='fax')
|
||||
option: DeprecatedParam('from_delete?', cli_name='from_delete', default=False)
|
||||
option: Bool('from_delete?', cli_name='from_delete', deprecated=True)
|
||||
option: Str('gecos?', autofill=True)
|
||||
option: Int('gidnumber?')
|
||||
option: Str('givenname', cli_name='first')
|
||||
|
4
VERSION
4
VERSION
@@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
|
||||
# #
|
||||
########################################################
|
||||
IPA_API_VERSION_MAJOR=2
|
||||
IPA_API_VERSION_MINOR=171
|
||||
# Last change: npmccallum - enable setting authinds on services
|
||||
IPA_API_VERSION_MINOR=172
|
||||
# Last change: ipalib: replace DeprecatedParam with `deprecated` Param argument
|
||||
|
@@ -887,7 +887,7 @@ from ipalib.backend import Backend
|
||||
from ipalib.frontend import Command, LocalOrRemote, Updater
|
||||
from ipalib.frontend import Object, Method
|
||||
from ipalib.crud import Create, Retrieve, Update, Delete, Search
|
||||
from ipalib.parameters import DefaultFrom, Bool, Flag, Int, Decimal, Bytes, Str, IA5Str, Password, DNParam, DeprecatedParam
|
||||
from ipalib.parameters import DefaultFrom, Bool, Flag, Int, Decimal, Bytes, Str, IA5Str, Password, DNParam
|
||||
from ipalib.parameters import (BytesEnum, StrEnum, IntEnum, AccessTime, File,
|
||||
DateTime, DNSNameParam)
|
||||
from ipalib.errors import SkipPluginModule
|
||||
|
@@ -415,6 +415,7 @@ class Param(ReadOnly):
|
||||
('option_group', unicode, None),
|
||||
('cli_metavar', str, None),
|
||||
('no_convert', bool, False),
|
||||
('deprecated', bool, False),
|
||||
|
||||
# The 'default' kwarg gets appended in Param.__init__():
|
||||
# ('default', self.type, None),
|
||||
@@ -871,6 +872,10 @@ class Param(ReadOnly):
|
||||
if error is not None:
|
||||
raise ValidationError(name=self.get_param_name(), error=error)
|
||||
|
||||
def _rule_deprecated(self, _, value):
|
||||
if self.deprecated:
|
||||
return _('this option is deprecated')
|
||||
|
||||
def get_default(self, **kw):
|
||||
"""
|
||||
Return the static default or construct and return a dynamic default.
|
||||
@@ -1870,22 +1875,6 @@ class DNParam(Param):
|
||||
return dn
|
||||
|
||||
|
||||
class DeprecatedParam(Any):
|
||||
kwargs = Param.kwargs + (
|
||||
('deprecate', bool, True),
|
||||
)
|
||||
|
||||
def __init__(self, name, *rules, **kw):
|
||||
if 'flags' in kw:
|
||||
kw['flags'] = list(kw['flags']) + ['no_option']
|
||||
else:
|
||||
kw['flags'] = ['no_option']
|
||||
|
||||
super(DeprecatedParam, self).__init__(name, *rules, **kw)
|
||||
|
||||
def _rule_deprecate(self, _, value):
|
||||
return _('this option is deprecated')
|
||||
|
||||
def create_param(spec):
|
||||
"""
|
||||
Create an `Str` instance from the shorthand ``spec``.
|
||||
|
@@ -44,7 +44,7 @@ from ipalib.capabilities import (
|
||||
VERSION_WITHOUT_CAPABILITIES,
|
||||
client_has_capability)
|
||||
from ipalib.parameters import (Flag, Bool, Int, Decimal, Str, StrEnum, Any,
|
||||
DeprecatedParam, DNSNameParam)
|
||||
DNSNameParam)
|
||||
from ipalib.plugable import Registry
|
||||
from .baseldap import (
|
||||
pkey_to_value,
|
||||
@@ -4053,9 +4053,13 @@ class dnsconfig(LDAPObject):
|
||||
label=_('Allow PTR sync'),
|
||||
doc=_('Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
|
||||
),
|
||||
DeprecatedParam('idnszonerefresh?',
|
||||
Int('idnszonerefresh?',
|
||||
deprecated=True,
|
||||
cli_name='zone_refresh',
|
||||
label=_('Zone refresh interval'),
|
||||
doc=_('An interval between regular polls of the name server for new DNS zones'),
|
||||
minvalue=0,
|
||||
flags={'no_option'},
|
||||
),
|
||||
Int('ipadnsversion?', # available only in installer/upgrade
|
||||
label=_('IPA DNS version'),
|
||||
|
@@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ipalib import api, errors
|
||||
from ipalib import AccessTime, Str, StrEnum, Bool, DeprecatedParam
|
||||
from ipalib import AccessTime, Str, StrEnum, Bool
|
||||
from ipalib.plugable import Registry
|
||||
from .baseldap import (
|
||||
pkey_to_value,
|
||||
@@ -230,7 +230,14 @@ class hbacrule(LDAPObject):
|
||||
doc=_('Host category the rule applies to'),
|
||||
values=(u'all', ),
|
||||
),
|
||||
DeprecatedParam('sourcehostcategory?'),
|
||||
StrEnum('sourcehostcategory?',
|
||||
deprecated=True,
|
||||
cli_name='srchostcat',
|
||||
label=_('Source host category'),
|
||||
doc=_('Source host category the rule applies to'),
|
||||
values=(u'all', ),
|
||||
flags={'no_option'},
|
||||
),
|
||||
StrEnum('servicecategory?',
|
||||
cli_name='servicecat',
|
||||
label=_('Service category'),
|
||||
@@ -265,8 +272,16 @@ class hbacrule(LDAPObject):
|
||||
label=_('Host Groups'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
),
|
||||
DeprecatedParam('sourcehost_host?'),
|
||||
DeprecatedParam('sourcehost_hostgroup?'),
|
||||
Str('sourcehost_host?',
|
||||
deprecated=True,
|
||||
label=_('Source Hosts'),
|
||||
flags=['no_create', 'no_update', 'no_search', 'no_option'],
|
||||
),
|
||||
Str('sourcehost_hostgroup?',
|
||||
deprecated=True,
|
||||
label=_('Source Host Groups'),
|
||||
flags=['no_create', 'no_update', 'no_search', 'no_option'],
|
||||
),
|
||||
Str('memberservice_hbacsvc?',
|
||||
label=_('Services'),
|
||||
flags=['no_create', 'no_update', 'no_search'],
|
||||
|
@@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ipalib import api, errors, output, util
|
||||
from ipalib import Command, Str, Flag, Int, DeprecatedParam
|
||||
from ipalib import Command, Str, Flag, Int
|
||||
from ipalib import _
|
||||
from ipapython.dn import DN
|
||||
from ipalib.plugable import Registry
|
||||
@@ -261,7 +261,12 @@ class hbactest(Command):
|
||||
label=_('User name'),
|
||||
primary_key=True,
|
||||
),
|
||||
DeprecatedParam('sourcehost?'),
|
||||
Str('sourcehost?',
|
||||
deprecated=True,
|
||||
cli_name='srchost',
|
||||
label=_('Source host'),
|
||||
flags={'no_option'},
|
||||
),
|
||||
Str('targethost',
|
||||
cli_name='host',
|
||||
label=_('Target host'),
|
||||
|
@@ -22,7 +22,7 @@ import six
|
||||
from ipalib.plugable import Registry
|
||||
from .baseldap import (LDAPObject, LDAPCreate, LDAPDelete,
|
||||
LDAPRetrieve, LDAPSearch, LDAPUpdate)
|
||||
from ipalib import api, Int, Str, DeprecatedParam, StrEnum, _, ngettext
|
||||
from ipalib import api, Int, Str, StrEnum, _, ngettext
|
||||
from ipalib import errors
|
||||
from ipapython.dn import DN
|
||||
|
||||
@@ -617,8 +617,22 @@ class idrange_mod(LDAPUpdate):
|
||||
msg_summary = _('Modified ID range "%(value)s"')
|
||||
|
||||
takes_options = LDAPUpdate.takes_options + (
|
||||
DeprecatedParam('ipanttrusteddomainsid?'),
|
||||
DeprecatedParam('ipanttrusteddomainname?'),
|
||||
Str(
|
||||
'ipanttrusteddomainsid?',
|
||||
deprecated=True,
|
||||
cli_name='dom_sid',
|
||||
flags=('no_update', 'no_option'),
|
||||
label=_('Domain SID of the trusted domain'),
|
||||
autofill=False,
|
||||
),
|
||||
Str(
|
||||
'ipanttrusteddomainname?',
|
||||
deprecated=True,
|
||||
cli_name='dom_name',
|
||||
flags=('no_search', 'virtual_attribute', 'no_update', 'no_option'),
|
||||
label=_('Name of the trusted domain'),
|
||||
autofill=False,
|
||||
),
|
||||
)
|
||||
|
||||
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
||||
|
@@ -23,7 +23,7 @@ from copy import deepcopy
|
||||
import six
|
||||
|
||||
from ipalib import api, errors
|
||||
from ipalib import DeprecatedParam
|
||||
from ipalib import Bool
|
||||
from ipalib.plugable import Registry
|
||||
from .baseldap import (
|
||||
LDAPCreate,
|
||||
@@ -270,10 +270,12 @@ class stageuser_add(baseuser_add):
|
||||
has_output_params = baseuser_add.has_output_params + stageuser_output_params
|
||||
|
||||
takes_options = LDAPCreate.takes_options + (
|
||||
DeprecatedParam('from_delete?',
|
||||
Bool(
|
||||
'from_delete?',
|
||||
deprecated=True,
|
||||
doc=_('Create Stage user in from a delete user'),
|
||||
cli_name='from_delete',
|
||||
default=False,
|
||||
flags={'no_option'},
|
||||
),
|
||||
)
|
||||
|
||||
|
@@ -153,6 +153,7 @@ ipa_class_members = {
|
||||
'sortorder',
|
||||
'option_group',
|
||||
'no_convert',
|
||||
'deprecated',
|
||||
],
|
||||
'ipalib.parameters.Bool': [
|
||||
'truths',
|
||||
|
Reference in New Issue
Block a user