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

VMware: Fixes Python3 compatibility of vmware_guest #55043

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ansible/modules/cloud/vmware/vmware_guest.py
Expand Up @@ -1603,8 +1603,9 @@ def customize_vm(self, vm_obj):

# Setting hostName, orgName and fullName is mandatory, so we set some default when missing
ident.userData.computerName = vim.vm.customization.FixedName()
# Strips punctuation from string in a Python2 and Python3 compatible way
default_name = re.sub(r'[^\w\s]', '', self.params['name'])
# computer name will be truncated to 15 characters if using VM name
default_name = self.params['name'].translate(None, string.punctuation)
ident.userData.computerName.name = str(self.params['customization'].get('hostname', default_name[0:15]))
ident.userData.fullName = str(self.params['customization'].get('fullname', 'Administrator'))
ident.userData.orgName = str(self.params['customization'].get('orgname', 'ACME'))
Expand Down