Project

General

Profile

Feature #97

Need view for unconfigured hosts

Added by Martin Englund over 9 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Normal
Category:
Host creation
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When you point existing systems to foreman a special view is needed to see which hosts needs to be configured

History

#2 Updated by Martin Englund over 9 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}

#3 Updated by Ohad Levy over 9 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} }

#4 Updated by Martin Englund over 9 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.

#5 Updated by Ohad Levy over 9 years ago

I think that its possible with named_scope, I'll play with it later on today

#6 Updated by Ohad Levy over 9 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

#7 Updated by Ohad Levy over 9 years ago

any update on this ticket?

thanks

#8 Updated by Ohad Levy over 8 years ago

  • Status changed from New to Rejected

Also available in: Atom PDF