mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
virt: use a list of disks for the domain template
Using a dict breaks the disk order which might be of importance to users. It only hides the disk name from the template rendering, but that one property wasn't used.
This commit is contained in:
parent
a75dcb3e9e
commit
99b453360f
@ -581,25 +581,27 @@ def _gen_xml(name,
|
||||
else:
|
||||
context['console'] = True
|
||||
|
||||
context['disks'] = {}
|
||||
context['disks'] = []
|
||||
disk_bus_map = {'virtio': 'vd', 'xen': 'xvd', 'fdc': 'fd', 'ide': 'hd'}
|
||||
for i, disk in enumerate(diskp):
|
||||
context['disks'][disk['name']] = {}
|
||||
context['disks'][disk['name']]['device'] = disk.get('device', 'disk')
|
||||
if 'source_file' and disk['source_file']:
|
||||
context['disks'][disk['name']]['source_file'] = disk['source_file']
|
||||
prefix = disk_bus_map.get(disk['model'], 'sd')
|
||||
context['disks'][disk['name']]['target_dev'] = '{0}{1}'.format(prefix, string.ascii_lowercase[i])
|
||||
if hypervisor in ['qemu', 'kvm', 'xen']:
|
||||
context['disks'][disk['name']]['address'] = False
|
||||
context['disks'][disk['name']]['driver'] = True
|
||||
elif hypervisor in ['esxi', 'vmware']:
|
||||
context['disks'][disk['name']]['address'] = True
|
||||
context['disks'][disk['name']]['driver'] = False
|
||||
context['disks'][disk['name']]['disk_bus'] = disk['model']
|
||||
context['disks'][disk['name']]['type'] = disk['format']
|
||||
context['disks'][disk['name']]['index'] = six.text_type(i)
|
||||
disk_context = {
|
||||
'device': disk.get('device', 'disk'),
|
||||
'target_dev': '{0}{1}'.format(prefix, string.ascii_lowercase[i]),
|
||||
'disk_bus': disk['model'],
|
||||
'type': disk['format'],
|
||||
'index': six.text_type(i),
|
||||
}
|
||||
if 'source_file' and disk['source_file']:
|
||||
disk_context['source_file'] = disk['source_file']
|
||||
|
||||
if hypervisor in ['qemu', 'kvm', 'bhyve', 'xen']:
|
||||
disk_context['address'] = False
|
||||
disk_context['driver'] = True
|
||||
elif hypervisor in ['esxi', 'vmware']:
|
||||
disk_context['address'] = True
|
||||
disk_context['driver'] = False
|
||||
context['disks'].append(disk_context)
|
||||
context['nics'] = nicp
|
||||
|
||||
context['os_type'] = os_type
|
||||
|
@ -9,7 +9,7 @@
|
||||
{% endfor %}
|
||||
</os>
|
||||
<devices>
|
||||
{% for diskname, disk in disks.items() %}
|
||||
{% for disk in disks %}
|
||||
<disk type='file' device='{{ disk.device }}'>
|
||||
{% if 'source_file' in disk %}
|
||||
<source file='{{ disk.source_file }}' />
|
||||
|
Loading…
Reference in New Issue
Block a user