diff --git a/app/models/concerns/fog_extensions/xenserver/server.rb b/app/models/concerns/fog_extensions/xenserver/server.rb index 191cfd2..c57f4fd 100644 --- a/app/models/concerns/fog_extensions/xenserver/server.rb +++ b/app/models/concerns/fog_extensions/xenserver/server.rb @@ -2,6 +2,8 @@ module FogExtensions module Xenserver module Server + attr_accessor :memory_min, :memory_max, :custom_template_name, :builtin_template_name + def to_s name end @@ -10,14 +12,6 @@ def nics_attributes=(attrs); end def volumes_attributes=(attrs); end - def memory_min - memory_static_min.to_i - end - - def memory_max - memory_static_max.to_i - end - def memory memory_static_max.to_i end @@ -38,14 +32,6 @@ def state power_state end - def custom_template_name - template_name - end - - def builtin_template_name - template_name - end - end end end diff --git a/app/views/compute_resources_vms/form/_network.html.erb b/app/views/compute_resources_vms/form/_network.html.erb index f7ee2bf..b98310f 100644 --- a/app/views/compute_resources_vms/form/_network.html.erb +++ b/app/views/compute_resources_vms/form/_network.html.erb @@ -4,6 +4,8 @@ selected = "" if params && params['host'] && params['host']['compute_attributes'] selected = params['host']['compute_attributes']['VIFs']['print'] + elsif new.__vifs + selected = new.__vifs['print'] end -%> diff --git a/app/views/compute_resources_vms/form/_templates.html.erb b/app/views/compute_resources_vms/form/_templates.html.erb index 0d44aee..78f6770 100644 --- a/app/views/compute_resources_vms/form/_templates.html.erb +++ b/app/views/compute_resources_vms/form/_templates.html.erb @@ -9,29 +9,12 @@ %>
- -
- -
-
- +
+ <%= selectable_f f, :custom_template_name,[[_("No template"), ""]] + compute_resource.custom_templates.map { |t| [t.name, t.name] }, {}, :class => 'form-control span2', :label => 'Custom Template' %>
-
-
- -
-
- -
+ <%= selectable_f f, :builtin_template_name,[[_("No template"), ""]] + compute_resource.builtin_templates.map { |t| [t.name, t.name] }, {}, :class => 'form-control span2', :label => 'Builtin Template' %>
-
-
-
\ No newline at end of file diff --git a/app/views/compute_resources_vms/form/_volume.html.erb b/app/views/compute_resources_vms/form/_volume.html.erb index 732177c..a1d8cb2 100644 --- a/app/views/compute_resources_vms/form/_volume.html.erb +++ b/app/views/compute_resources_vms/form/_volume.html.erb @@ -2,9 +2,12 @@ <% selected = "" size = "" - if params && params['host'] && params['host']['compute_attributes'] + if params && params['host'] && params['host']['compute_attributes'] && params['host']['compute_attributes']['VBDs']['physical_size'] != "" selected = params['host']['compute_attributes']['VBDs']['print'] size = params['host']['compute_attributes']['VBDs']['physical_size'] + elsif new.__vbds + selected = new.__vbds['print'] + size = new.__vbds['physical_size'] end -%> <%= selectable_f f, :print, compute_resource.storage_pools.map(&:name), { :selected => selected }, :class => "span2", :label => _("Storage Repository") %> diff --git a/app/views/compute_resources_vms/form/_xenserver.html.erb b/app/views/compute_resources_vms/form/_xenserver.html.erb index d7cddc9..bba92ab 100644 --- a/app/views/compute_resources_vms/form/_xenserver.html.erb +++ b/app/views/compute_resources_vms/form/_xenserver.html.erb @@ -3,65 +3,72 @@ if params && params['host'] && params['host']['compute_attributes'] && params['host']['compute_attributes']['custom_template_name'] != '' hide_raw = 'display:none;' end + + if controller_name == 'hosts' + fields_enabled = true + elsif controller_name == 'compute_attributes' + fields_enabled = true + else + fields_enabled = false + end -%>
VM Profile
- <%= text_f f, :name, :disabled => !new if controller_name != 'hosts' %> - <%= selectable_f f, :vcpus_max, 1..compute_resource.max_cpu_count, {}, :class => 'input-mini', :disabled => !new, :label => 'vCPUs' %> - <%= selectable_f f, :memory_min, memory_options(compute_resource.max_memory), {}, :class => 'form-control span2', :disabled => !new, :label => 'Memory Min' %> - <%= selectable_f f, :memory_max, memory_options(compute_resource.max_memory), {}, :class => 'form-control span2', :disabled => !new, :label => 'Memory Max' %> + <%= text_f f, :name, :disabled => !fields_enabled, :label => 'Name' if controller_name != 'hosts' %> + <%= selectable_f f, :vcpus_max, 1..compute_resource.max_cpu_count, {}, :class => 'input-mini', :disabled => !fields_enabled, :label => 'vCPUs' %> + <%= selectable_f f, :memory_min, memory_options(compute_resource.max_memory), {}, :class => 'form-control span2', :disabled => !fields_enabled, :label => 'Memory Min' %> + <%= selectable_f f, :memory_max, memory_options(compute_resource.max_memory), {}, :class => 'form-control span2', :disabled => !fields_enabled, :label => 'Memory Max' %>
<%= field_set_tag 'VM Template', :id => 'xen_templates', :title => _('Template') do -%> - <%= render 'compute_resources_vms/form/templates', :f => f, :compute_resource => compute_resource %> + <%= render 'compute_resources_vms/form/templates', :f => f, :compute_resource => compute_resource, :new => new %> <% end -%>
<%= field_set_tag 'Xen Store Data', :id => 'xen_store_data', :title => _('Xen Store Data') do -%> - <%= render 'compute_resources_vms/form/xenstore', :f => f, :compute_resource => compute_resource, :new => new %> + <%= render 'compute_resources_vms/form/xenstore', :f => f, :compute_resource => compute_resource, :new => new %> <% end %>
-
<%= new_child_fields_template(f, :VBDs, { - :object => compute_resource.new_volume, - :partial => 'compute_resources_vms/form/volume', :form_builder_attrs => { :compute_resource => compute_resource } }) %> + :object => compute_resource.new_volume, + :partial => 'compute_resources_vms/form/volume', :form_builder_attrs => { :compute_resource => compute_resource, :new => new } }) %> <%= field_set_tag 'Storage', :id => 'storage_volumes', :title => _('Storage') do -%> - <%= f.fields_for :VBDs do |i| %> - <%= render 'compute_resources_vms/form/volume', :f => i, :compute_resource => compute_resource %> - <% end -%> + <%= f.fields_for :VBDs do |i| %> + <%= render 'compute_resources_vms/form/volume', :f => i, :compute_resource => compute_resource, :new => new %> + <% end -%> <% end -%>
<%= field_set_tag 'Network interfaces', :id => 'network_interfaces', :title => _('Networks') do -%> - <%= f.fields_for :VIFs do |i| %> - <%= render 'compute_resources_vms/form/network', :f => i, :compute_resource => compute_resource %> - <% end -%> + <%= f.fields_for :VIFs do |i| %> + <%= render 'compute_resources_vms/form/network', :f => i, :compute_resource => compute_resource, :new => new %> + <% end -%> <% end -%>
<%= field_set_tag 'VM Startup Options', :id => 'vm_starup_options', :title => _('Power ON this machine') do -%> -
- -
-
- <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %> - <%= checkbox_f f, :start, { :checked => (checked == '1')} if new %> -
-
-
+
+ +
+
+ <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %> + <%= checkbox_f f, :start, { :checked => (checked == '1')} if fields_enabled %> +
+
+
<% end -%>
@@ -69,18 +76,18 @@ diff --git a/app/views/compute_resources_vms/form/_xenstore.html.erb b/app/views/compute_resources_vms/form/_xenstore.html.erb index dc113b5..b90ecf8 100644 --- a/app/views/compute_resources_vms/form/_xenstore.html.erb +++ b/app/views/compute_resources_vms/form/_xenstore.html.erb @@ -1,11 +1,11 @@ <% vmdata = { :ifs => - { '0' => { - :ip => '', - :gateway => '', - :netmask => '' - } - }, + { '0' => { + :ip => '', + :gateway => '', + :netmask => '' + } + }, :nameserver1 => '', :nameserver2 => '', :environment => '' @@ -31,100 +31,100 @@
-
+
-
-
- id="xenstore-vm-data-ifs-0-ip" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][ip]" class="form-control input-mini" value="<%= ip %>"> -
-
+
+
+ id="xenstore-vm-data-ifs-0-ip" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][ip]" class="form-control input-mini" value="<%= ip %>"> +
+
-
+
-
-
- id="xenstore-vm-data-ifs-0-gateway" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][gateway]" class="form-control input-mini" value="<%= gateway %>"> -
-
+
+
+ id="xenstore-vm-data-ifs-0-gateway" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][gateway]" class="form-control input-mini" value="<%= gateway %>"> +
+
-
+
-
-
- id="xenstore-vm-data-ifs-0-netmask" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][netmask]" class="form-control input-mini" value="<%= netmask %>"> -
-
+
+
+ id="xenstore-vm-data-ifs-0-netmask" type="text" name="host[compute_attributes][xenstore][vm-data][ifs][0][netmask]" class="form-control input-mini" value="<%= netmask %>"> +
+
-
- -
- id="xenstore-vm-data-nameserver1" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver1]" class="form-control input-mini" value="<%= nameserver1 %>"> -
+
+ +
+ id="xenstore-vm-data-nameserver1" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver1]" class="form-control input-mini" value="<%= nameserver1 %>">
+
-
- -
- id="xenstore-vm-data-nameserver2" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver2]" class="form-control input-mini" value="<%= nameserver2 %>"> -
+
+ +
+ id="xenstore-vm-data-nameserver2" type="text" name="host[compute_attributes][xenstore][vm-data][nameserver2]" class="form-control input-mini" value="<%= nameserver2 %>">
+
-
- -
- id="xenstore-vm-data-environment" type="text" name="host[compute_attributes][xenstore][vm-data][environment]" class="form-control input-mini" value="<%= environment %>"> -
+
+ +
+ id="xenstore-vm-data-environment" type="text" name="host[compute_attributes][xenstore][vm-data][environment]" class="form-control input-mini" value="<%= environment %>">
+
\ No newline at end of file