database.client.users¶
Mixin class for databse client with user related functions
- class accre.database.client.users.DBClientUserMixin[source]¶
Bases:
object
Functionality related to ACCRE cluster users
- activate_user(vunetid, reason=None, log_date=None)[source]¶
(Re)Activate the user in the Database. Note that this does not activate a user in LDAP, but simply marks a user as one that should currently have access. A reason string is required.
- Parameters:
vunetid (str) – User to be activated
reason (str) – Reason for activation. Cite a ticket if possible.
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- add_secondary_groups(vunetid, *groups, log_date=None)[source]¶
Add specified secondary groups to a cluster user
- Parameters:
vunetid (str) – user to add to secondary group(s)
groups (str) – Groups to add the user to
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- add_user(*, vunetid, user_id, group, email, first_name, last_name, attended_unix=False, attended_cluster=False, attended_slurm=False, active=True, join_date=None)[source]¶
Add a new ACCRE user to the database
- Parameters:
vunetid (str) – vunetid of the user, should match Vanderbilt LDAP
user_id (int) – UID of the new user, should match Vanderbilt LDAP
group (str) – Primary group name of the new user
email (str) – email address of the new user, matching Vandy LDAP
first_name (str) – first name of the new user
last_name (str) – last name of the new user
attended_unix (bool) – attendence for the intro unix course
attended_cluster (bool) – attendence for the intro cluster course
attended_slurm (bool) – attendence for the intro slurm course
join_date (datetime.datetime) – Date the user joined the cluster, defaults to the current date
- add_user_log(vunetid, comment, log_date=None)[source]¶
Add an entry to the given user’s log.
- Parameters:
vunetid (str) – vunetid of the user
comment (str) – entry to add to the log
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- all_users_info(secondary_groups=False, limit=None, offset=None)[source]¶
Retrieve general information for all ACCRE users including secondary groups if requested
- Parameters:
secondary_groups (bool) – Show secondary groups for all users if set to true
limit (int) – Maximum number of records to return, return all if None
offset (int) – Offset from first record to begin list of records, start at the first record if None
- Returns:
General user information for all users
- Return type:
list(dict)
- deactivate_user(vunetid, reason=None, log_date=None)[source]¶
Deactivate the user in the Database. Note that this does not deactivate a user in LDAP, but simply marks a user as one that should no longer have access. A reason string is required.
- Parameters:
vunetid (str) – User to be deactivated
reason (str) – Reason for deactivation. Cite a ticket if possible.
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- get_user_logs(vunetid)[source]¶
Fetch user logs for a given vunetid sorted by newest first
- Parameters:
vunetid (str) –
- Returns:
list of all user log dates and comments for the vunetid
- Return type:
list(tuple(datetime.datetime, comment))
- list_scheduler_acc_associations()[source]¶
Return a list of all scheduler associations for accelerated partitions (i.e. triplets of VUNetID, group, and accelerated partition) that should be present according to the datbase.
- Returns:
List of scheduler associations (VUNetID, group, partition)
- Return type:
list(tuple(str, str, str))
- list_scheduler_associations()[source]¶
Return a list of all scheduler associations (i.e. triplets of VUNetID, group, and scheduler partition) that should be present according to the datbase. Note that accelerated partition associations are not returned by this method.
- Returns:
List of scheduler associations (VUNetID, group, partition)
- Return type:
list(tuple(str, str, str))
- list_users(active=False)[source]¶
List all users in the databse, or all active users.
- Parameters:
active (bool) – List only active users if set to true
- Returns:
List of user ids
- Return type:
list(str)
- mark_attended(vunetid, unix=None, cluster=None, slurm=None, log_date=None)[source]¶
Updates attendance fields for a user
- Parameters:
vunetid (str) – User vunetid
unix (bool) – Attendance for Intro to Unix
cluster (bool) – Attendance for Intro to the Cluster
slurm (bool) – Attendance for Intro to Slurm
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- modify_user(vunetid, reason=None, log_date=None, **updates)[source]¶
Modify one or more fields of an existing ACCRE user and log the change with an optional reason.
- Parameters:
vunetid (str) – VUNetID or ACCRE username for the user
reason (str) – Explanation of the change to be logged
updates (dict) – Columns to be updated with their values
log_date (datetime.datetime) – Date to log the user modification, defaults to the current date
- remove_secondary_groups(vunetid, *groups, log_date=None)[source]¶
Remove specified secondary groups from a cluster user
- Parameters:
vunetid (str) – user to remove from secondary group(s)
groups (str) – Groups to remove the user from
log_date (datetime.datetime) – Date to use for the log entry, defaults to the current date.
- show_modified_scheduler_associations(show_all=False)[source]¶
Return a dict keyed by scheduler associations (i.e. triplets of VUNetID, group, and scheduler partition) that should be present according to the datbase, with values that are the modifications that should be present in those associations (i.e. QOS, fairshare, max_mem, etc…). By default, do not add associations for which there are no modifications.
- Parameters:
show_all (boot) – If True, add all associations to the dict, even those with no modifications
- Returns:
Dict of scheduler associations (VUNetID, group, partition) and their corresponding modifications
- Return type:
dict(tuple(str, str, str), dict)
- user_exists(vunetid)[source]¶
Return true if the specified user exists in the database
- Parameters:
vunetid (str) – ACCRE user to be queried
- Returns:
True if the user is found in the database
- Return type:
bool
- user_info(vunetid, secondary_groups=False, gpfs_usage=False)[source]¶
Retrieve general information for an ACCRE user including secondary groups and/or gpfs usage if requested
- Parameters:
vunetid (str) – ACCRE user to be queried
secondary_groups (bool) – Show secondary groups for the user if set to true
gpfs_usage (bool) – Show gpfs usage records for home and scratch if set to true.
- Returns:
General user information
- Return type:
dict