From 650ed972a1443b3a7e127fe1e48f2f3e2680ee98 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 20 Jan 2020 21:12:33 -0500 Subject: [PATCH] Use disk_id ordering for storage volumes Prevents a bug if a disk is removed/readded and the database ID order does not match the sdX/vdX order. --- client-api/api_lib/pvcapi_provisioner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client-api/api_lib/pvcapi_provisioner.py b/client-api/api_lib/pvcapi_provisioner.py index 85ef3ec5..bb4bcc57 100755 --- a/client-api/api_lib/pvcapi_provisioner.py +++ b/client-api/api_lib/pvcapi_provisioner.py @@ -996,7 +996,8 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True): vm_data['networks'] = db_cur.fetchall() # Get the storage volumes - query = 'SELECT * FROM storage WHERE storage_template = %s' + # ORDER BY ensures disks are always in the sdX/vdX order, regardless of add order + query = 'SELECT * FROM storage WHERE storage_template = %s ORDER BY disk_id' args = (profile_data['storage_template'],) db_cur.execute(query, args) vm_data['volumes'] = db_cur.fetchall()