C0 code coverage information generated on Wed Mar 15 10:52:00 MST 2006
Marked code looks like this.
This line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this.
Finally, here's a line marked as not executed.
1 #! /usr/bin/ruby
2
3 # == Usage
4 #
5 # serialnumb.rb [ -h | --help ] [ -v | --verbose ] <input>.psv
6 #
7 # == Author
8 # Jared Harper
9
10 require 'rdoc/usage'
11 require 'getoptlong'
12 require 'rubygems'
13 require 'psvparse'
14 require 'ping'
15 require_gem 'net-ssh'
16
17 @verbose = false
18 @remote_user = 'build'
19
20 class SerialNumberHosts
21 attr_reader :hosts, :parser
22
23 class Host
24 attr_reader :make, :ip, :serial_number
25
26 def initialize(make, ip, serial_number)
27 @make = make
28 @ip = ip
29 @serial_number = serial_number
30 end
31
32 def to_s
33 "#{@make}|#{@ip}|#{@serial_number}"
34 end
35
36 end
37
38 def initialize(file)
39 @hosts = Array.new
40 @parser = PSVParse.new(file)
41
42 psvHost = @parser.search(
43 {:search_term => 'HOST_NAME',
44 :search_field => :host_name,
45 :result_field => :all,
46 :negated => true})
47 psvHost.each do |row|
48 if (row[:make] and
49 (row[:make].casecmp('dell') == 0 or row[:make].casecmp('hp') == 0))
50 @hosts.push(Host.new(row[:make], row[:ip], row[:serial_number]))
51 end
52 end
53 end
54
55 end
56
57 ###################### main ####################
58
59 if __FILE__ == $0
60 opts = GetoptLong.new(
61 ["--verbose", "-v", GetoptLong::NO_ARGUMENT],
62 ["--help", "-h", GetoptLong::NO_ARGUMENT])
63 opts.each do |opt, arg|
64 case opt
65 when '--verbose' then
66 @verbose = true
67 when '--help'
68 RDoc::usage
69 end
70 end
71 filename = ARGV.join(' ')
72
73 hosts = SerialNumberHosts.new(filename)
74 hosts.hosts.each do |host|
75 if ((host.make.casecmp('dell') == 0) or
76 (host.make.casecmp('hp') == 0))
77 err = `ping -q -c 1 -W 1 #{host.ip}`
78 if !$?
79 puts host
80 else
81 puts "#{host} not reachable"
82 end
83 end
84 end
85 end
86
87 # vim:ts=2:sw=2:sts=2:et

