Cleanup libvirt templates for netris switches
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
{# Build list of links for this switch #}
|
||||
{% set switch_links = [] %}
|
||||
{% set link_idx = namespace(value=0) %}
|
||||
{% for link in topology.links %}
|
||||
{% if link.local == vm_name %}
|
||||
{% set _ = switch_links.append({'port': link.local_port, 'remote': link.remote, 'remote_port': link.remote_port, 'udp_local': udp_base_port + (link_idx.value * 2), 'udp_remote': udp_base_port + (link_idx.value * 2) + 1}) %}
|
||||
{% endif %}
|
||||
{% if link.remote == vm_name %}
|
||||
{% set _ = switch_links.append({'port': link.remote_port, 'remote': link.local, 'remote_port': link.local_port, 'udp_local': udp_base_port + (link_idx.value * 2) + 1, 'udp_remote': udp_base_port + (link_idx.value * 2)}) %}
|
||||
{% endif %}
|
||||
{% set link_idx.value = link_idx.value + 1 %}
|
||||
{% endfor %}
|
||||
{# Add server links #}
|
||||
{% set server_link_start = topology.links | length %}
|
||||
{% for server in servers | default([]) %}
|
||||
{% if server.connected_to == vm_name %}
|
||||
{% set _ = switch_links.append({'port': server.switch_port, 'remote': server.name, 'remote_port': 'eth1', 'udp_local': udp_base_port + ((server_link_start + loop.index0) * 2), 'udp_remote': udp_base_port + ((server_link_start + loop.index0) * 2) + 1}) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
||||
<name>{{ vm_name }}</name>
|
||||
<memory unit='MiB'>{{ switch_memory_mb }}</memory>
|
||||
<vcpu placement='static'>{{ switch_vcpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc-q35-8.2'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
</features>
|
||||
<cpu mode='host-passthrough' check='none' migratable='on'/>
|
||||
<clock offset='utc'>
|
||||
<timer name='rtc' tickpolicy='catchup'/>
|
||||
<timer name='pit' tickpolicy='delay'/>
|
||||
<timer name='hpet' present='no'/>
|
||||
</clock>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='{{ vm_disk_path }}/{{ vm_name }}.qcow2'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
</disk>
|
||||
<controller type='usb' model='none'/>
|
||||
<serial type='pty'>
|
||||
<target type='isa-serial' port='0'>
|
||||
<model name='isa-serial'/>
|
||||
</target>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target type='serial' port='0'/>
|
||||
</console>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
|
||||
<!-- QEMU command line arguments for networking -->
|
||||
<qemu:commandline>
|
||||
<!-- Management interface with SSH port forwarding -->
|
||||
<qemu:arg value='-netdev'/>
|
||||
<qemu:arg value='user,id=mgmt,net=192.168.100.0/24,hostfwd=tcp::{{ mgmt_ssh_base_port + vm_index | int }}-:22'/>
|
||||
<qemu:arg value='-device'/>
|
||||
<qemu:arg value='virtio-net-pci,netdev=mgmt,mac=52:54:00:00:{{ "%02x" | format(vm_index | int) }}:00'/>
|
||||
|
||||
{% for link in switch_links %}
|
||||
<!-- {{ link.port }} <-> {{ link.remote }}:{{ link.remote_port }} -->
|
||||
<qemu:arg value='-netdev'/>
|
||||
<qemu:arg value='socket,id={{ link.port | replace("/", "_") }},udp=127.0.0.1:{{ link.udp_remote }},localaddr=127.0.0.1:{{ link.udp_local }}'/>
|
||||
<qemu:arg value='-device'/>
|
||||
<qemu:arg value='virtio-net-pci,netdev={{ link.port | replace("/", "_") }},mac=52:54:{{ "%02x" | format(vm_index | int) }}:{{ "%02x" | format(loop.index) }}:{{ "%02x" | format((link.udp_local // 256) % 256) }}:{{ "%02x" | format(link.udp_local % 256) }}'/>
|
||||
|
||||
{% endfor %}
|
||||
</qemu:commandline>
|
||||
</domain>
|
||||
Reference in New Issue
Block a user