-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Fix Unicode-objects must be encoded before hashing #46608
Conversation
this LGTM shipit |
@nitzmahone I met same error when trying azure_rm plugin, could you pls help to review the PR? thanks. |
bot_status |
@nitzmahone Could you pls help to review the change? thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
@@ -450,7 +450,7 @@ def __init__(self, vm_model, inventory_client, vmss=None): | |||
self.nics = [] | |||
|
|||
# Azure often doesn't provide a globally-unique filename, so use resource name + a chunk of ID hash | |||
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(vm_model['id']).hexdigest()[0:4]) | |||
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about multylining it for readability?
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4]) | |
self.default_inventory_hostname = ( | |
'_'.join(( | |
vm_model['name'], | |
hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4], | |
)) | |
) |
@@ -450,7 +450,7 @@ def __init__(self, vm_model, inventory_client, vmss=None): | |||
self.nics = [] | |||
|
|||
# Azure often doesn't provide a globally-unique filename, so use resource name + a chunk of ID hash | |||
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(vm_model['id']).hexdigest()[0:4]) | |||
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe
self.default_inventory_hostname = '{0}_{1}'.format(vm_model['name'], hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4]) | |
self.default_inventory_hostname = '_'.join(( | |
vm_model['name'], | |
hashlib.sha1(to_bytes(vm_model['id'])).hexdigest()[0:4], | |
)) |
Plugin is broken now, I have the same error. Would be nice to have a fix ASAP. Thanks! |
@daixijun can you close and open the PR to re-run the CI? |
Thanks. Working now! How long do things like this usually take to make it back into stable? |
@nitzmahone I'd really like to see this in stable-2.7,and maybe a new 2.7-release until 2.8 is fully availble on pypi. Is this, by any chance possible or planned? |
@f3rdy I think it should be ok if you send a backport PR |
@f3rdy Will You send a PR for 2.7? |
Done. |
SUMMARY
with azure_rm plugin: Unicode-objects must be encoded before hashing
ISSUE TYPE
COMPONENT NAME
inventory plugin
azure_rm
ANSIBLE VERSION
ADDITIONAL INFORMATION