<% javascript 'compute_resource', 'lookup_keys' %>
<%= text_f f, :name if show_vm_name? %>
<% new = @host.nil? || @host.try(:new_record?) %>
<% clusters = compute_resource.clusters %>
<%= select_f f, :cluster, clusters, :id, :name, { },
             { :disabled    => !new, :'data-url' => cluster_selected_compute_resource_path(compute_resource),
               :onchange    => 'ovirt_clusterSelected(this);',
               :help_inline => :indicator,
               :label      => _('Cluster') } %>
<%= f.hidden_field :cluster if !new %>
<%= select_f f, :template, compute_resource.templates, :id, :name, {:include_blank => _("Select template")},
             { :disabled    => !new, :'data-url' => template_selected_compute_resource_path(compute_resource),
               :onchange    => 'ovirt_templateSelected(this);',
               :help_inline => :indicator,
               :help_block  => _("Template / Compute Profile to use"),
               :label       => _('Template') } %>
<%= f.hidden_field :template if !new %>

<div class='compute_profile'>
  <%= selectable_f f, :cores, 1..compute_resource.max_cpu_count, { }, :class => "col-md-2", :label => _('Cores') %>
  <%= selectable_f f, :memory, memory_options(compute_resource.max_memory), { }, :class => "col-md-2", :label => _('Memory') %>
  <div class="children_fields">
    <%= new_child_fields_template(f, :interfaces, {
        :object  => compute_resource.new_interface,
        :partial => 'compute_resources_vms/form/ovirt/network', :form_builder_attrs => { :clusters => clusters, :compute_resource => compute_resource } }) %>
    <%= field_set_tag _("Network interfaces"), :id => "network_interfaces", :title => _('Networks') do %>
      <%= f.fields_for :interfaces do |i| %>
        <%= render 'compute_resources_vms/form/ovirt/network', :f => i, :clusters => clusters, :compute_resource => compute_resource %>
      <% end %>
      <%= add_child_link '+ ' + _("Add Interface"), :interfaces, { :class => "info", :title => _('add new network interface') } %>
    <% end %>

    <%= new_child_fields_template(f, :volumes, {
            :object  => compute_resource.new_volume,
            :partial => 'compute_resources_vms/form/ovirt/volume', :form_builder_attrs => { :clusters => clusters, :compute_resource => compute_resource } }) %>
    <%= field_set_tag _("Volumes"), :id => "volumes", :title => _('Volumes') do %>
        <%= f.fields_for :volumes do |i| %>
            <%= render 'compute_resources_vms/form/ovirt/volume', :f => i, :compute_resource => compute_resource %>
        <% end %>
        <%= add_child_link '+ ' + _("Add Volume"), :volumes, { :class => "info", :title => _('add new volume') } %>
    <% end %>
  </div>
</div>
<% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %>
<%= checkbox_f f, :start, { :checked => (checked == '1'), :help_inline => _("Power ON this machine"), :label => _('Start') } if new && controller_name != "compute_attributes" %>
