Essentially, there is a Hosts class which belongs_to Hostgroup and Hostgroup class has a column called 'ancestry' which is actually a Hostgroup (probably what is referred to as STI but I am not sure) and thus within Foreman, nesting Hostgroups is not uncommon.
Thus I could have a Host that is called "ServerA", that belongs to "WebServer" Hostgroup which has an ancestry (Hostgroup) called "Base" and for me to find out all of the puppetclasses that host "ServerA" belongs to, I would have to get a listing of all of the puppetclasses within the chain of Hostgroups to which ServerA belongs.
So this is my code...
@hosts.each do |host|
@ancestors = Hostgroup.find(host.hostgroup.ancestry) unless host.hostgroup.ancestry == nil
@ancestors.puppetclasses.each do |anc|
@my_classes[anc.name] += 1
And this works for me because I am only nesting 1 level but it's conceivable that other users would nest many more levels and if my patch is to be accepted, I undoubtedly have to account for an infinite level of nesting.
How would I accomplish that?
Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ firstname.lastname@example.org
1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com
Need help communicating between generations at work to achieve your desired success? Let us help!
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.