Created
June 22, 2009 08:16
-
-
Save sheldonh/133866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/models/hos_server.rb | |
=================================================================== | |
--- app/models/hos_server.rb (revision 554) | |
+++ app/models/hos_server.rb (working copy) | |
@@ -8,6 +8,8 @@ | |
# to be able to use the rails reserved word 'type' as a column name. | |
self.inheritance_column = nil | |
+ alias_attribute :status, "Status" | |
+ | |
# named_scope :named, lambda {|name| {:conditions => {:server => name}}} | |
named_scope :active_sa, lambda { {:select => "DISTINCT(server)",:conditions => ["`belongs-to` = 'sa' and Status = 'Active' and distribution = 'Debian'",]}} | |
named_scope :hos_server_fields, lambda { {:select => "server,backupserver,allowupdates,`second-ns` AS secondns,`ups-shutdown` AS upsshutdown,location, | |
Index: script/scriptlet/hos_server_compare.rb | |
=================================================================== | |
--- script/scriptlet/hos_server_compare.rb (revision 557) | |
+++ script/scriptlet/hos_server_compare.rb (working copy) | |
@@ -15,7 +15,7 @@ | |
puppethost = {} | |
HosServer.active_sa.each do |host| | |
unless ignored?(host.server) | |
- hosserver[host.server] = :exists | |
+ hosserver[host.server] = host.status | |
end | |
end | |
Host.find(:all).each do |host| | |
@@ -36,8 +36,10 @@ | |
puppethost.each do |host, created_at| | |
unless hosserver.include?(host) | |
- age = ActionController::Base.helpers.time_ago_in_words(created_at) | |
- puts "#{host} should not be in puppet (first seen #{age} ago)" | |
+ if hosserver[host].status == "Inactive" | |
+ Host.find_by_name(host).destroy | |
+ end | |
+ puts "#{host} removed from puppet" | |
problem_count += 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment