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.
This commit is contained in:
Joshua Boniface 2020-01-20 21:12:33 -05:00
parent b615a27e98
commit 650ed972a1
1 changed files with 2 additions and 1 deletions

View File

@ -996,7 +996,8 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True):
vm_data['networks'] = db_cur.fetchall() vm_data['networks'] = db_cur.fetchall()
# Get the storage volumes # 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'],) args = (profile_data['storage_template'],)
db_cur.execute(query, args) db_cur.execute(query, args)
vm_data['volumes'] = db_cur.fetchall() vm_data['volumes'] = db_cur.fetchall()