fix for #12 - panos_admpwd hangs with python3 #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
panos_admpwd hangs or crashes when using with python3
Description
underlying paramiko library returns bytes instead of str when used in python3 vs python2. The panos_admpwd expects only str to be returned. This patch uses the Ansible recommended to_text function to switch handle bytes vs str return data as documented here:
https://docs.ansible.com/ansible/latest/dev_guide/developing_python_3.html#unicode-sandwich-common-borders-places-to-convert-bytes-to-text-in-controller-code
Motivation and Context
Launching instances in AWS when using python3 should work as expected.
Fixes issue #12
Launching with ansible-playbook -vvv eventually shows the following stack trace:
How Has This Been Tested?
tested with both python3 and python2 environments on panorama instances launched in AWS.
Screenshots (if appropriate)
Types of changes
Introduce a new library into the panos_admpwd module:
from ansible.module_utils._text import to_text
Then wraps the call to
shell.recv(_PROMPTBUFF)
withto_text(shell.recv(_PROMPTBUFF))
Checklist