Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosalib/ova: template VMware HW and OS versions from image.yaml; enable UEFI #2762

Merged
merged 3 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/cosalib/ova.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -63,14 +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", scsi="VirtualSCSI",
network="VmxNet3"):
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
Expand All @@ -87,8 +91,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),
}
Expand Down
9 changes: 8 additions & 1 deletion src/image-default.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions src/vmware-template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<VirtualSystem ovf:id="image">
<Info>A virtual machine</Info>
<Name>{vsphere_image_name}</Name>
<OperatingSystemSection ovf:id="80" ovf:version="6" vmw:osType="{vsphere_os_type}">
<OperatingSystemSection ovf:id="100" vmw:osType="{vsphere_os_type}">
<Info>The kind of installed guest operating system</Info>
</OperatingSystemSection>
<VirtualHardwareSection ovf:transport="com.vmware.guestInfo">
Expand Down Expand Up @@ -56,7 +56,7 @@
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceSubType>{vsphere_scsi_controller_type}</rasd:ResourceSubType>
<rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
</Item>
<Item>
Expand All @@ -75,11 +75,13 @@
<rasd:Description>VmxNet3 ethernet adapter on "VM Network"</rasd:Description>
<rasd:ElementName>Network adapter 1</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:ResourceSubType>{vsphere_network_controller_type}</rasd:ResourceSubType>
<rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
<vmw:Config ovf:required="false" vmw:key="connectable.allowGuestControl" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="false"/>
</Item>
<vmw:Config ovf:required="false" vmw:key="bootOptions.efiSecureBootEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="efi"/>
</VirtualHardwareSection>
<ProductSection>
<Info>Information about the installed software</Info>
Expand Down