Class: Nexpose::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose-functions.rb

Instance Method Summary collapse

Instance Method Details

#load_csv_hostnames(nsc, csvfile) ⇒ Object

Load asset hostnames from a CSV file.

Parameters:

  • nsc (Connection)

    an active connection to a Nexpose console.

  • csvfile (String)

    path to a CSV file to load hostnames from. (The first column will be used.)



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/nexpose-functions.rb', line 133

def load_csv_hostnames(nsc, csvfile)
    puts "Loading site..."
    @site = Site.load(@nsc, self.id)

    puts "Building hostname/asset list..."
    @hostnames = []
    CSV.foreach(@csvfile) do |line|
        @hostnames << HostName.new(line[0])
    end

    puts "Saving site assets..."
    @site.included_addresses = @hostnames
    @site.save(@nsc)
    puts "Done."
    puts "Site #{self.id} now has #{@hostnames.length} assets."
end