Skip to content

Commit 0c252cf

Browse files
bgilbertopenshift-merge-robot
authored andcommittedFeb 20, 2020
vmware: Fix References/File size for OVA disk
The file size issue in coreos/fedora-coreos-tracker#391 isn't actually about DiskSection/Disk/ovf:populatedSize; that property is only a hint. The problem is that References/File/ovf:size should be the size of the VMDK file in bytes, not its virtual capacity. Change References/File/ovf:size to match the VMDK file size. For simplicity, change DiskSection/Disk/ovf:populatedSize to match. Rename template variables to improve clarity.
1 parent 46d913b commit 0c252cf

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎src/cosalib/vmware.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def generate_ovf_parameters(self, vmdk, cpu=2,
7070
based on the qemu, vmdk, and info from the build metadata
7171
"""
7272
disk_info = image_info(vmdk)
73+
vmdk_size = os.stat(vmdk).st_size
7374
image = self.summary
7475
product = f'{self.meta["name"]} {self.summary}'
7576
vendor = self.meta['name']
@@ -86,8 +87,8 @@ def generate_ovf_parameters(self, vmdk, cpu=2,
8687
'vsphere_os_type': os_type,
8788
'vsphere_scsi_controller_type': scsi,
8889
'vsphere_network_controller_type': network,
89-
'virtual_disk_size': disk_info.get("virtual-size"),
90-
'vmdk_size': disk_info.get("actual-size"),
90+
'vmdk_capacity': disk_info.get("virtual-size"),
91+
'vmdk_size': str(vmdk_size),
9192
}
9293

9394
return params

‎src/vmware-template.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0"?>
22
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" vmw:buildId="build-880146">
33
<References>
4-
<File ovf:href="disk.vmdk" ovf:id="file1" ovf:size="{virtual_disk_size}"/>
4+
<File ovf:href="disk.vmdk" ovf:id="file1" ovf:size="{vmdk_size}"/>
55
</References>
66
<DiskSection>
77
<Info>Virtual disk information</Info>
8-
<Disk ovf:capacity="{virtual_disk_size}" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="{vmdk_size}"/>
8+
<Disk ovf:capacity="{vmdk_capacity}" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="{vmdk_size}"/>
99
</DiskSection>
1010
<NetworkSection>
1111
<Info>The list of logical networks</Info>

0 commit comments

Comments
 (0)