Method: Cisco::Node#config_get
- Defined in:
- lib/cisco_node_utils/node.rb
#config_get(feature, name, *args) ⇒ String, ...
Convenience wrapper for show(command, :structured). Uses CommandReference to look up the given show command and key of interest, executes that command, and returns the value corresponding to that key.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cisco_node_utils/node.rb', line 69 def config_get(feature, name, *args) fail 'lazy_connect specified but did not request connect' unless @cmd_ref ref = @cmd_ref.lookup(feature, name) return ref.default_value if ref.default_only? begin token = ref.config_get_token(*args) rescue IndexError # IndexError: no entry for config_get_token token = nil end if token.nil? # Just get the whole output return massage(show(ref.config_get, :structured), ref) elsif token[0].kind_of?(Regexp) return massage(Cisco.find_ascii(show(ref.config_get, :ascii), token[-1], *token[0..-2]), ref) else return massage( config_get_handle_structured(token, show(ref.config_get, :structured)), ref) end end |