|
1 | 1 | <domain type='{{ libvirt_vm_engine }}'> |
2 | 2 | <name>{{ vm.name }}</name> |
3 | | - {% if vm.uuid is defined %} |
| 3 | +{% if vm.uuid is defined %} |
4 | 4 | <uuid>{{ vm.uuid }}</uuid> |
5 | | - {% elif (libvirt_vm_default_uuid_deterministic | bool) or (vm.uuid_deterministic is defined and (vm.uuid_deterministic | bool)) %} |
| 5 | +{% elif (libvirt_vm_default_uuid_deterministic | bool) or (vm.uuid_deterministic is defined and (vm.uuid_deterministic | bool)) %} |
6 | 6 | <uuid>{{ vm.name | to_uuid }}</uuid> |
7 | | - {% endif %} |
| 7 | +{% endif %} |
8 | 8 | <memory>{{ vm.memory_mb | int * 1024 }}</memory> |
9 | 9 | <vcpu>{{ vm.vcpus }}</vcpu> |
10 | | - {% if vm.clock_offset |default( libvirt_vm_clock_offset ) %} |
| 10 | +{% if vm.clock_offset |default( libvirt_vm_clock_offset ) %} |
11 | 11 | <clock offset="{{ vm.clock_offset }}"/> |
12 | | - {% else %} |
| 12 | +{% else %} |
13 | 13 | <clock sync="localtime"/> |
14 | | - {% endif %} |
| 14 | +{% endif %} |
15 | 15 | <on_poweroff>destroy</on_poweroff> |
16 | 16 | <on_reboot>restart</on_reboot> |
17 | 17 | <on_crash>destroy</on_crash> |
|
34 | 34 | <apic/> |
35 | 35 | <pae/> |
36 | 36 | </features> |
37 | | - {% if cpu_mode %} |
| 37 | +{% if cpu_mode %} |
38 | 38 | <cpu mode='{{ cpu_mode }}'> |
39 | 39 | <model fallback='allow'/> |
40 | 40 | </cpu> |
41 | | - {% endif %} |
| 41 | +{% endif %} |
42 | 42 | <devices> |
43 | 43 | <emulator>{{ libvirt_vm_emulator }}</emulator> |
44 | 44 | {% for volume in volumes %} |
45 | 45 | <disk type='{{ volume.type | default(libvirt_volume_default_type) }}' device='{{ volume.device | default(libvirt_volume_default_device) }}'> |
46 | 46 | <driver name='qemu' type='{{ volume.format | default(libvirt_volume_default_format) }}'/> |
47 | | - {% if volume.type | default(libvirt_volume_default_type) == 'file' %} |
| 47 | + {% if volume.type | default(libvirt_volume_default_type) == 'file' %} |
48 | 48 | <source file='{{ volume.file_path |default(libvirt_volume_default_images_path) }}/{{ volume.name}}'/> |
49 | | - {% elif volume.type | default(libvirt_volume_default_type) == 'network' %} |
50 | | - {% if volume.auth.username is defined %} |
| 49 | + {% elif volume.type | default(libvirt_volume_default_type) == 'network' %} |
| 50 | + {% if volume.auth.username is defined %} |
51 | 51 | <auth username='{{ volume.auth.username }}'> |
52 | 52 | <secret type='{{ volume.auth.type }}' {% if volume.auth.uuid is defined and volume.auth.uuid is not none %} uuid='{{ volume.auth.uuid }}' {% else %} usage='{{ volume.auth.usage }}' {% endif %}/> |
53 | 53 | </auth> |
54 | | - {% endif %} {# End volume.auth.username check #} |
55 | | - {% if volume.source.name is defined %} |
| 54 | + {% endif %} {# End volume.auth.username check #} |
| 55 | + {% if volume.source.name is defined %} |
56 | 56 | <source protocol='{{ volume.source.protocol }}' name='{{ volume.source.name }}'> |
57 | | - {% for host in volume.source.hosts_list %} |
| 57 | + {% for host in volume.source.hosts_list %} |
58 | 58 | <host name='{{ host }}' {% if volume.source.port is defined and volume.source.port is not none %} port='{{ volume.source.port }}' {% endif %}/> |
59 | | - {% endfor %} |
| 59 | + {% endfor %} |
60 | 60 | </source> |
61 | | - {% endif %} {# End volume.source.name check #} |
62 | | - {% elif volume.type | default(libvirt_volume_default_type) == 'block' %} |
| 61 | + {% endif %} {# End volume.source.name check #} |
| 62 | + {% elif volume.type | default(libvirt_volume_default_type) == 'block' %} |
63 | 63 | <source dev='{{ volume.dev }}'/> |
64 | | - {% else %} {# End elif volume.type is defined #} |
| 64 | + {% else %} {# End elif volume.type is defined #} |
65 | 65 | <source pool='{{ volume.pool }}' volume='{{ volume.name }}'/> |
66 | | - {% endif %} |
67 | | - {% if volume.target is undefined %} |
| 66 | + {% endif %} |
| 67 | + {% if volume.target is undefined %} |
68 | 68 | <target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index - 1] }}' {% if volume.device | default(libvirt_volume_default_device) == 'cdrom' %}bus='sata'{% endif %}/> |
69 | | - {% else %} |
| 69 | + {% else %} |
70 | 70 | <target dev='{{ volume.target }}' {% if volume.device | default(libvirt_volume_default_device) == 'cdrom' %}bus='sata'{% endif %}/> |
71 | | - {% endif %} |
| 71 | + {% endif %} |
72 | 72 | </disk> |
73 | 73 | {% endfor %} |
74 | 74 | {% for interface in interfaces %} |
75 | | -{% if interface.type is defined and interface.type == 'direct' %} |
| 75 | + {% if interface.type is defined and interface.type == 'direct' %} |
76 | 76 | <interface type='direct' {% if interface.trust_guest_rx_filters | default(libvirt_vm_trust_guest_rx_filters) | bool %}trustGuestRxFilters='yes'{% endif %}> |
77 | 77 | <source dev='{{ interface.source.dev }}' mode='{{ interface.source.mode | default('vepa') }}'/> |
78 | | -{% elif interface.type is defined and interface.type == 'bridge' %} |
| 78 | + {% elif interface.type is defined and interface.type == 'bridge' %} |
79 | 79 | <interface type='bridge'> |
80 | 80 | <source bridge='{{ interface.source.dev }}'/> |
81 | | -{% elif interface.type is not defined or interface.type == 'network' %} |
| 81 | + {% elif interface.type is not defined or interface.type == 'network' %} |
82 | 82 | <interface type='network'> |
83 | 83 | <source network='{{ interface.network }}'/> |
84 | | -{% endif %} |
85 | | - {% if interface.mac is defined %} |
| 84 | + {% endif %} |
| 85 | + {% if interface.mac is defined %} |
86 | 86 | <mac address='{{ interface.mac }}'/> |
87 | | - {% endif %} |
| 87 | + {% endif %} |
88 | 88 | {# if the network configuration is invalid this can still appear in the xml #} |
89 | 89 | {# (say you enter 'bond' instead of 'bridge' in your variables) #} |
90 | | - {% if interface.model is defined %} |
| 90 | + {% if interface.model is defined %} |
91 | 91 | <model type='{{ interface.model }}'/> |
92 | 92 | {% else %} |
93 | 93 | <model type='virtio'/> |
94 | 94 | {% endif %} |
95 | 95 | {% if interface.alias is defined %} |
96 | 96 | <alias name='ua-{{ interface.alias }}'/> |
97 | | - {% endif %} |
| 97 | + {% endif %} |
98 | 98 | </interface> |
99 | 99 | {% endfor %} |
100 | 100 | {% if console_log_enabled | bool %} |
|
0 commit comments