mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: Fix python 3 incompatibility (#54123)
Add Python2 and Python3 compatible `string.translate` for hostname customzation. Fixes: #54118
This commit is contained in:
parent
d7f4f886f8
commit
8f89d1d3da
1 changed files with 2 additions and 1 deletions
|
@ -1593,7 +1593,8 @@ class PyVmomiHelper(PyVmomi):
|
||||||
# Setting hostName, orgName and fullName is mandatory, so we set some default when missing
|
# Setting hostName, orgName and fullName is mandatory, so we set some default when missing
|
||||||
ident.userData.computerName = vim.vm.customization.FixedName()
|
ident.userData.computerName = vim.vm.customization.FixedName()
|
||||||
# computer name will be truncated to 15 characters if using VM name
|
# 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.computerName.name = str(self.params['customization'].get('hostname', default_name[0:15]))
|
||||||
ident.userData.fullName = str(self.params['customization'].get('fullname', 'Administrator'))
|
ident.userData.fullName = str(self.params['customization'].get('fullname', 'Administrator'))
|
||||||
ident.userData.orgName = str(self.params['customization'].get('orgname', 'ACME'))
|
ident.userData.orgName = str(self.params['customization'].get('orgname', 'ACME'))
|
||||||
|
|
Loading…
Reference in a new issue