Class: Nexpose::EnginePool
- Inherits:
-
Object
- Object
- Nexpose::EnginePool
- Defined in:
- lib/nexpose/scan_engine.rb
Overview
Core objects for creating an engine pool Example usage:
pool = EnginePool.new('East Coast Pool')
pool.add('New York Engine')
pool.add('Georgia Engine')
pool.create(@nsc)
Instance Attribute Summary collapse
-
#engines ⇒ Object
Array containing (EngineSummary*).
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
-
#add(engine) ⇒ Object
Add an engine to the pool by name (not ID).
-
#create(connection) ⇒ Object
Creates a new engine pool, and adds scan engines to the pool.
-
#delete(connection) ⇒ Object
Deletes an engine pool.
-
#initialize(name, id = -1,, scope = 'silo') ⇒ EnginePool
constructor
A new instance of EnginePool.
-
#load_details(connection) ⇒ Object
Returns detailed information about a single engine pool.
- #to_s ⇒ Object
-
#update(connection) ⇒ Object
Updates a specific role with new information.
Constructor Details
#initialize(name, id = -1,, scope = 'silo') ⇒ EnginePool
Returns a new instance of EnginePool.
208 209 210 211 212 213 |
# File 'lib/nexpose/scan_engine.rb', line 208 def initialize(name, id = -1, scope = 'silo') @name = name @id = id @scope = scope @engines = [] end |
Instance Attribute Details
#engines ⇒ Object
Array containing (EngineSummary*)
206 207 208 |
# File 'lib/nexpose/scan_engine.rb', line 206 def engines @engines end |
#id ⇒ Object
Returns the value of attribute id.
202 203 204 |
# File 'lib/nexpose/scan_engine.rb', line 202 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
203 204 205 |
# File 'lib/nexpose/scan_engine.rb', line 203 def name @name end |
#scope ⇒ Object
Returns the value of attribute scope.
204 205 206 |
# File 'lib/nexpose/scan_engine.rb', line 204 def scope @scope end |
Instance Method Details
#add(engine) ⇒ Object
Add an engine to the pool by name (not ID). Only use this for creating pools.
217 218 219 |
# File 'lib/nexpose/scan_engine.rb', line 217 def add(engine) @engines << EngineSummary.new(-1, engine, 'nowhere', 40814, 'unknown') end |
#create(connection) ⇒ Object
Creates a new engine pool, and adds scan engines to the pool.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/nexpose/scan_engine.rb', line 222 def create(connection) xml = '<EnginePoolCreateRequest session-id="' + connection.session_id + '">' xml << %Q{<EnginePool name="#@name" scope="#@scope">} @engines.each do |engine| xml << %Q{<Engine name="#{engine.name}" />} end xml << '</EnginePool>' xml << '</EnginePoolCreateRequest>' r = connection.execute(xml, '1.2') if r.success r.res.elements.each('EnginePoolCreateResponse') do |v| @id = v.attributes['id'] end else @error = true @error_msg = 'EnginePoolCreateResponse Parse Error' end end |
#delete(connection) ⇒ Object
Deletes an engine pool
243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/nexpose/scan_engine.rb', line 243 def delete(connection) xml = '<EnginePoolDeleteRequest session-id="' + connection.session_id + '">' xml << %Q{<EnginePool name="#@name" scope="#@scope" />} xml << '</EnginePoolDeleteRequest>' r = connection.execute(xml, '1.2') unless r.success @error = true @error_msg = 'EnginePoolDeleteResponse Parse Error' end end |
#load_details(connection) ⇒ Object
Returns detailed information about a single engine pool.
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/nexpose/scan_engine.rb', line 280 def load_details(connection) xml = '<EnginePoolDetailsRequest session-id="' + connection.session_id + '">' xml << %Q{<EnginePool name="#@name" scope="#@scope" />} xml << '</EnginePoolDetailsRequest>' r = connection.execute(xml, '1.2') if r.success r.res.elements.each('EnginePoolDetailsResponse/EnginePool') do |pool| @id = pool.attributes['id'] @name = pool.attributes['name'] @scope = pool.attributes['scope'] @engines = [] r.res.elements.each('EnginePoolDetailsResponse/EnginePool/EngineSummary') do |summary| @engines.push(EngineSummary.new(summary.attributes['id'], summary.attributes['name'], summary.attributes['address'], summary.attributes['port'], summary.attributes['status'], summary.attributes['scope'])) end end else @error = true @error_msg = 'EnginePoolListingResponse Parse Error' end end |
#to_s ⇒ Object
307 308 309 |
# File 'lib/nexpose/scan_engine.rb', line 307 def to_s "Engine Pool: #@name [ID: #@id], Scope: #@scope\n" + @engines.map { |engine| " #{engine}" }.join("\n") end |
#update(connection) ⇒ Object
Updates a specific role with new information. An EnginePoolUpdate is similar to an EnginePoolCreate, except that an EnginePoolUpdate replaces any previously existing information with the new information specified in the EnginePoolUpdateRequest.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/nexpose/scan_engine.rb', line 259 def update(connection) xml = '<EnginePoolUpdateRequest session-id="' + connection.session_id + '">' xml << %Q{<EnginePool id="#@id" name="#@name" scope="#@scope">} @engines.each do |engine| xml << %Q{<Engine name="#{engine.name}" />} end xml << '</EnginePool>' xml << '</EnginePoolUpdateRequest>' r = connection.execute(xml, '1.2') if r.success r.res.elements.each('EnginePoolUpdateResponse') do |v| @id = v.attributes['id'] end else @error = true @error_msg = 'EnginePoolCreateResponse Parse Error' end end |