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.



1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
# File 'lib/nexpose.rb', line 1369

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



1363
1364
1365
# File 'lib/nexpose.rb', line 1363

def connection
  @connection
end

#devicesObject (readonly)

//Array of (Device)*



1367
1368
1369
# File 'lib/nexpose.rb', line 1367

def devices
  @devices
end

#errorObject (readonly)

true if an error condition exists; false otherwise



1355
1356
1357
# File 'lib/nexpose.rb', line 1355

def error
  @error
end

#error_msgObject (readonly)

Error message string



1357
1358
1359
# File 'lib/nexpose.rb', line 1357

def error_msg
  @error_msg
end

#request_xmlObject (readonly)

The last XML request sent by this object



1359
1360
1361
# File 'lib/nexpose.rb', line 1359

def request_xml
  @request_xml
end

#response_xmlObject (readonly)

The last XML response received by this object



1361
1362
1363
# File 'lib/nexpose.rb', line 1361

def response_xml
  @response_xml
end

#site_idObject (readonly)

The Site ID. 0 if all sites are specified.



1365
1366
1367
# File 'lib/nexpose.rb', line 1365

def site_id
  @site_id
end