Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode json payload to UTF-8 in send_facts() #46

Merged
merged 1 commit into from
Sep 8, 2016
Merged

Encode json payload to UTF-8 in send_facts() #46

merged 1 commit into from
Sep 8, 2016

Conversation

karras
Copy link
Contributor

@karras karras commented Sep 7, 2016

I've encountered the following error when using the Ansible callback plugin to upload facts:

[WARNING]: Failure when attempting to use callback plugin (</home/foobar/.ansible/plugins/callback_plugins/foreman_callback.CallbackModule object at 0x7f32cd4c96d0>): buf must be a byte string

The environment variables are configured as follows:

FOREMAN_URL=https://foreman.example.com
FOREMAN_SSL_CERT=foreman_client.crt
FOREMAN_SSL_KEY=foreman_client.key
FOREMAN_SSL_VERIFY=False

Encoding the JSON payload to UTF-8 fixed the issue and I was able to upload facts to Foreman. Maybe this has to be fixed on line 161 as well.

The PR definitely needs to be reviewed because I didn't had time to thoroughly test it.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 1e31522 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 1e31522 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@agx
Copy link
Member

agx commented Sep 8, 2016

On Wed, Sep 07, 2016 at 12:53:00PM -0700, Michael Hofer wrote:

I've encountered the following error when using the Ansible callback plugin to upload facts:

[WARNING]: Failure when attempting to use callback plugin (</home/foobar/.ansible/plugins/callback_plugins/foreman_callback.CallbackModule object at 0x7f32cd4c96d0>): buf must be a byte string

Your /usb/bin/python is a Python3? The change is harmless in python2.7
to add.

@karras
Copy link
Contributor Author

karras commented Sep 8, 2016

I've tested it on a Jessie running Python 2.7.9:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.4 (jessie)
Release:    8.4
Codename:   jessie
$ /usr/bin/python --version
Python 2.7.9

Running Foreman 1.12.1 and Foreman Ansible Plugin 1.0.

@agx
Copy link
Member

agx commented Sep 8, 2016

On Wed, Sep 07, 2016 at 10:30:47PM -0700, Michael Hofer wrote:

I've tested it on a Jessie running Python 2.7.9:

$ lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:  Debian GNU/Linux 8.4 (jessie)
Release:  8.4
Codename: jessie
$ /usr/bin/python --version
Python 2.7.9

That's odd since I'm using the same version but maybe my facts are all
ascii. Anyways, looks goot to me!

@dLobatog
Copy link
Member

dLobatog commented Sep 8, 2016

[test]

@dLobatog
Copy link
Member

dLobatog commented Sep 8, 2016

Ready to merge if Jenkins tests pass

@dLobatog dLobatog merged commit 46e8164 into theforeman:master Sep 8, 2016
@dLobatog
Copy link
Member

dLobatog commented Sep 8, 2016

Merged, thanks @karras and @agx ! I've modified the commit to include a - between the issue number and the message so that Redmine automatically detects it

agx pushed a commit to agx/foreman_ansible that referenced this pull request Jul 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants