Method: Rbeapi::Client::Node#get_config
- Defined in:
- lib/rbeapi/client.rb
#get_config(opts = {}) ⇒ String
This method will retrieve the specified configuration from the node and return it in full text.
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/rbeapi/client.rb', line 513 def get_config(opts = {}) config = opts.fetch(:config, 'running-config') params = opts.fetch(:params, '') encoding = opts.fetch(:encoding, 'text') as_string = opts.fetch(:as_string, false) begin result = run_commands("show #{config} #{params}", encoding: encoding) rescue Rbeapi::Eapilib::CommandError => error # rubocop:disable Style/GuardClause if error.to_s =~ /'show (running|startup)-config'/ return nil else raise error end # rubocop:enable Style/GuardClause end if encoding == 'json' # rubocop:disable Style/GuardClause return result.first else return result.first['output'].strip.split("\n") unless as_string result.first['output'].strip end end |