Skip to content

Commit

Permalink
869371-ram - able to set RAM during new system creation in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmckay committed Dec 18, 2012
1 parent 2fc4d4b commit 5b92cde
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/app/controllers/systems_controller.rb
Expand Up @@ -84,7 +84,7 @@ def param_rules
check_array_params([:id], params)
end
end
{ :create => {:arch => [:arch_id],:system=>[:sockets, :name, :environment_id], :system_type =>[:virtualized]},
{ :create => {:arch => [:arch_id],:system=>[:sockets, :name, :environment_id, :memory], :system_type =>[:virtualized]},
:update => update_check
}
end
Expand All @@ -109,6 +109,7 @@ def create
@system.facts = {}
@system.arch = params["arch"]["arch_id"]
@system.sockets = params["system"]["sockets"]
@system.memory = params["system"]["memory"]
@system.guest = (params["system_type"]["virtualized"] == 'virtual')
@system.name= params["system"]["name"]
@system.cp_type = "system"
Expand Down
15 changes: 12 additions & 3 deletions src/app/models/glue/candlepin/consumer.rb
Expand Up @@ -288,12 +288,21 @@ def distribution
end

def memory
mem = facts["memory.memtotal"]
# dmi.memory.size is on older clients
mem ||= facts["dmi.memory.size"]
if facts
mem = facts["memory.memtotal"]
# dmi.memory.size is on older clients
mem ||= facts["dmi.memory.size"]
else
mem = '0'
end
memory_in_megabytes(mem)
end

def memory=(mem)
mem = "#{mem.to_i} MB"
facts["memory.memtotal"] = mem
end

def entitlements_valid?
"true" == facts["system.entitlements_valid"]
end
Expand Down
7 changes: 4 additions & 3 deletions src/app/models/system.rb
Expand Up @@ -39,7 +39,7 @@ class System < ActiveRecord::Base
:system_group,
:installed_products,
"custom_info.KEYNAME",
:ram,
:memory,
:sockets]

dynamic_templates = [
Expand Down Expand Up @@ -70,7 +70,7 @@ class System < ActiveRecord::Base
indexes :lastCheckin, :type=>'date'
indexes :name_autocomplete, :type=>'string', :analyzer=>'autcomplete_name_analyzer'
indexes :installed_products, :type=>'string', :analyzer=>:kt_name_analyzer
indexes :ram, :type => 'integer'
indexes :memory, :type => 'integer'
indexes :sockets, :type => 'integer'
indexes :facts, :path=>"just_name" do
end
Expand Down Expand Up @@ -103,6 +103,8 @@ class System < ActiveRecord::Base
validates_length_of :location, :maximum => 255
validates :sockets, :numericality => { :only_integer => true, :greater_than => 0 },
:allow_nil => true, :if => ("validation_context == :create || validation_context == :update")
validates :memory, :numericality => { :only_integer => true, :greater_than_or_equal_to => 0 },
:allow_nil => true, :if => ("validation_context == :create || validation_context == :update")
before_create :fill_defaults

after_create :init_default_custom_info_keys
Expand Down Expand Up @@ -302,7 +304,6 @@ def extended_index_attrs
:system_group=>self.system_groups.collect{|g| g.name},
:system_group_ids=>self.system_group_ids,
:installed_products=>collect_installed_product_names,
:ram => self.memory,
:sockets => self.sockets,
:custom_info=>collect_custom_info
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/systems/_edit.html.haml
Expand Up @@ -85,7 +85,7 @@
.grid_5.la #{System.architectures[system.arch]}
%fieldset
.grid_2.ra.fieldset
= label :ram, :ram, _("RAM (MB)")
= label :memory, :memory, _("RAM (MB)")
.grid_5.la #{system.memory}
%fieldset
.grid_2.ra.fieldset
Expand Down
6 changes: 5 additions & 1 deletion src/app/views/systems/_new.html.haml
Expand Up @@ -7,12 +7,14 @@

:ruby
sockets_help = _("The number of CPU Sockets or LPARs which this system uses")
memory_help = _("The amount of RAM memory, in megabytes (MB), which this system has")


- if @environment
= content_for :title do
#{_("New system")}
= content_for :content do
= content_for :content do
.full
= kt_form_for(System.new, :action => "create", :id => "new_system") do |form|
= hidden_field_tag 'system[environment_id]', @environment.id
.grid_8#new_system
Expand All @@ -23,6 +25,8 @@

= form.text_field :sockets, :label => _("Number of Sockets or LPARs:"), :help => sockets_help, :value => 1

= form.text_field :memory, :label => _("Amount of RAM (MB):"), :help => memory_help, :value => ''

= form.field :virtual, :label => _("System Type:") do
= virtual_buttons

Expand Down

0 comments on commit 5b92cde

Please sign in to comment.