Method: Rbeapi::Api::Users#initialize

Defined in:
lib/rbeapi/api/users.rb

#initialize(node) ⇒ Users

Returns a new instance of Users.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rbeapi/api/users.rb', line 44

def initialize(node)
  super(node)
  # The regex used here parses the running configuration to find all
  # username entries. There is extra logic in the regular expression
  # to store the username as 'user' and then creates a back reference
  # to find a following configuration line that might contain the
  # users sshkey.
  @users_re = Regexp.new(/^username\s+(?<user>[^\s]+)\s+
                          privilege\s+(?<priv>\d+)
                          (\s+role\s+(?<role>\S+))?
                          (?:\s+(?<nopassword>(nopassword)))?
                          (\s+secret\s+(?<encryption>0|5|7|sha512)\s+
                          (?<secret>\S+))?.*$\n
                          (username\s+\k<user>\s+
                           sshkey\s+(?<sshkey>.*)$)?/x)

  @encryption_map = { 'cleartext' => '0',
                      'md5' => '5',
                      'sha512' => 'sha512' }
end