Method: Rbeapi::Netdev::Snmp#snmp_user_password_hash

Defined in:
lib/rbeapi/netdev/snmp.rb

#snmp_user_password_hash(running_config, user_cmd) ⇒ Hash<Symbol,String>

snmp_user_password obtains the password hash from the device in order to provide an idempotent configuration value.

Parameters:

  • The text of the current running configuration.

  • The prefix of the command that identifies the user in the running-config. e.g. (‘snmp-server user jeff developers v3’)

Returns:

  • The hashes for :auth and :privacy



356
357
358
359
360
# File 'lib/rbeapi/netdev/snmp.rb', line 356

def snmp_user_password_hash(running_config, user_cmd)
  regexp = /#{user_cmd} .*?auth \w+\s+(.*?)\s+priv \w+\s+(.*?)\s/
  (auth_hash, priv_hash) = running_config.scan(regexp).first
  { auth: auth_hash, privacy: priv_hash }
end