|
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>
|
|
28 | 28 | <apic/>
|
29 | 29 | <pae/>
|
30 | 30 | </features>
|
31 |
| - {% if cpu_mode %} |
| 31 | +{% if cpu_mode %} |
32 | 32 | <cpu mode='{{ cpu_mode }}'>
|
33 | 33 | <model fallback='allow'/>
|
34 | 34 | </cpu>
|
35 |
| - {% endif %} |
| 35 | +{% endif %} |
36 | 36 | <devices>
|
37 | 37 | <emulator>{{ libvirt_vm_emulator }}</emulator>
|
38 | 38 | {% for volume in volumes %}
|
39 | 39 | <disk type='{{ volume.type | default(libvirt_volume_default_type) }}' device='{{ volume.device | default(libvirt_volume_default_device) }}'>
|
40 | 40 | <driver name='qemu' type='{{ volume.format | default(libvirt_volume_default_format) }}'/>
|
41 |
| - {% if volume.type | default(libvirt_volume_default_type) == 'file' %} |
| 41 | + {% if volume.type | default(libvirt_volume_default_type) == 'file' %} |
42 | 42 | <source file='{{ volume.file_path |default(libvirt_volume_default_images_path) }}/{{ volume.name}}'/>
|
43 |
| - {% elif volume.type | default(libvirt_volume_default_type) == 'network' %} |
44 |
| - {% if volume.auth.username is defined %} |
| 43 | + {% elif volume.type | default(libvirt_volume_default_type) == 'network' %} |
| 44 | + {% if volume.auth.username is defined %} |
45 | 45 | <auth username='{{ volume.auth.username }}'>
|
46 | 46 | <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 %}/>
|
47 | 47 | </auth>
|
48 |
| - {% endif %} {# End volume.auth.username check #} |
49 |
| - {% if volume.source.name is defined %} |
| 48 | + {% endif %} {# End volume.auth.username check #} |
| 49 | + {% if volume.source.name is defined %} |
50 | 50 | <source protocol='{{ volume.source.protocol }}' name='{{ volume.source.name }}'>
|
51 |
| - {% for host in volume.source.hosts_list %} |
| 51 | + {% for host in volume.source.hosts_list %} |
52 | 52 | <host name='{{ host }}' {% if volume.source.port is defined and volume.source.port is not none %} port='{{ volume.source.port }}' {% endif %}/>
|
53 |
| - {% endfor %} |
| 53 | + {% endfor %} |
54 | 54 | </source>
|
55 |
| - {% endif %} {# End volume.source.name check #} |
56 |
| - {% elif volume.type | default(libvirt_volume_default_type) == 'block' %} |
| 55 | + {% endif %} {# End volume.source.name check #} |
| 56 | + {% elif volume.type | default(libvirt_volume_default_type) == 'block' %} |
57 | 57 | <source dev='{{ volume.dev }}'/>
|
58 |
| - {% else %} {# End elif volume.type is defined #} |
| 58 | + {% else %} {# End elif volume.type is defined #} |
59 | 59 | <source pool='{{ volume.pool }}' volume='{{ volume.name }}'/>
|
60 |
| - {% endif %} |
61 |
| - {% if volume.target is undefined %} |
| 60 | + {% endif %} |
| 61 | + {% if volume.target is undefined %} |
62 | 62 | <target dev='vd{{ 'abcdefghijklmnopqrstuvwxyz'[loop.index - 1] }}' {% if volume.device | default(libvirt_volume_default_device) == 'cdrom' %}bus='sata'{% endif %}/>
|
63 |
| - {% else %} |
| 63 | + {% else %} |
64 | 64 | <target dev='{{ volume.target }}' {% if volume.device | default(libvirt_volume_default_device) == 'cdrom' %}bus='sata'{% endif %}/>
|
65 |
| - {% endif %} |
| 65 | + {% endif %} |
66 | 66 | </disk>
|
67 | 67 | {% endfor %}
|
68 | 68 | {% for interface in interfaces %}
|
69 |
| -{% if interface.type is defined and interface.type == 'direct' %} |
| 69 | + {% if interface.type is defined and interface.type == 'direct' %} |
70 | 70 | <interface type='direct' {% if interface.trust_guest_rx_filters | default(libvirt_vm_trust_guest_rx_filters) | bool %}trustGuestRxFilters='yes'{% endif %}>
|
71 | 71 | <source dev='{{ interface.source.dev }}' mode='{{ interface.source.mode | default('vepa') }}'/>
|
72 |
| -{% elif interface.type is defined and interface.type == 'bridge' %} |
| 72 | + {% elif interface.type is defined and interface.type == 'bridge' %} |
73 | 73 | <interface type='bridge'>
|
74 | 74 | <source bridge='{{ interface.source.dev }}'/>
|
75 |
| -{% elif interface.type is not defined or interface.type == 'network' %} |
| 75 | + {% elif interface.type is not defined or interface.type == 'network' %} |
76 | 76 | <interface type='network'>
|
77 | 77 | <source network='{{ interface.network }}'/>
|
78 |
| -{% endif %} |
79 |
| - {% if interface.mac is defined %} |
| 78 | + {% endif %} |
| 79 | + {% if interface.mac is defined %} |
80 | 80 | <mac address='{{ interface.mac }}'/>
|
81 |
| - {% endif %} |
| 81 | + {% endif %} |
82 | 82 | {# if the network configuration is invalid this can still appear in the xml #}
|
83 | 83 | {# (say you enter 'bond' instead of 'bridge' in your variables) #}
|
84 |
| - {% if interface.model is defined %} |
| 84 | + {% if interface.model is defined %} |
85 | 85 | <model type='{{ interface.model }}'/>
|
86 | 86 | {% else %}
|
87 | 87 | <model type='virtio'/>
|
88 | 88 | {% endif %}
|
89 | 89 | {% if interface.alias is defined %}
|
90 | 90 | <alias name='ua-{{ interface.alias }}'/>
|
91 |
| - {% endif %} |
| 91 | + {% endif %} |
92 | 92 | </interface>
|
93 | 93 | {% endfor %}
|
94 | 94 | {% if console_log_enabled | bool %}
|
|
0 commit comments