class Nexpose::EnginePool

Engine pool configuration object.

Attributes

engines[RW]

Array containing (EngineSummary*) for each engine assigned to the pool.

id[RW]

Unique identifier of the engine pool.

name[RW]

Name of the engine pool.

scope[RW]

Whether the engine pool has global or silo scope.

Public Class Methods

load(connection, name, scope = 'silo') click to toggle source

Returns detailed information about a single engine pool.

@param [Connection] connection Connection to console where site exists. @param [String] name The name of the engine pool. @param [String] scope The silo of the engine pool. @return [EnginePool] Engine pool configuration object.

# File lib/nexpose/pool.rb, line 101
def self.load(connection, name, scope = 'silo')
  xml = %(<EnginePoolDetailsRequest session-id="#{connection.session_id}">)
  xml << %(<EnginePool name="#{name}" scope="#{scope}"/>)
  xml << '</EnginePoolDetailsRequest>'
  r = connection.execute(xml, '1.2')
  if r.success
    r.res.elements.each('EnginePoolDetailsResponse/EnginePool') do |pool|
      config = EnginePool.new(pool.attributes['name'],
                              pool.attributes['scope'],
                              pool.attributes['id'].to_i)
      r.res.elements.each('EnginePoolDetailsResponse/EnginePool/EngineSummary') do |summary|
        config.engines << EngineSummary.new(summary.attributes['id'].to_i,
                                            summary.attributes['name'],
                                            summary.attributes['address'],
                                            summary.attributes['port'].to_i,
                                            summary.attributes['status'],
                                            summary.attributes['scope'])
      end
      return config
    end
  end
  nil
end
new(name, scope = 'silo', id = -1) click to toggle source
# File lib/nexpose/pool.rb, line 76
def initialize(name, scope = 'silo', id = -1)
  @name    = name
  @scope   = scope
  @id      = id.to_i
  @engines = []
end

Public Instance Methods

add(engine_name) click to toggle source

Add an engine to the pool by name (not ID).

EngineSummary objects should just be appended to the pool directly,

e.g., pool.engines << nsc.engines.find { |e| e.name == 'Cleveland' }

@param [String] engine_name Name used to identify a paired scan engine.

# File lib/nexpose/pool.rb, line 90
def add(engine_name)
  @engines << EngineSummary.new(-1, engine_name, nil, 40814, nil)
end
delete(connection) click to toggle source

Deletes an engine pool

@param [Connection] connection Connection to console where site exists.

# File lib/nexpose/pool.rb, line 153
def delete(connection)
  xml = %(<EnginePoolDeleteRequest session-id="#{connection.session_id}">)
  xml << %(<EnginePool name="#{@name}" scope="#{@scope}" />)
  xml << '</EnginePoolDeleteRequest>'

  r = connection.execute(xml, '1.2')
  r.success
end
save(connection) click to toggle source

Save an engine pool to a security console.

@param [Connection] connection Connection to console where site exists.

# File lib/nexpose/pool.rb, line 129
def save(connection)
  request = @id > 0 ? 'EnginePoolUpdateRequest' : 'EnginePoolCreateRequest'
  xml = %(<#{request} session-id="#{connection.session_id}">)
  xml << '<EnginePool'
  xml << %( id="#{@id}") if @id > 0
  xml << %( name="#{@name}" scope="#{@scope}">)
  @engines.each do |engine|
    xml << %(<Engine name="#{engine.name}" />)
  end
  xml << '</EnginePool>'
  xml << %(</#{request}>)

  r = connection.execute(xml, '1.2')
  if r.success
    r.res.elements.each(request.gsub('Request', 'Response')) do |v|
      return @id = v.attributes['id'].to_i
    end
  end
end