Merge pull request #56383 from Tomorrow9/fix_pr56296

VMware: add timezone and hwclockUTC customize parameters for Linux guest in vmware_guest
This commit is contained in:
Diane Wang 2019-05-14 11:11:52 -07:00 committed by Gonéri Le Bouder
parent 4a2fa46429
commit 0d2a120454

View file

@ -318,6 +318,11 @@ options:
- ' - C(domain) (string): DNS domain name to use.' - ' - C(domain) (string): DNS domain name to use.'
- ' - C(hostname) (string): Computer hostname (default: shorted C(name) parameter). Allowed characters are alphanumeric (uppercase and lowercase) - ' - C(hostname) (string): Computer hostname (default: shorted C(name) parameter). Allowed characters are alphanumeric (uppercase and lowercase)
and minus, rest of the characters are dropped as per RFC 952.' and minus, rest of the characters are dropped as per RFC 952.'
- 'Parameters related to Linux customization:'
- ' - C(timezone) (string): Timezone (See List of supported time zones for different vSphere versions in Linux/Unix
systems (2145518) U(https://kb.vmware.com/s/article/2145518)). version_added: 2.9'
- ' - C(hwclockUTC) (bool): Specifies whether the hardware clock is in UTC or local time.
True when the hardware clock is in UTC, False when the hardware clock is in local time. version_added: 2.9'
- 'Parameters related to Windows customization:' - 'Parameters related to Windows customization:'
- ' - C(autologon) (bool): Auto logon after virtual machine customization (default: False).' - ' - C(autologon) (bool): Auto logon after virtual machine customization (default: False).'
- ' - C(autologoncount) (int): Number of autologon after reboot (default: 1).' - ' - C(autologoncount) (int): Number of autologon after reboot (default: 1).'
@ -1650,6 +1655,13 @@ class PyVmomiHelper(PyVmomi):
valid_hostname = re.sub(r"[^a-zA-Z0-9\-]", "", hostname) valid_hostname = re.sub(r"[^a-zA-Z0-9\-]", "", hostname)
ident.hostName.name = valid_hostname ident.hostName.name = valid_hostname
# List of supported time zones for different vSphere versions in Linux/Unix systems
# https://kb.vmware.com/s/article/2145518
if 'timezone' in self.params['customization']:
ident.timeZone = str(self.params['customization']['timezone'])
if 'hwclockUTC' in self.params['customization']:
ident.hwClockUTC = self.params['customization']['hwclockUTC']
self.customspec = vim.vm.customization.Specification() self.customspec = vim.vm.customization.Specification()
self.customspec.nicSettingMap = adaptermaps self.customspec.nicSettingMap = adaptermaps
self.customspec.globalIPSettings = globalip self.customspec.globalIPSettings = globalip