Class: Nexpose::SiteDeviceListing
- Inherits:
-
Object
- Object
- Nexpose::SiteDeviceListing
- Defined in:
- lib/nexpose/site.rb
Overview
Description
Object that represents a listing of devices for a site or the entire NSC. Note that only devices which are accessible to the account used to create the connection object will be returned. This object is created and populated automatically with the instantiation of a new Site object.
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
The NSC Connection associated with this object.
-
#devices ⇒ Object
readonly
//Array of (Device)*.
-
#error ⇒ Object
readonly
true if an error condition exists; false otherwise.
-
#error_msg ⇒ Object
readonly
Error message string.
-
#request_xml ⇒ Object
readonly
The last XML request sent by this object.
-
#response_xml ⇒ Object
readonly
The last XML response received by this object.
-
#site_id ⇒ Object
readonly
The Site ID.
Instance Method Summary collapse
-
#initialize(connection, site_id = 0) ⇒ SiteDeviceListing
constructor
A new instance of SiteDeviceListing.
Constructor Details
#initialize(connection, site_id = 0) ⇒ SiteDeviceListing
Returns a new instance of SiteDeviceListing.
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/nexpose/site.rb', line 547 def initialize(connection, site_id = 0) @site_id = site_id @error = false @connection = connection @devices = [] r = nil if (@site_id) r = @connection.execute('<SiteDeviceListingRequest session-id="' + connection.session_id + '" site-id="' + "#{@site_id}" + '"/>') if r.success r.res.elements.each('SiteDeviceListingResponse/SiteDevices/device') do |d| @devices.push(Device.new(d.attributes['id'], @site_id, d.attributes["address"], d.attributes["riskfactor"], d.attributes["riskscore"])) end end else r = @connection.execute('<SiteDeviceListingRequest session-id="' + connection.session_id + '"/>') if r.success r.res.elements.each('SiteDeviceListingResponse/SiteDevices') do |rr| @sid = rr.attribute("site-id") rr.elements.each('device') do |d| @devices.push(Device.new(d.attributes['id'], @sid, d.attributes["address"], d.attributes['riskfactor'], d.attributes['riskscore'])) end end end end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
541 542 543 |
# File 'lib/nexpose/site.rb', line 541 def connection @connection end |
#devices ⇒ Object (readonly)
//Array of (Device)*
545 546 547 |
# File 'lib/nexpose/site.rb', line 545 def devices @devices end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
533 534 535 |
# File 'lib/nexpose/site.rb', line 533 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
535 536 537 |
# File 'lib/nexpose/site.rb', line 535 def error_msg @error_msg end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
537 538 539 |
# File 'lib/nexpose/site.rb', line 537 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
539 540 541 |
# File 'lib/nexpose/site.rb', line 539 def response_xml @response_xml end |
#site_id ⇒ Object (readonly)
The Site ID. 0 if all sites are specified.
543 544 545 |
# File 'lib/nexpose/site.rb', line 543 def site_id @site_id end |