
<% nat    = compute_resource.networks %>
<% bridge = compute_resource.interfaces %>

<%= selectable_f f, :type, libvirt_networks(compute_resource), {},
                 { :label    => _('Network type'),
                   :disabled => !new_host,
                   :onchange => 'libvirt_network_selected(this)',
                   :class => 'libvirt_network without_select2'
                 } %>

<div id='nat' class='<%= 'hide' if f.object.type != 'network' %>'>
  <%= selectable_f f, :network, nat.map(&:name),
                   { :include_blank => nat.any? ? false : _("No networks") },
                   { :class => "col-md-2 libvirt_nat without_select2", :label => _("Network"), :disabled => (f.object.type != 'network' || !new_host) } %>
</div>

<div id='bridge' class='<%= 'hide' if f.object.type && (f.object.type != 'bridge') %>'>
  <% if bridge.any? %>
    <%= selectable_f f, :bridge, bridge.map(&:name),
                     { :include_blank => bridge.any? ? false : _("No bridges") },
                     { :class => "col-md-2 libvirt_bridge without_select2", :label => _("Network"), :disabled => ((f.object.type && (f.object.type != 'bridge')) || !new_host) } %>
  <% else %>
    <%= text_f f, :bridge, :class => "col-md-2 libvirt_bridge", :label => _("Network"), :help_block => _("your libvirt host does not support interface listing, please enter here the bridge name (e.g. br0)"), :disabled => !new_host %>
  <% end %>
</div>

<%= selectable_f f, :model, %w(virtio rtl8139 ne2k_pci pcnet e1000), {},
                 { :label => _('NIC type'), :class => 'col-md-2 without_select2', :disabled => !new_host } %>
