Class: Nexpose::SiteListing
- Inherits:
-
Object
- Object
- Nexpose::SiteListing
- Defined in:
- lib/nexpose.rb
Overview
Description
Object that represents a listing of all of the sites available on an NSC.
Example
# Create a new Nexpose Connection on the default port and Login
nsc = Connection.new("10.1.40.10","nxadmin","password")
nsc->login();
# Get Site Listing
sitelisting = SiteListing.new(nsc)
# Enumerate through all of the SiteSummaries
sitelisting.sites.each do |sitesummary|
# Do some operation on each site
end
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
The NSC Connection associated with this object.
-
#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_count ⇒ Object
readonly
The number of sites.
-
#sites ⇒ Object
readonly
Array containing SiteSummary objects for each site in the connection.
Instance Method Summary collapse
-
#initialize(connection) ⇒ SiteListing
constructor
Constructor SiteListing (connection).
- #parse(r) ⇒ Object
Constructor Details
#initialize(connection) ⇒ SiteListing
Constructor SiteListing (connection)
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
# File 'lib/nexpose.rb', line 1054 def initialize(connection) @sites = [] @connection = connection r = @connection.execute('<SiteListingRequest session-id="' + @connection.session_id.to_s + '"/>') if (r.success) parse(r.res) else raise APIError.new(r, "Failed to get site listing") end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
The NSC Connection associated with this object
1046 1047 1048 |
# File 'lib/nexpose.rb', line 1046 def connection @connection end |
#error ⇒ Object (readonly)
true if an error condition exists; false otherwise
1038 1039 1040 |
# File 'lib/nexpose.rb', line 1038 def error @error end |
#error_msg ⇒ Object (readonly)
Error message string
1040 1041 1042 |
# File 'lib/nexpose.rb', line 1040 def error_msg @error_msg end |
#request_xml ⇒ Object (readonly)
The last XML request sent by this object
1042 1043 1044 |
# File 'lib/nexpose.rb', line 1042 def request_xml @request_xml end |
#response_xml ⇒ Object (readonly)
The last XML response received by this object
1044 1045 1046 |
# File 'lib/nexpose.rb', line 1044 def response_xml @response_xml end |
#site_count ⇒ Object (readonly)
The number of sites
1050 1051 1052 |
# File 'lib/nexpose.rb', line 1050 def site_count @site_count end |
#sites ⇒ Object (readonly)
Array containing SiteSummary objects for each site in the connection
1048 1049 1050 |
# File 'lib/nexpose.rb', line 1048 def sites @sites end |
Instance Method Details
#parse(r) ⇒ Object
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/nexpose.rb', line 1068 def parse(r) r.elements.each('SiteListingResponse/SiteSummary') do |s| site_summary = SiteSummary.new( s.attributes['id'].to_s, s.attributes['name'].to_s, s.attributes['description'].to_s, s.attributes['riskfactor'].to_s ) @sites.push(site_summary) end @site_count = @sites.length end |