Skip to content

Commit

Permalink
vmware_export_ovf: add export with extra config support (#1161)
Browse files Browse the repository at this point in the history
vmware_export_ovf: add export with extra config support

Signed-off-by: dianew [email protected]
SUMMARY

There is known issue of if there is no extra config in ovf, then when template imported to Fusion, it may encounter GOS can not boot up issue.
So add a new parameter export_with_extraconfig in this module to contain VM extra config options in ovf file when exporting to template.

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

vmware_export_ovf
ADDITIONAL INFORMATION

Reviewed-by: Mario Lenz <[email protected]>
Reviewed-by: None <None>
  • Loading branch information
Tomorrow9 authored Dec 29, 2021
1 parent 2595bdb commit 801361b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/vmware_export_ovf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- vmware_export_ovf - Add a new parameter 'export_with_extraconfig' to support export extra config options in ovf (https://github.com/ansible-collections/community.vmware/pull/1161).
13 changes: 12 additions & 1 deletion plugins/modules/vmware_export_ovf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
description:
- Export an ISO image of the media mounted on the CD/DVD Drive within the virtual machine.
type: bool
export_with_extraconfig:
type: bool
default: false
description:
- All extra configuration options are exported for a virtual machine.
version_added: '2.0.0'
download_timeout:
description:
- The user defined timeout in second of exporting file.
Expand Down Expand Up @@ -209,7 +215,7 @@ def download_device_files(self, headers, temp_target_disk, device_url, lease_upd
def export_to_ovf_files(self, vm_obj):
self.create_export_dir(vm_obj=vm_obj)
export_with_iso = False
if 'export_with_images' in self.params and self.params['export_with_images']:
if self.params['export_with_images']:
export_with_iso = True
self.download_timeout = self.params['download_timeout']

Expand Down Expand Up @@ -284,6 +290,10 @@ def export_to_ovf_files(self, vm_obj):
ovf_parameters = vim.OvfManager.CreateDescriptorParams()
ovf_parameters.name = ovf_descriptor_name
ovf_parameters.ovfFiles = ovf_files
if self.params['export_with_extraconfig']:
ovf_parameters.exportOption = ['extraconfig']
if self.params['export_with_images']:
ovf_parameters.includeImageFiles = True
vm_descriptor_result = ovf_manager.CreateDescriptor(obj=vm_obj, cdp=ovf_parameters)
if vm_descriptor_result.error:
http_nfc_lease.HttpNfcLeaseAbort()
Expand Down Expand Up @@ -325,6 +335,7 @@ def main():
datacenter=dict(type='str', default='ha-datacenter'),
export_dir=dict(type='path', required=True),
export_with_images=dict(type='bool', default=False),
export_with_extraconfig=dict(type='bool', default=False),
download_timeout=dict(type='int', default=30),
)

Expand Down

0 comments on commit 801361b

Please sign in to comment.