{#
    Add a typical single-VM device to Vagrantfile

    inputs:
    * name -- node name
    * n    -- node dictionary
#}
  config.vm.define "{{ name }}" do |{{name}}|
{% if n.mgmt is defined and n.mgmt.mac is defined %}
    {{ name }}.vm.provider :libvirt do |domain|
      domain.management_network_mac = "{{n.mgmt.mac}}"
      domain.qemu_use_session = false
    end
{% endif %}
    {{ name }}.vm.box = "{{ n.box }}"
{% if 'box_version' in n %}
    {{ name }}.vm.box_version = "{{ n.box_version }}"
{% endif %}
{% include n.device ~ "-domain.j2" %}

    {{ name }}.vm.provider :libvirt do |domain|
{% if 'cpu' in n %}
      domain.cpus = {{ n.cpu }}
{% endif %}
{% if 'memory' in n %}
      domain.memory = {{ n.memory }}
{% endif %}
{% if n.libvirt is defined and 'nic_model' in n.libvirt %}
      domain.nic_model_type = "{{ n.libvirt.nic_model }}"
{% endif %}
    end

{% for l in n.interfaces|default([]) if l.virtual_interface is not defined %}
{%   if 'remote_ifindex' in l: %}
{%     include "libvirt-tunnel.j2" %}
{%   else %}
{%     include "libvirt-bridge.j2" %}
{%   endif %}

{% endfor %}
  end
