Don't convert bytes into KB in OVA import

Doing so can create an image that is 1 sector (512 bytes) too large,
which will then break qemu-img because it's stupid (or, VMDK is stupid,
I haven't decided which is).. Current Ceph rbd commands seem to accept
--size in bytes so this is fine.
This commit is contained in:
Joshua Boniface 2020-05-05 15:45:46 -04:00
parent 3e351bb84a
commit 34c4690d49
1 changed files with 4 additions and 9 deletions

View File

@ -177,12 +177,9 @@ def upload_ova(ova_data, pool, name, ova_size):
retflag, retdata = pvc_ceph.remove_volume(zk_conn, pool, "ova_{}".format(name)) retflag, retdata = pvc_ceph.remove_volume(zk_conn, pool, "ova_{}".format(name))
pvc_common.stopZKConnection(zk_conn) pvc_common.stopZKConnection(zk_conn)
# Normalize the OVA size to MB # Normalize the OVA size to bytes
# The function always return XXXXB, so strip off the B and convert to an integer
ova_size_bytes = int(pvc_ceph.format_bytes_fromhuman(ova_size)[:-1]) ova_size_bytes = int(pvc_ceph.format_bytes_fromhuman(ova_size)[:-1])
# Put the size into KB which rbd --size can understand ova_size = pvc_ceph.format_bytes_fromhuman(ova_size)
ova_size_kb = math.ceil(ova_size_bytes / 1024)
ova_size = "{}K".format(ova_size_kb)
# Verify that the cluster has enough space to store the OVA volumes (2x OVA size, temporarily, 1x permanently) # Verify that the cluster has enough space to store the OVA volumes (2x OVA size, temporarily, 1x permanently)
zk_conn = pvc_common.startZKConnection(config['coordinators']) zk_conn = pvc_common.startZKConnection(config['coordinators'])
@ -272,11 +269,9 @@ def upload_ova(ova_data, pool, name, ova_size):
dev_size_raw = ova_archive.getmember(dev_src).size dev_size_raw = ova_archive.getmember(dev_src).size
vm_volume_size = disk.get('capacity') vm_volume_size = disk.get('capacity')
# Normalize the dev size to KB # Normalize the dev size to bytes
# The function always return XXXXB, so strip off the B and convert to an integer
dev_size_bytes = int(pvc_ceph.format_bytes_fromhuman(dev_size_raw)[:-1]) dev_size_bytes = int(pvc_ceph.format_bytes_fromhuman(dev_size_raw)[:-1])
dev_size_kb = math.ceil(dev_size_bytes / 1024) dev_size = pvc_ceph.format_bytes_fromhuman(dev_size_raw)
dev_size = "{}K".format(dev_size_kb)
def cleanup_img_maps(): def cleanup_img_maps():
zk_conn = pvc_common.startZKConnection(config['coordinators']) zk_conn = pvc_common.startZKConnection(config['coordinators'])