summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-06-02 15:58:43 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-03 09:00:34 +0200
commit3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36 (patch)
tree35d9b5235752fca82159e5e12d99d75225c15b3b /ipalib
parent0e989e2a28fb8093528176574ffd2ae2ecac4c14 (diff)
downloadfreeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.tar.gz
freeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.tar.xz
freeipa-3cf5f83d92a2c315eb8a0dd2ed06cd1d61df5d36.zip
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>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/__init__.py2
-rw-r--r--ipalib/parameters.py21
-rw-r--r--ipalib/plugins/dns.py8
-rw-r--r--ipalib/plugins/hbacrule.py23
-rw-r--r--ipalib/plugins/hbactest.py9
-rw-r--r--ipalib/plugins/idrange.py20
-rw-r--r--ipalib/plugins/stageuser.py8
7 files changed, 60 insertions, 31 deletions
diff --git a/ipalib/__init__.py b/ipalib/__init__.py
index a6768a843..030a4f7d2 100644
--- a/ipalib/__init__.py
+++ b/ipalib/__init__.py
@@ -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
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index ccbf6e349..196300295 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -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``.
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b67642270..9cca07c6d 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -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'),
diff --git a/ipalib/plugins/hbacrule.py b/ipalib/plugins/hbacrule.py
index e0301239f..7d3e4851a 100644
--- a/ipalib/plugins/hbacrule.py
+++ b/ipalib/plugins/hbacrule.py
@@ -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'],
diff --git a/ipalib/plugins/hbactest.py b/ipalib/plugins/hbactest.py
index 2dbab510e..90f3b561a 100644
--- a/ipalib/plugins/hbactest.py
+++ b/ipalib/plugins/hbactest.py
@@ -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'),
diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 7e868c363..ccd67995e 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -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):
diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
index d6533099e..86b1935f3 100644
--- a/ipalib/plugins/stageuser.py
+++ b/ipalib/plugins/stageuser.py
@@ -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'},
),
)