From: <jh...@us...> - 2009-09-23 01:02:30
|
Revision: 98 http://etch.svn.sourceforge.net/etch/?rev=98&view=rev Author: jheiss Date: 2009-09-23 01:02:24 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Add etch_to_trunk to package. This is a tool for setting the config_mgmt_tag in nVentory to trunk-YYYYMMDD-HH00 for etch clients to temporarily bump them to trunk. Modified Paths: -------------- trunk/client/Makefile trunk/client/etch-client.spec Added Paths: ----------- trunk/client/etch_to_trunk Modified: trunk/client/Makefile =================================================================== --- trunk/client/Makefile 2009-09-23 00:58:08 UTC (rev 97) +++ trunk/client/Makefile 2009-09-23 01:02:24 UTC (rev 98) @@ -19,6 +19,8 @@ mkdir -p $(BUILDROOT)/usr/sbin cp -p etch $(BUILDROOT)/usr/sbin chmod 555 $(BUILDROOT)/usr/sbin/etch + cp -p etch_to_trunk $(BUILDROOT)/usr/sbin + chmod 555 $(BUILDROOT)/usr/sbin/etch_to_trunk mkdir -p $(BUILDROOT)/usr/lib/ruby/site_ruby/1.8 cp -p etch.rb $(BUILDROOT)/usr/lib/ruby/site_ruby/1.8 chmod 444 $(BUILDROOT)/usr/lib/ruby/site_ruby/1.8/etch.rb @@ -48,6 +50,8 @@ mkdir -p $(BUILDROOT)/usr/sbin cp -p etch $(BUILDROOT)/usr/sbin chmod 555 $(BUILDROOT)/usr/sbin/etch + cp -p etch_to_trunk $(BUILDROOT)/usr/sbin + chmod 555 $(BUILDROOT)/usr/sbin/etch_to_trunk mkdir -p $(BUILDROOT)/usr/local/lib/site_ruby/1.8 cp -p etch.rb $(BUILDROOT)/usr/local/lib/site_ruby/1.8 chmod 444 $(BUILDROOT)/usr/local/lib/site_ruby/1.8/etch.rb @@ -75,6 +79,11 @@ cat $(BUILDROOT)/usr/sbin/etch.tmp | sed 's,/usr/bin/ruby,/opt/csw/bin/ruby,' > $(BUILDROOT)/usr/sbin/etch rm $(BUILDROOT)/usr/sbin/etch.tmp chmod 555 $(BUILDROOT)/usr/sbin/etch + cp -p etch_to_trunk $(BUILDROOT)/usr/sbin + mv $(BUILDROOT)/usr/sbin/etch_to_trunk $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp + cat $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp | sed 's,/usr/bin/ruby,/opt/csw/bin/ruby,' > $(BUILDROOT)/usr/sbin/etch_to_trunk + rm $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp + chmod 555 $(BUILDROOT)/usr/sbin/etch_to_trunk mkdir -p $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8 cp -p etch.rb $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8 chmod 444 $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8/etch.rb @@ -115,6 +124,8 @@ # our library file (etch.rb) into /opt/csw. We modify etch to use # the Sunfreeware ruby in /usr/local/bin, but then tell it to also look # in the /opt/csw directory for libraries. +# I'm going to guess that the smaller utilities like etch_to_trunk won't have +# problems, so I'm leaving them set to /opt/csw/bin/ruby. sysvpkg-sparc: pkginfo depend # # Create package file structure in build root @@ -130,6 +141,11 @@ cat $(BUILDROOT)/usr/sbin/etch.tmp | awk '/unshift.*__FILE__/ {print "$$:.unshift \"/opt/csw/lib/ruby/site_ruby/1.8\"\n" $$0; next}; {print}' > $(BUILDROOT)/usr/sbin/etch rm $(BUILDROOT)/usr/sbin/etch.tmp chmod 555 $(BUILDROOT)/usr/sbin/etch + cp -p etch_to_trunk $(BUILDROOT)/usr/sbin + mv $(BUILDROOT)/usr/sbin/etch_to_trunk $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp + cat $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp | sed 's,/usr/bin/ruby,/opt/csw/bin/ruby,' > $(BUILDROOT)/usr/sbin/etch_to_trunk + rm $(BUILDROOT)/usr/sbin/etch_to_trunk.tmp + chmod 555 $(BUILDROOT)/usr/sbin/etch_to_trunk mkdir -p $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8 cp -p etch.rb $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8 chmod 444 $(BUILDROOT)/opt/csw/lib/ruby/site_ruby/1.8/etch.rb Modified: trunk/client/etch-client.spec =================================================================== --- trunk/client/etch-client.spec 2009-09-23 00:58:08 UTC (rev 97) +++ trunk/client/etch-client.spec 2009-09-23 01:02:24 UTC (rev 98) @@ -13,6 +13,7 @@ %files %defattr(-,root,root) /usr/sbin/etch +/usr/sbin/etch_to_trunk /usr/lib/ruby/site_ruby/1.8/etch.rb /etc/etch /usr/sbin/etch_cron_wrapper Added: trunk/client/etch_to_trunk =================================================================== --- trunk/client/etch_to_trunk (rev 0) +++ trunk/client/etch_to_trunk 2009-09-23 01:02:24 UTC (rev 98) @@ -0,0 +1,45 @@ +#!/usr/bin/ruby -w + +require 'nventory' + +@username = ENV['LOGNAME'] + +if ARGV.length == 0 + abort "Usage: #{File.basename($0)} <server1> [<server2> <server3>]" +end + +# The etch servers run in UTC +ENV['TZ'] = 'UTC' +currentheadtag = Time.now.strftime('trunk-%Y%m%d-%H00') + +# Find the requested clients +nvclient = NVentory::Client.new +results = nvclient.get_objects('nodes', {}, { 'name' => ARGV }, {}, {}) +ARGV.each do |name| + if results.empty? && results[name].nil? + abort "No entry found for #{name}" + else + if !results[name]['config_mgmt_tag'].nil? && + !results[name]['config_mgmt_tag'].empty? + puts "Changing #{name} from #{results[name]['config_mgmt_tag']} to #{currentheadtag}" + else + puts "Setting #{name} to #{currentheadtag}" + end + end +end + +while true + print "Proceed? [y|n] " + response = $stdin.gets.chomp + if response == 'y' + break + elsif response == 'n' + exit + end +end + +# Update the clients +successcount = nvclient.set_objects('nodes', results, {'config_mgmt_tag' => currentheadtag}, @username) + +puts "#{File.basename($0)} operation succeeded for #{successcount} of #{results.size} nodes" + Property changes on: trunk/client/etch_to_trunk ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |