From eb878a46b667cc30c3c8a810d51f0f4044fc7837 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 17 Mar 2022 00:55:37 -0400 Subject: [PATCH 1/3] cosalib/ova: stop templating SCSI and network adapters We don't use this for anything, and other values are not likely to be drop-in replacements. --- src/cosalib/ova.py | 5 +---- src/vmware-template.xml | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cosalib/ova.py b/src/cosalib/ova.py index 2ec82b48ba..38c0a54fac 100644 --- a/src/cosalib/ova.py +++ b/src/cosalib/ova.py @@ -65,8 +65,7 @@ def __init__(self, **kwargs): def generate_ovf_parameters(self, vmdk, cpu=2, memory=4096, system_type="vmx-13", - os_type="rhel7_64Guest", scsi="VirtualSCSI", - network="VmxNet3"): + os_type="rhel7_64Guest"): """ Returns a dictionary with the parameters needed to create an OVF file based on the qemu, vmdk, and info from the build metadata @@ -87,8 +86,6 @@ def generate_ovf_parameters(self, vmdk, cpu=2, 'vsphere_product_version': version, 'vsphere_virtual_system_type': system_type, 'vsphere_os_type': os_type, - 'vsphere_scsi_controller_type': scsi, - 'vsphere_network_controller_type': network, 'vmdk_capacity': disk_info.get("virtual-size"), 'vmdk_size': str(vmdk_size), } diff --git a/src/vmware-template.xml b/src/vmware-template.xml index 70d66bdff3..d36ae0e07b 100644 --- a/src/vmware-template.xml +++ b/src/vmware-template.xml @@ -56,7 +56,7 @@ SCSI Controller SCSI Controller 0 3 - {vsphere_scsi_controller_type} + VirtualSCSI 6 @@ -75,7 +75,7 @@ VmxNet3 ethernet adapter on "VM Network" Network adapter 1 5 - {vsphere_network_controller_type} + VmxNet3 10 From 5d9f834218e224ccc031e1cbe6c7ede6018ad7d4 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 17 Mar 2022 01:52:58 -0400 Subject: [PATCH 2/3] cosalib/ova: template VMware HW and OS versions from image.yaml FCOS and RHCOS want to set different VMware hardware versions and OS type IDs. Read both from image.yaml, defaulting to the values we currently use. OVF images created by VMware Workstation 16.2.3 respectively record Fedora and RHEL 8 guests as: The ovf:id values are defined to come from CIM_OperatingSystem.OsType, which defines 80 as "RedHat Enterprise Linux 64-Bit" and 100 as "Linux 2.6.x 64-Bit". (2.6.x seems to be the last explicit kernel version listed in the spec.) ovf:version appears to be the major version of the OS. VMware's ovftool doesn't seem to care about either of those fields, only the vmw:osType, so we hardcode the ovf:id to 100 and call it a day. --- src/cosalib/ova.py | 15 ++++++++++----- src/image-default.yaml | 9 ++++++++- src/vmware-template.xml | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/cosalib/ova.py b/src/cosalib/ova.py index 38c0a54fac..ec9645127d 100644 --- a/src/cosalib/ova.py +++ b/src/cosalib/ova.py @@ -10,7 +10,7 @@ sys.path.insert(0, f"{cosa_dir}/cosalib") sys.path.insert(0, cosa_dir) -from cosalib.cmdlib import image_info +from cosalib.cmdlib import flatten_image_yaml, image_info from cosalib.qemuvariants import QemuVariantImage @@ -63,13 +63,18 @@ def __init__(self, **kwargs): # Ensure that coreos.ovf is included in the tar self.ovf_path = os.path.join(self._tmpdir, "coreos.ovf") - def generate_ovf_parameters(self, vmdk, cpu=2, - memory=4096, system_type="vmx-13", - os_type="rhel7_64Guest"): + def generate_ovf_parameters(self, vmdk, cpu=2, memory=4096): """ Returns a dictionary with the parameters needed to create an OVF file - based on the qemu, vmdk, and info from the build metadata + based on the qemu, vmdk, image.yaml, and info from the build metadata """ + image_yaml = flatten_image_yaml( + '/usr/lib/coreos-assembler/image-default.yaml', + flatten_image_yaml('src/config/image.yaml') + ) + + system_type = 'vmx-{}'.format(image_yaml['vmware-hw-version']) + os_type = image_yaml['vmware-os-type'] disk_info = image_info(vmdk) vmdk_size = os.stat(vmdk).st_size image = self.summary diff --git a/src/image-default.yaml b/src/image-default.yaml index c03e27dce2..a725a9a5fb 100644 --- a/src/image-default.yaml +++ b/src/image-default.yaml @@ -1,8 +1,15 @@ -# This file contains defaults for image.yaml that is used by create_disk.sh +# This file contains defaults for image.yaml + bootfs: "ext4" rootfs: "xfs" grub-script: "/usr/lib/coreos-assembler/grub.cfg" + # True if we should use `ostree container image deploy` deploy-via-container: false + # Set this to a target container reference, e.g. ostree-unverified-registry:quay.io/example/os:latest # container-imgref: "" + +# Defaults for VMware OVA, matching historical behavior +vmware-hw-version: 13 +vmware-os-type: rhel7_64Guest diff --git a/src/vmware-template.xml b/src/vmware-template.xml index d36ae0e07b..22d11b4039 100644 --- a/src/vmware-template.xml +++ b/src/vmware-template.xml @@ -16,7 +16,7 @@ A virtual machine {vsphere_image_name} - + The kind of installed guest operating system From 9e1150f6e59c053f78aeec34d45379349ef61615 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 17 Mar 2022 01:56:31 -0400 Subject: [PATCH 3/3] cosalib/ova: enable UEFI in VMware OVA Disable Secure Boot due to https://github.com/coreos/ignition/issues/1092. Co-authored-by: Joseph Callen --- src/vmware-template.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vmware-template.xml b/src/vmware-template.xml index 22d11b4039..5946940981 100644 --- a/src/vmware-template.xml +++ b/src/vmware-template.xml @@ -80,6 +80,8 @@ + + Information about the installed software