mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-06 00:14:02 -07:00
Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423)
We couldn't copy to_unicode, to_bytes, to_str into module_utils because of licensing. So once created it we had two sets of functions that did the same things but had different implementations. To remedy that, this change removes the ansible.utils.unicode versions of those functions.
This commit is contained in:
parent
7a9395b5e0
commit
4ed88512e4
89 changed files with 759 additions and 894 deletions
|
@ -19,26 +19,24 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.unicode import to_unicode
|
||||
from ansible.errors import AnsibleUndefinedVariable
|
||||
|
||||
import socket
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
|
||||
class TimedOutException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
TRANSFERS_FILES = False
|
||||
|
||||
|
@ -50,7 +48,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
def do_until_success_or_timeout(self, what, timeout_sec, what_desc, fail_sleep_sec=1):
|
||||
max_end_time = datetime.utcnow() + timedelta(seconds=timeout_sec)
|
||||
|
||||
|
||||
while datetime.utcnow() < max_end_time:
|
||||
try:
|
||||
what()
|
||||
|
@ -82,7 +80,7 @@ class ActionModule(ActionBase):
|
|||
winrm_port = self._connection._winrm_port
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
|
||||
# initiate reboot
|
||||
(rc, stdout, stderr) = self._connection.exec_command("shutdown /r /t %d" % pre_reboot_delay_sec)
|
||||
|
||||
|
@ -92,7 +90,7 @@ class ActionModule(ActionBase):
|
|||
result['msg'] = "Shutdown command failed, error text was %s" % stderr
|
||||
return result
|
||||
|
||||
def raise_if_port_open():
|
||||
def raise_if_port_open():
|
||||
try:
|
||||
sock = socket.create_connection((winrm_host, winrm_port), connect_timeout_sec)
|
||||
sock.close()
|
||||
|
@ -137,4 +135,3 @@ class ActionModule(ActionBase):
|
|||
result['msg'] = toex.message
|
||||
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue