From 93c2fdec9388a7b3c591efb0ed48718ec5034a90 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 21 Jun 2021 21:59:57 -0400 Subject: [PATCH] Swap order of networks and disks in provisioner Done to make the resulting config match the expectations when using "vm network add", which is that networks are below disks, not above. Not a functional change, just ensures the VM XML is consistent after many changes. --- api-daemon/pvcapid/provisioner.py | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/api-daemon/pvcapid/provisioner.py b/api-daemon/pvcapid/provisioner.py index 00dc781d..88a0f69e 100755 --- a/api-daemon/pvcapid/provisioner.py +++ b/api-daemon/pvcapid/provisioner.py @@ -1323,6 +1323,30 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True, script_r vm_architecture=system_architecture ) + # Add disk devices + monitor_list = list() + coordinator_names = config['storage_hosts'] + for coordinator in coordinator_names: + monitor_list.append("{}.{}".format(coordinator, config['storage_domain'])) + + ceph_storage_secret = config['ceph_storage_secret_uuid'] + + for volume in vm_data['volumes']: + vm_schema += libvirt_schema.devices_disk_header.format( + ceph_storage_secret=ceph_storage_secret, + disk_pool=volume['pool'], + vm_name=vm_name, + disk_id=volume['disk_id'] + ) + for monitor in monitor_list: + vm_schema += libvirt_schema.devices_disk_coordinator.format( + coordinator_name=monitor, + coordinator_ceph_mon_port=config['ceph_monitor_port'] + ) + vm_schema += libvirt_schema.devices_disk_footer + + vm_schema += libvirt_schema.devices_vhostmd + # Add network devices network_id = 0 for network in vm_data['networks']: @@ -1364,30 +1388,6 @@ def create_vm(self, vm_name, vm_profile, define_vm=True, start_vm=True, script_r network_id += 1 - # Add disk devices - monitor_list = list() - coordinator_names = config['storage_hosts'] - for coordinator in coordinator_names: - monitor_list.append("{}.{}".format(coordinator, config['storage_domain'])) - - ceph_storage_secret = config['ceph_storage_secret_uuid'] - - for volume in vm_data['volumes']: - vm_schema += libvirt_schema.devices_disk_header.format( - ceph_storage_secret=ceph_storage_secret, - disk_pool=volume['pool'], - vm_name=vm_name, - disk_id=volume['disk_id'] - ) - for monitor in monitor_list: - vm_schema += libvirt_schema.devices_disk_coordinator.format( - coordinator_name=monitor, - coordinator_ceph_mon_port=config['ceph_monitor_port'] - ) - vm_schema += libvirt_schema.devices_disk_footer - - vm_schema += libvirt_schema.devices_vhostmd - # Add default devices vm_schema += libvirt_schema.devices_default