Feature #97
closedNeed view for unconfigured hosts
Description
When you point existing systems to foreman a special view is needed to see which hosts needs to be configured
Updated by Martin Englund almost 15 years ago
How do you add a constraint on a join table in active_scaffold? Currently it does this, which is simple:
:constraints => { :hostgroup_id => nil}
Updated by Ohad Levy almost 15 years ago
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} }
Updated by Martin Englund almost 15 years ago
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.
Updated by Ohad Levy almost 15 years ago
I think that its possible with named_scope, I'll play with it later on today
Updated by Ohad Levy almost 15 years ago
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