Method: Rbeapi::Netdev::Snmp#parse_snmp_users
- Defined in:
- lib/rbeapi/netdev/snmp.rb
#parse_snmp_users(text) ⇒ Array<Hash<Symbol,Object>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
parse_snmp_users takes the text output from the ‘show snmp user` EAPI command and parses the text into structured data suitable for use as a resource has to the provider initializer method.
“‘
User name : jeff Security model : v3 Engine ID : f5717f00420008177800 Authentication : SHA Privacy : AES-128 Group : developers
User name : nigel Security model : v2c Group : sysops (not configured)
User name : nigel Security model : v3 Engine ID : f5717f00420008177800 Authentication : SHA Privacy : AES-128 Group : sysops “‘
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/rbeapi/netdev/snmp.rb', line 241 def parse_snmp_users(text) text.split("\n\n").map do |user_s| user_s.scan(/^(\w+).*?: (.*)/).each_with_object({}) do |(h, v), m| key = SNMP_USER_PARAM[h.downcase.intern] || h.downcase.intern m[key] = case key when :privacy then v =~ /AES/ ? :aes128 : :des when :version then v.sub('v2c', 'v2').intern when :auth then v.downcase.intern when :roles then v.sub(/ \(.*?\)/, '') else v.downcase end end end end |