From 7020b27b0a42b9fb253de7b4ad5257196ef2fab8 Mon Sep 17 00:00:00 2001 From: Algirdas <76789112+Algirdas-Z@users.noreply.github.com> Date: Sun, 16 Jul 2023 11:58:30 +0300 Subject: [PATCH] cobbler inventory plugin: Convert unicode to str (#6923) * plugins/inventory/cobbler: Convert unicode to str * plugins/inventory/cobbler: Use text_type instead --- changelogs/fragments/6923-cobbler-inventory_unicode.yml | 2 ++ plugins/inventory/cobbler.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6923-cobbler-inventory_unicode.yml diff --git a/changelogs/fragments/6923-cobbler-inventory_unicode.yml b/changelogs/fragments/6923-cobbler-inventory_unicode.yml new file mode 100644 index 0000000000..ccd11985e0 --- /dev/null +++ b/changelogs/fragments/6923-cobbler-inventory_unicode.yml @@ -0,0 +1,2 @@ +minor_changes: + - cobbler inventory plugin - convert Ansible unicode strings to native Python unicode strings before passing user/password to XMLRPC client (https://github.com/ansible-collections/community.general/pull/6923). diff --git a/plugins/inventory/cobbler.py b/plugins/inventory/cobbler.py index 4e118d569d..6ab8606749 100644 --- a/plugins/inventory/cobbler.py +++ b/plugins/inventory/cobbler.py @@ -104,6 +104,7 @@ import socket from ansible.errors import AnsibleError from ansible.module_utils.common.text.converters import to_text from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, to_safe_group_name +from ansible.module_utils.six import text_type # xmlrpc try: @@ -145,7 +146,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable): self.connection = xmlrpc_client.Server(self.cobbler_url, allow_none=True) self.token = None if self.get_option('user') is not None: - self.token = self.connection.login(self.get_option('user'), self.get_option('password')) + self.token = self.connection.login(text_type(self.get_option('user')), text_type(self.get_option('password'))) return self.connection def _init_cache(self):