mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 12:33:59 -07:00
update code to python3 (#10903)
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
* update code to python3 * add changelog frag * rollback adjustment for plugins/lookup/lmdb_kv.py * accept PR suggestion for plugins/module_utils/utm_utils.py * accept PR suggestion for plugins/module_utils/vexata.py * Apply suggestions from code review * Update changelogs/fragments/10903-2to3.yml * Update changelogs/fragments/10903-2to3.yml
This commit is contained in:
parent
056633efaa
commit
07cfd6c4b4
8 changed files with 18 additions and 24 deletions
8
changelogs/fragments/10903-2to3.yml
Normal file
8
changelogs/fragments/10903-2to3.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
minor_changes:
|
||||||
|
- pickle cache plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- counter_enabled callback plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- wsl connection plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- cobbler inventory plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- linode inventory plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- utm_utils module_utils plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
||||||
|
- vexata module_utils plugin - use Python 3 idioms (https://github.com/ansible-collections/community.general/pull/10903).
|
5
plugins/cache/pickle.py
vendored
5
plugins/cache/pickle.py
vendored
|
@ -42,10 +42,7 @@ options:
|
||||||
type: float
|
type: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
import pickle
|
||||||
import cPickle as pickle
|
|
||||||
except ImportError:
|
|
||||||
import pickle
|
|
||||||
|
|
||||||
from ansible.plugins.cache import BaseFileCacheModule
|
from ansible.plugins.cache import BaseFileCacheModule
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CallbackModule(CallbackBase):
|
||||||
def v2_playbook_on_play_start(self, play):
|
def v2_playbook_on_play_start(self, play):
|
||||||
name = play.get_name().strip()
|
name = play.get_name().strip()
|
||||||
if not name:
|
if not name:
|
||||||
msg = u"play"
|
msg = "play"
|
||||||
else:
|
else:
|
||||||
msg = f"PLAY [{name}]"
|
msg = f"PLAY [{name}]"
|
||||||
|
|
||||||
|
|
|
@ -525,9 +525,9 @@ class Connection(ConnectionBase):
|
||||||
raise AnsibleAuthenticationFailure(msg)
|
raise AnsibleAuthenticationFailure(msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = to_text(e)
|
msg = to_text(e)
|
||||||
if u'PID check failed' in msg:
|
if 'PID check failed' in msg:
|
||||||
raise AnsibleError('paramiko version issue, please upgrade paramiko on the machine running ansible')
|
raise AnsibleError('paramiko version issue, please upgrade paramiko on the machine running ansible')
|
||||||
elif u'Private key file is encrypted' in msg:
|
elif 'Private key file is encrypted' in msg:
|
||||||
msg = (
|
msg = (
|
||||||
f'ssh {self.get_option("remote_user")}@{self.get_options("remote_addr")}:{port} : '
|
f'ssh {self.get_option("remote_user")}@{self.get_options("remote_addr")}:{port} : '
|
||||||
f'{msg}\nTo connect as a different user, use -u <username>.'
|
f'{msg}\nTo connect as a different user, use -u <username>.'
|
||||||
|
|
|
@ -139,14 +139,10 @@ from ansible_collections.community.general.plugins.plugin_utils.unsafe import ma
|
||||||
|
|
||||||
# xmlrpc
|
# xmlrpc
|
||||||
try:
|
try:
|
||||||
import xmlrpclib as xmlrpc_client
|
import xmlrpc.client as xmlrpc_client
|
||||||
HAS_XMLRPC_CLIENT = True
|
HAS_XMLRPC_CLIENT = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
HAS_XMLRPC_CLIENT = False
|
||||||
import xmlrpc.client as xmlrpc_client
|
|
||||||
HAS_XMLRPC_CLIENT = True
|
|
||||||
except ImportError:
|
|
||||||
HAS_XMLRPC_CLIENT = False
|
|
||||||
|
|
||||||
|
|
||||||
class TimeoutTransport (xmlrpc_client.SafeTransport):
|
class TimeoutTransport (xmlrpc_client.SafeTransport):
|
||||||
|
|
|
@ -167,13 +167,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
|
|
||||||
def _add_groups(self):
|
def _add_groups(self):
|
||||||
"""Add Linode instance groups to the dynamic inventory."""
|
"""Add Linode instance groups to the dynamic inventory."""
|
||||||
self.linode_groups = set(
|
self.linode_groups = {instance.group for instance in self.instances if instance.group}
|
||||||
filter(None, [
|
|
||||||
instance.group
|
|
||||||
for instance
|
|
||||||
in self.instances
|
|
||||||
])
|
|
||||||
)
|
|
||||||
|
|
||||||
for linode_group in self.linode_groups:
|
for linode_group in self.linode_groups:
|
||||||
self.inventory.add_group(linode_group)
|
self.inventory.add_group(linode_group)
|
||||||
|
|
|
@ -183,7 +183,7 @@ class UTM:
|
||||||
result = None
|
result = None
|
||||||
if response is not None:
|
if response is not None:
|
||||||
results = json.loads(response.read())
|
results = json.loads(response.read())
|
||||||
result = next(iter([d for d in results if d['name'] == module.params.get('name')]), None)
|
result = next((d for d in results if d['name'] == module.params.get('name')), None)
|
||||||
return info, result
|
return info, result
|
||||||
|
|
||||||
def _clean_result(self, result):
|
def _clean_result(self, result):
|
||||||
|
|
|
@ -20,10 +20,9 @@ VXOS_VERSION = None
|
||||||
def get_version(iocs_json):
|
def get_version(iocs_json):
|
||||||
if not iocs_json:
|
if not iocs_json:
|
||||||
raise Exception('Invalid IOC json')
|
raise Exception('Invalid IOC json')
|
||||||
active = [x for x in iocs_json if x['mgmtRole']]
|
active = next((x for x in iocs_json if x['mgmtRole']), None)
|
||||||
if not active:
|
if active is None:
|
||||||
raise Exception('Unable to detect active IOC')
|
raise Exception('Unable to detect active IOC')
|
||||||
active = active[0]
|
|
||||||
ver = active['swVersion']
|
ver = active['swVersion']
|
||||||
if ver[0] != 'v':
|
if ver[0] != 'v':
|
||||||
raise Exception('Illegal version string')
|
raise Exception('Illegal version string')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue