Skip to content

Commit

Permalink
VMware: Fix python 3 incompatibility (ansible#54123)
Browse files Browse the repository at this point in the history
Add Python2 and Python3 compatible `string.translate` for hostname customzation.

Fixes: ansible#54118
  • Loading branch information
Klaus Frank authored and Akasurde committed May 27, 2019
1 parent d7f4f88 commit 8f89d1d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ansible/modules/cloud/vmware/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,8 @@ 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()
# computer name will be truncated to 15 characters if using VM name
default_name = self.params['name'].translate(None, string.punctuation)
default_name = self.params['name'].replace(' ', '')
default_name = ''.join([c for c in default_name if c not in 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

0 comments on commit 8f89d1d

Please sign in to comment.