software-infrastructure/templates/libvirt-vm.xml.j2
2024-10-25 10:25:04 -04:00

109 lines
5.4 KiB
Django/Jinja

<domain type='{{ domain.type }}'>
<name>{{ domain.name }}</name>
<memory unit='{{ domain.memory.unit }}'>{{ domain.memory.value }}</memory>
<vcpu placement='{{ domain.vcpu.placement }}'>{{ domain.vcpu.value }}</vcpu>
<os>
<type arch='{{ domain.os.type.arch }}' machine='{{ domain.os.type.machine }}'>{{ domain.os.type.value }}</type>
<boot dev='{{ domain.os.boot.dev }}'/>
</os>
<cpu mode='{{ domain.cpu.mode }}' check='{{ domain.cpu.check }}'/>
<devices>
<emulator>{{ domain.devices.emulator }}</emulator>
{% if domain.devices.disks is defined %}
{% for disk in domain.devices.disks %}
<disk type='{{ disk.type }}' device='{{ disk.device }}'>
<driver name='{{ disk.driver.name }}' type='{{ disk.driver.type }}'/>
{% if disk.source.protocol is defined %}
<source protocol='{{ disk.source.protocol }}' name='{{ disk.source.name }}'>
<host name='{{ disk.source.host.name }}' port='{{ disk.source.host.port }}'/>
</source>
{% elif disk.source.dev is defined %}
<source dev='{{ disk.source.dev }}'/>
{% else %}
<source file='{{ disk.source.file }}'/>
{% endif %}
<target dev='{{ disk.target.dev }}' bus='{{ disk.target.bus }}'/>
{% if disk.address is defined %}
<address type='{{ disk.address.type }}' domain='{{ disk.address.domain }}' bus='{{ disk.address.bus }}' slot='{{ disk.address.slot }}' function='{{ disk.address.function }}'/>
{% endif %}
</disk>
{% endfor %}
{% endif %}
{% if domain.filesystems is defined %}
{% for filesystem in domain.filesystems %}
<filesystem type='{{ filesystem.type }}' accessmode='{{ filesystem.accessmode }}'>
<source dir='{{ filesystem.source.dir }}'/>
<target dir='{{ filesystem.target.dir }}'/>
</filesystem>
{% endfor %}
{% endif %}
{% if domain.devices.interfaces is defined %}
{% for interface in domain.devices.interfaces %}
<interface type='{{ interface.type }}'>
<source network='{{ interface.source.network }}'/>
<model type='{{ interface.model.type }}'/>
{% if interface.address is defined %}
<address type='{{ interface.address.type }}' domain='{{ interface.address.domain }}' bus='{{ interface.address.bus }}' slot='{{ interface.address.slot }}' function='{{ interface.address.function }}'/>
{% endif %}
</interface>
{% endfor %}
{% endif %}
{% if domain.devices.channels is defined %}
{% for channel in domain.devices.channels %}
<channel type='{{ channel.type }}'>
<target type='{{ channel.target.type }}' name='{{ channel.target.name }}'/>
{% if channel.address is defined %}
<address type='{{ channel.address.type }}' controller='{{ channel.address.controller }}' bus='{{ channel.address.bus }}' port='{{ channel.address.port }}'/>
{% endif %}
</channel>
{% endfor %}
{% endif %}
{% if domain.devices.inputs is defined %}
{% for input in domain.devices.inputs %}
<input type='{{ input.type }}' bus='{{ input.bus }}'>
{% if input.address is defined %}
<address type='{{ input.address.type }}' bus='{{ input.address.bus }}' port='{{ input.address.port }}'/>
{% endif %}
</input>
{% endfor %}
{% endif %}
{% if domain.devices.graphics is defined %}
<graphics type='{{ domain.devices.graphics.type }}' autoport='{{ domain.devices.graphics.autoport }}'>
<listen type='{{ domain.devices.graphics.listen.type }}'/>
<image compression='{{ domain.devices.graphics.image.compression }}'/>
</graphics>
{% endif %}
{% if domain.devices.video is defined %}
<video>
<model type='{{ domain.devices.video.model.type }}' ram='{{ domain.devices.video.model.ram }}' vram='{{ domain.devices.video.model.vram }}' vgamem='{{ domain.devices.video.model.vgamem }}' heads='{{ domain.devices.video.model.heads }}' primary='{{ domain.devices.video.model.primary }}'/>
{% if domain.devices.video.address is defined %}
<address type='{{ domain.devices.video.address.type }}' domain='{{ domain.devices.video.address.domain }}' bus='{{ domain.devices.video.address.bus }}' slot='{{ domain.devices.video.address.slot }}' function='{{ domain.devices.video.address.function }}'/>
{% endif %}
</video>
{% endif %}
{% if domain.devices.memballoon is defined %}
<memballoon model='{{ domain.devices.memballoon.model }}'>
{% if domain.devices.memballoon.address is defined %}
<address type='{{ domain.devices.memballoon.address.type }}' domain='{{ domain.devices.memballoon.address.domain }}' bus='{{ domain.devices.memballoon.address.bus }}' slot='{{ domain.devices.memballoon.address.slot }}' function='{{ domain.devices.memballoon.address.function }}'/>
{% endif %}
</memballoon>
{% endif %}
{% if domain.devices.rng is defined %}
<rng model='virtio'>
<backend model='random'>/dev/urandom</backend>
{% if domain.devices.rng.address is defined %}
<address type='{{ domain.devices.rng.address.type }}' domain='{{ domain.devices.rng.address.domain }}' bus='{{ domain.devices.rng.address.bus }}' slot='{{ domain.devices.rng.address.slot }}' function='{{ domain.devices.rng.address.function }}'/>
{% endif %}
</rng>
{% endif %}
<serial type='pty'>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
</devices>
</domain>