1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Deprecate module_utils.redhat (#6663)

This module contains bits that are either unused (the Rhsm* classes), or
used only by deprecated modules (the RegistrationBase class).
Considering that the bits here have not seen updates in years, it is
unlikely that anyone is actually using them as "library".

Hence, deprecate the whole module altogether:
- the Rhsm* classes, as not used by anything, are slated for removal in
  9.0.0
- the RegistrationBase class is slated for removal in 10.0.0, together
  with its only user (i.e. the rhn_register module)
This commit is contained in:
Pino Toscano 2023-06-10 13:26:14 +02:00 committed by GitHub
parent 011b2f8bdc
commit 78c42def04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 4 deletions

View file

@ -0,0 +1,11 @@
deprecated_features:
- |
redhat module utils - the ``module_utils.redhat`` module is deprecated, as
effectively unused: the ``Rhsm``, ``RhsmPool``, and ``RhsmPools`` classes
will be removed in community.general 9.0.0; the ``RegistrationBase`` class
will be removed in community.general 10.0.0 together with the
``rhn_register`` module, as it is the only user of this class; this means
that the whole ``module_utils.redhat`` module will be dropped in
community.general 10.0.0, so importing it without even using anything of it
will fail
(https://github.com/ansible-collections/community.general/pull/6663).

View file

@ -24,6 +24,14 @@ from ansible.module_utils.six.moves import configparser
class RegistrationBase(object): class RegistrationBase(object):
"""
DEPRECATION WARNING
This class is deprecated and will be removed in community.general 10.0.0.
There is no replacement for it; please contact the community.general
maintainers in case you are using it.
"""
def __init__(self, module, username=None, password=None): def __init__(self, module, username=None, password=None):
self.module = module self.module = module
self.username = username self.username = username
@ -71,10 +79,23 @@ class RegistrationBase(object):
class Rhsm(RegistrationBase): class Rhsm(RegistrationBase):
"""
DEPRECATION WARNING
This class is deprecated and will be removed in community.general 9.0.0.
There is no replacement for it; please contact the community.general
maintainers in case you are using it.
"""
def __init__(self, module, username=None, password=None): def __init__(self, module, username=None, password=None):
RegistrationBase.__init__(self, module, username, password) RegistrationBase.__init__(self, module, username, password)
self.config = self._read_config() self.config = self._read_config()
self.module = module self.module = module
self.module.deprecate(
'The Rhsm class is deprecated with no replacement.',
version='9.0.0',
collection_name='community.general',
)
def _read_config(self, rhsm_conf='/etc/rhsm/rhsm.conf'): def _read_config(self, rhsm_conf='/etc/rhsm/rhsm.conf'):
''' '''
@ -200,14 +221,25 @@ class Rhsm(RegistrationBase):
class RhsmPool(object): class RhsmPool(object):
''' """
Convenience class for housing subscription information Convenience class for housing subscription information
'''
DEPRECATION WARNING
This class is deprecated and will be removed in community.general 9.0.0.
There is no replacement for it; please contact the community.general
maintainers in case you are using it.
"""
def __init__(self, module, **kwargs): def __init__(self, module, **kwargs):
self.module = module self.module = module
for k, v in kwargs.items(): for k, v in kwargs.items():
setattr(self, k, v) setattr(self, k, v)
self.module.deprecate(
'The RhsmPool class is deprecated with no replacement.',
version='9.0.0',
collection_name='community.general',
)
def __str__(self): def __str__(self):
return str(self.__getattribute__('_name')) return str(self.__getattribute__('_name'))
@ -223,11 +255,23 @@ class RhsmPool(object):
class RhsmPools(object): class RhsmPools(object):
""" """
This class is used for manipulating pools subscriptions with RHSM This class is used for manipulating pools subscriptions with RHSM
DEPRECATION WARNING
This class is deprecated and will be removed in community.general 9.0.0.
There is no replacement for it; please contact the community.general
maintainers in case you are using it.
""" """
def __init__(self, module): def __init__(self, module):
self.module = module self.module = module
self.products = self._load_product_list() self.products = self._load_product_list()
self.module.deprecate(
'The RhsmPools class is deprecated with no replacement.',
version='9.0.0',
collection_name='community.general',
)
def __iter__(self): def __iter__(self):
return self.products.__iter__() return self.products.__iter__()