Class: Nexpose::SiteDeviceListing

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose.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

Instance Method Summary collapse

Constructor Details

#initialize(connection, site_id = 0) ⇒ SiteDeviceListing

Returns a new instance of SiteDeviceListing.



892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
# File 'lib/nexpose.rb', line 892

def initialize(connection, site_id = 0)

	@site_id = site_id
	@error = false
	@connection = connection
	@devices = Array.new()

	r = nil
	if (@site_id)
		r = @connection.execute('<SiteDeviceListingRequest session-id="' + connection.session_id + '" site-id="' + @site_id + '"/>')
	else
		r = @connection.execute('<SiteDeviceListingRequest session-id="' + connection.session_id + '"/>')
	end

	if(r.success)
		response.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
end

Instance Attribute Details

#connectionObject (readonly)

The NSC Connection associated with this object



886
887
888
# File 'lib/nexpose.rb', line 886

def connection
  @connection
end

#devicesObject (readonly)

//Array of (Device)*



890
891
892
# File 'lib/nexpose.rb', line 890

def devices
  @devices
end

#errorObject (readonly)

true if an error condition exists; false otherwise



878
879
880
# File 'lib/nexpose.rb', line 878

def error
  @error
end

#error_msgObject (readonly)

Error message string



880
881
882
# File 'lib/nexpose.rb', line 880

def error_msg
  @error_msg
end

#request_xmlObject (readonly)

The last XML request sent by this object



882
883
884
# File 'lib/nexpose.rb', line 882

def request_xml
  @request_xml
end

#response_xmlObject (readonly)

The last XML response received by this object



884
885
886
# File 'lib/nexpose.rb', line 884

def response_xml
  @response_xml
end

#site_idObject (readonly)

The Site ID. 0 if all sites are specified.



888
889
890
# File 'lib/nexpose.rb', line 888

def site_id
  @site_id
end