Revamp ordering and spacing of libvirt XML
This commit is contained in:
@ -781,7 +781,7 @@ def create_vm(self, vm_name, vm_profile):
|
||||
if not target_node:
|
||||
raise ClusterError("No ready cluster node contains at least {}+512 MB of free RAM".format(vm_data['system_details']['vram_mb']))
|
||||
|
||||
print("Selecting target node {} with {} MB free ram".format(target_node, last_free))
|
||||
print("Selecting target node {} with {} MB free RAM".format(target_node, last_free))
|
||||
|
||||
# Verify that all configured networks are present on the cluster
|
||||
cluster_networks, _discard = pvc_network.getClusterNetworkList(zk_conn)
|
||||
@ -1005,59 +1005,7 @@ def create_vm(self, vm_name, vm_profile):
|
||||
vm_memory=vm_data['system_details']['vram_mb'],
|
||||
vm_vcpus=vm_data['system_details']['vcpu_count'],
|
||||
vm_architecture=system_architecture
|
||||
).strip()
|
||||
|
||||
# Add default devices
|
||||
vm_schema += libvirt_schema.devices_default.strip()
|
||||
|
||||
# Add serial device
|
||||
if vm_data['system_details']['serial']:
|
||||
vm_schema += libvirt_schema.devices_serial.format(
|
||||
vm_name=vm_name
|
||||
).strip()
|
||||
|
||||
# Add VNC device
|
||||
if vm_data['system_details']['vnc']:
|
||||
if vm_data['system_details']['vnc_bind']:
|
||||
vm_vnc_bind = vm_data['system_details']['vnc_bind']
|
||||
else:
|
||||
vm_vnc_bind = "127.0.0.1"
|
||||
|
||||
vm_vncport = 5900
|
||||
vm_vnc_autoport = "yes"
|
||||
|
||||
vm_schema += libvirt_schema.devices_vnc.format(
|
||||
vm_vncport=vm_vncport,
|
||||
vm_vnc_autoport=vm_vnc_autoport,
|
||||
vm_vnc_bind=vm_vnc_bind
|
||||
).strip()
|
||||
|
||||
# Add SCSI controller
|
||||
vm_schema += libvirt_schema.devices_scsi_controller.strip()
|
||||
|
||||
# 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']
|
||||
).strip()
|
||||
for monitor in monitor_list:
|
||||
vm_schema += libvirt_schema.devices_disk_coordinator.format(
|
||||
coordinator_name=monitor,
|
||||
coordinator_ceph_mon_port=config['ceph_monitor_port']
|
||||
).strip()
|
||||
vm_schema += libvirt_schema.devices_disk_footer.strip()
|
||||
|
||||
vm_schema += libvirt_schema.devices_vhostmd.strip()
|
||||
)
|
||||
|
||||
# Add network devices
|
||||
network_id = 0
|
||||
@ -1093,11 +1041,64 @@ def create_vm(self, vm_name, vm_profile):
|
||||
vm_schema += libvirt_schema.devices_net_interface.format(
|
||||
eth_macaddr=eth_macaddr,
|
||||
eth_bridge=eth_bridge
|
||||
).strip()
|
||||
)
|
||||
|
||||
network_id += 1
|
||||
|
||||
vm_schema += libvirt_schema.libvirt_footer.strip()
|
||||
# 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
|
||||
|
||||
# Add serial device
|
||||
if vm_data['system_details']['serial']:
|
||||
vm_schema += libvirt_schema.devices_serial.format(
|
||||
vm_name=vm_name
|
||||
)
|
||||
|
||||
# Add VNC device
|
||||
if vm_data['system_details']['vnc']:
|
||||
if vm_data['system_details']['vnc_bind']:
|
||||
vm_vnc_bind = vm_data['system_details']['vnc_bind']
|
||||
else:
|
||||
vm_vnc_bind = "127.0.0.1"
|
||||
|
||||
vm_vncport = 5900
|
||||
vm_vnc_autoport = "yes"
|
||||
|
||||
vm_schema += libvirt_schema.devices_vnc.format(
|
||||
vm_vncport=vm_vncport,
|
||||
vm_vnc_autoport=vm_vnc_autoport,
|
||||
vm_vnc_bind=vm_vnc_bind
|
||||
)
|
||||
|
||||
# Add SCSI controller
|
||||
vm_schema += libvirt_schema.devices_scsi_controller
|
||||
|
||||
# Add footer
|
||||
vm_schema += libvirt_schema.libvirt_footer
|
||||
|
||||
print("Final VM schema:\n{}\n".format(vm_schema))
|
||||
|
||||
|
Reference in New Issue
Block a user