Users¶
API Module for working with EOS local user resources
The Users resource provides configuration of local user resources for an EOS node.
- param username
The username parameter maps to the local username defined in the running-config.
- type username
string
- param nopassword
Configures the username to use no password at login. This parameter is mutually exclusive with secret
- type nopassword
boolean
- param privilege
Configures the user privilege level in EOS
- type privilege
integer
- param role
Configures the users role in EOS
- type role
string
- param secret
Configures the users secret (password) to use at login. This parameter is mutually exclusive with secret and is used in conjunction with format.
- type secret
string
- param format
Configures the format of the secret value. Accepted values for format are “cleartext”, “md5” and “sha512”
- type format
string
- class pyeapi.api.users.Users(node)[source]¶
Bases:
pyeapi.api.abstract.EntityCollection
The Users class provides a configuration resource for local users. The regex used here parses the running configuration to find username entries. There is extra logic in the regular expression to store the username as ‘user’ and then creates a backreference to find a following configuration line that might contain the users sshkey.
- create(name, nopassword=None, secret=None, encryption=None)[source]¶
Creates a new user on the local system.
Creating users requires either a secret (password) or the nopassword keyword to be specified.
- Parameters
name (str) – The name of the user to craete
nopassword (bool) – Configures the user to be able to authenticate without a password challenage
secret (str) – The secret (password) to assign to this user
encryption (str) – Specifies how the secret is encoded. Valid values are “cleartext”, “md5”, “sha512”. The default is “cleartext”
- Returns
True if the operation was successful otherwise False
- Raises
TypeError – if the required arguments are not satisfied
- create_with_nopassword(name)[source]¶
Creates a new user on the local node
- Parameters
name (str) – The name of the user to create
- Returns
True if the operation was successful otherwise False
- create_with_secret(name, secret, encryption)[source]¶
Creates a new user on the local node
- Parameters
name (str) – The name of the user to craete
secret (str) – The secret (password) to assign to this user
encryption (str) – Specifies how the secret is encoded. Valid values are “cleartext”, “md5”, “sha512”. The default is “cleartext”
- Returns
True if the operation was successful otherwise False
- default(name)[source]¶
Configures the local username using the default keyword
- Parameters
name (str) – The name of the user to configure
- Returns
True if the operation was successful otherwise False
- delete(name)[source]¶
Deletes the local username from the config
- Parameters
name (str) – The name of the user to delete
- Returns
True if the operation was successful otherwise False
- get(name)[source]¶
Returns the local user configuration as a resource dict
- Parameters
name (str) – The username to return from the nodes global running- config.
- Returns
A resource dict object
If the name does not exist, then None is returned
- Return type
dict
- getall()[source]¶
Returns all local users configuration as a resource dict
- Returns
A dict of usernames with a nested resource dict object
- Return type
dict
- set_privilege(name, value=None)[source]¶
Configures the user privilege value in EOS
- Parameters
name (str) – The name of the user to craete
value (int) – The privilege value to assign to the user. Valid values are in the range of 0 to 15
- Returns
True if the operation was successful otherwise False
- Raises
TypeError – if the value is not in the valid range
- set_role(name, value=None, default=False, disable=False)[source]¶
Configures the user role vale in EOS
- Parameters
name (str) – The name of the user to create
value (str) – The value to configure for the user role
default (bool) – Configure the user role using the EOS CLI default command
disable (bool) – Negate the user role using the EOS CLI no command
- Returns
True if the operation was successful otherwise False
- set_sshkey(name, value=None, default=False, disable=False)[source]¶
Configures the user sshkey
- Parameters
name (str) – The name of the user to add the sshkey to
value (str) – The value to configure for the sshkey.
default (bool) – Configure the sshkey using the EOS CLI default command
disable (bool) – Negate the sshkey using the EOS CLI no command
- Returns
True if the operation was successful otherwise False
- pyeapi.api.users.instance(node)[source]¶
Returns an instance of Users
This method will create and return an instance of the Users object passing the value of API to the object. The instance method is required for the resource to be autoloaded by the Node object
- Parameters
node (Node) – The node argument passes an instance of Node to the resource