mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-16 01:45:25 -07:00
Use a decorator to ensure jit connection, instead of an explicit call to _connect
This commit is contained in:
parent
f7839dee11
commit
9754c67138
5 changed files with 27 additions and 6 deletions
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
|||
|
||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
|
||||
from functools import wraps
|
||||
from six import with_metaclass
|
||||
|
||||
from ansible import constants as C
|
||||
|
@ -32,7 +33,16 @@ from ansible.errors import AnsibleError
|
|||
# which may want to output display/logs too
|
||||
from ansible.utils.display import Display
|
||||
|
||||
__all__ = ['ConnectionBase']
|
||||
__all__ = ['ConnectionBase', 'ensure_connect']
|
||||
|
||||
|
||||
def ensure_connect(func):
|
||||
@wraps(func)
|
||||
def wrapped(self, *args, **kwargs):
|
||||
self._connect()
|
||||
return func(self, *args, **kwargs)
|
||||
return wrapped
|
||||
|
||||
|
||||
class ConnectionBase(with_metaclass(ABCMeta, object)):
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue