Feature #97
closed
Need view for unconfigured hosts
Added by Martin Englund almost 15 years ago.
Updated about 14 years ago.
Description
When you point existing systems to foreman a special view is needed to see which hosts needs to be configured
How do you add a constraint on a join table in active_scaffold? Currently it does this, which is simple:
:constraints => { :hostgroup_id => nil}
Martin Englund wrote:
How do you add a constraint on a join table in active_scaffold? Currently it does this, which is simple:
[...]
try:
:constraints => { :host => { :puppetclasses => nil} }
Ohad Levy wrote:
try:
:constraints => { :host => { :puppetclasses => nil} }
That generates a SQL query with a WHERE clause like this:
WHERE hosts_puppetclasses.puppetclass_id IS NULL
which is always going to return an empty list.
I think I'll have to create a custom SQL query to pick out the host.id for unconfigured hosts, and then pass it to the active_scaffold constraints clause.
I think that its possible with named_scope, I'll play with it later on today
Ohad Levy wrote:
I think that its possible with named_scope, I'll play with it later on today
one option would be do to something like this:
#all hosts which have no classes defined:
named_scope :classless, :include => :puppetclasses, :conditions => {'hosts_puppetclasses.host_id' => nil }
#all hosts which do not belong to a group
named_scope :groupless, :include => :hostgroup, :conditions => { 'hostgroups.id' => nil }
than you could play with it - e.g.:
Host.classless.groupless > all hosts which are unconfigured
Host.classless.groupless.count > count all hosts which are unconfigured in an SQL friendly way.
Hopes this helps
any update on this ticket?
thanks
- Status changed from New to Rejected
Also available in: Atom
PDF