Use correct esxi host variable in vmware_cfg_backup (#38721)

Fixed bug where hostname could not be found and minor documentation changes.
pull/38719/merge
Andreas Nafpliotis 7 years ago committed by Abhijeet Kasurde
parent 88662d0c56
commit 8f5320435f

@ -31,7 +31,7 @@ requirements:
options: options:
esxi_hostname: esxi_hostname:
description: description:
- Name of ESXi server. - Name of ESXi server. This is required only if authentication against a vCenter is done.
required: False required: False
dest: dest:
description: description:
@ -51,17 +51,17 @@ extends_documentation_fragment: vmware.documentation
''' '''
EXAMPLES = ''' EXAMPLES = '''
# save the ESXi configuration locally # save the ESXi configuration locally by authenticating directly against the ESXi host
- name: ESXI backup test - name: ESXI backup test
local_action: local_action:
module: vmware_cfg_backup module: vmware_cfg_backup
hostname: esxi_host hostname: esxi_hostname
username: user username: user
password: pass password: pass
state: saved state: saved
dest: /tmp/ dest: /tmp/
# save the ESXi configuration locally for specific ESXi # save the ESXi configuration locally by authenticating against the vCenter and selecting the ESXi host
- name: ESXI backup test - name: ESXI backup test
local_action: local_action:
module: vmware_cfg_backup module: vmware_cfg_backup
@ -133,7 +133,7 @@ class VMwareConfigurationBackup(PyVmomi):
self.module.fail_json(msg="Source file {} does not exist".format(self.src)) self.module.fail_json(msg="Source file {} does not exist".format(self.src))
url = self.host.configManager.firmwareSystem.QueryFirmwareConfigUploadURL() url = self.host.configManager.firmwareSystem.QueryFirmwareConfigUploadURL()
url = url.replace('*', self.hostname) url = url.replace('*', self.host.name)
# find manually the url if there is a redirect because urllib2 -per RFC- doesn't do automatic redirects for PUT requests # find manually the url if there is a redirect because urllib2 -per RFC- doesn't do automatic redirects for PUT requests
try: try:
request = open_url(url=url, method='HEAD', validate_certs=self.validate_certs) request = open_url(url=url, method='HEAD', validate_certs=self.validate_certs)
@ -169,7 +169,7 @@ class VMwareConfigurationBackup(PyVmomi):
def save_configuration(self): def save_configuration(self):
url = self.host.configManager.firmwareSystem.BackupFirmwareConfiguration() url = self.host.configManager.firmwareSystem.BackupFirmwareConfiguration()
url = url.replace('*', self.hostname) url = url.replace('*', self.host.name)
if os.path.isdir(self.dest): if os.path.isdir(self.dest):
filename = url.rsplit('/', 1)[1] filename = url.rsplit('/', 1)[1]
self.dest = os.path.join(self.dest, filename) self.dest = os.path.join(self.dest, filename)

Loading…
Cancel
Save