| 1 |
""" |
| 2 |
Arrange for all ContextService connections to be torn down unconditionally, |
| 3 |
required for reliable LRU tests. |
| 4 |
""" |
| 5 |
|
| 6 |
import ansible_mitogen.connection |
| 7 |
import ansible_mitogen.services |
| 8 |
|
| 9 |
from ansible.plugins.action import ActionBase |
| 10 |
|
| 11 |
|
| 12 |
class ActionModule(ActionBase): |
| 13 |
# Running this for every host is pointless. |
| 14 |
BYPASS_HOST_LOOP = True |
| 15 |
|
| 16 |
def run(self, tmp=None, task_vars=None): |
| 17 |
if not isinstance(self._connection, |
| 18 |
ansible_mitogen.connection.Connection): |
| 19 |
return { |
| 20 |
'skipped': True, |
| 21 |
} |
| 22 |
|
| 23 |
self._connection._connect() |
| 24 |
binding = self._connection.get_binding() |
| 25 |
return { |
| 26 |
'changed': True, |
| 27 |
'result': binding.get_service_context().call_service( |
| 28 |
service_name='ansible_mitogen.services.ContextService', |
| 29 |
method_name='shutdown_all', |
| 30 |
) |
| 31 |
} |