Class: Proxy::Onboard::BMC::BaseScanner
- Inherits:
-
Object
- Object
- Proxy::Onboard::BMC::BaseScanner
- Defined in:
- lib/bmc/basescanner.rb
Overview
This is the interface for scanning BMC IP address ranges.
Direct Known Subclasses
Instance Method Summary collapse
- #error_string ⇒ Object
-
#initialize(args = {}) ⇒ BaseScanner
constructor
A new instance of BaseScanner.
- #max_range_size ⇒ Object
-
#scan_to_list ⇒ Object
Run the scanner and return results as array.
- #valid? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ BaseScanner
Returns a new instance of BaseScanner.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bmc/basescanner.rb', line 9 def initialize(args = {}) if args.key? :address_first address_first = IPAddr.new args[:address_first] address_last = IPAddr.new args[:address_last] @range = (address_first..address_last) elsif args.key?(:address) && args.key?(:netmask) @range = IPAddr.new("#{args[:address]}/#{args[:netmask]}").to_range else @range = IPAddr.new(args[:address]).to_range end # Disallow range too large scanner_max_range_size = max_range_size if @range.first(scanner_max_range_size + 1).size > scanner_max_range_size @range = nil @invalid_reason = "Range too large. Batch supports only #{scanner_max_range_size} IP addresses at a time." end rescue StandardError @range = nil @invalid_reason = if args.is_a?(Hash) && args.key?(:address) 'Invalid CIDR provided' else 'Invalid IP address provided' end end |
Instance Method Details
#error_string ⇒ Object
38 39 40 |
# File 'lib/bmc/basescanner.rb', line 38 def error_string @invalid_reason end |
#max_range_size ⇒ Object
42 43 44 |
# File 'lib/bmc/basescanner.rb', line 42 def max_range_size Proxy::Onboard::Plugin.settings.bmc_scanner_max_range_size || 65_536 end |
#scan_to_list ⇒ Object
Run the scanner and return results as array
47 48 49 |
# File 'lib/bmc/basescanner.rb', line 47 def scan_to_list raise NotImplementedError end |
#valid? ⇒ Boolean
34 35 36 |
# File 'lib/bmc/basescanner.rb', line 34 def valid? @range.is_a? Range end |