Users Package¶
Users
Package¶
This package contains all User importers.
UserImporter
Module¶
This module contains the base class for all User importers.
-
class
HPCStats.Importer.Users.UserImporter.
UserImporter
(app, db, config, cluster)¶ Bases:
HPCStats.Importer.Importer.Importer
This is the base class common to all HPCStats User importers. It defines a common set of attributes and generic methods.
-
find_account
(search)¶ Search for an Account over the list of Accounts loaded by importer in self.accounts attribute. Returns None if not found.
-
find_user
(search)¶ Search for a User over the list of Users loaded by importer in self.users attribute. Returns None if not found.
-
UserImporterFactory
Module¶
This module contains the factory design pattern class that builds the appropriate UserImporter depending on what is specified in configuration.
-
class
HPCStats.Importer.Users.UserImporterFactory.
UserImporterFactory
¶ Bases:
object
This class simply delivers the factory() static method, there is not point to instanciate it with an object.
-
static
factory
(app, db, config, cluster)¶ This method returns the appropriate UserImporter object depending on what is specified in configuration. In case of configuration error, HPCStatsConfigurationException is raised.
-
static
UserImporterLdap
Module¶
This module contains the UserImporterLdap class.
-
class
HPCStats.Importer.Users.UserImporterLdap.
UserImporterLdap
(app, db, config, cluster)¶ Bases:
HPCStats.Importer.Users.UserImporter.UserImporter
This UserImporter is a bit tricky since it also has to calculate start and end datetime of users’ Accounts. For this purpose, the load() method must first get all user accounts that are currently defined w/o end datetime in database to find out if they have disapeared or not in LDAP directory. If yes, update the account end datetime with todays date.
-
check
()¶ Check the LDAP directory is available for connections.
-
connect_ldap
()¶ Connect to LDAP directory and set ldap_conn attribute accordingly. Raises HPCStatsSourceError in case of error.
-
get_default_new_date
()¶ Returns the date that is used as creation date for new accounts. If there is no account for this cluster in DB yet, we consider this is an import from scratch and the creation date is epoch. Else the creation date is today.
-
get_group_members
(group)¶ Return the list of (Users,Account) tuples members of a group in LDAP directory.
-
get_user_account_from_login
(login)¶ Returns (User,Account) objects tuple with information found in LDAP for the login in parameter. The login in parameter must be down-cased.
The created account have None creation date and deletion date. It is up-to update() method to set them well.
When no account could be found in LDAP directory for the login, if strict_user_membership attribute is True, this function raises an HPCStatsSourceError exception. If the attribute is False, None is returned.
-
get_user_department
(login, gid)¶ Search for the user department based on its group membership. If unable to compute a department name this way, use the primary group.
-
get_user_department_groups_member
(login)¶ Search for user department based on its groups membership.
The login in parameter must be downcased.
-
get_user_department_prim_group
(login, gid)¶ Define the user department based on the name of its primary group.
-
load
()¶ Load (User,Account) tuples from both LDAP directoy and DB.
-
load_db
()¶ Load (User,Account) tuples w/o account deletion date from DB.
-
load_groups_alias
()¶
-
load_ldap
()¶ Load (User,Account) tuples from LDAP directory.
-
update
()¶ Update Users and Accounts in DB based on what has been loaded from LDAP directory and current DB content.
-
UserImporterLdapSlurm
Module¶
This module contains the UserImporterLdapSlurm class.
-
class
HPCStats.Importer.Users.UserImporterLdapSlurm.
UserImporterLdapSlurm
(app, db, config, cluster)¶ Bases:
HPCStats.Importer.Users.UserImporterLdap.UserImporterLdap
This class inherits from UserImporterLdap so it imports users from LDAP directory and ensure that accounts from DB are closed properly as well. But it also imports the list of users known in Slurm DB and tries to get information about them in LDAP. This is particularly usefull for users that are still in LDAP but not in cluster user group anymore since these users have not been imported by UserImporterLdap on purpose.
-
connect_db
()¶ Connect to cluster Slurm database and set conn/cur attribute accordingly. Raises HPCStatsSourceError in case of problem.
-
disconnect_db
()¶ Disconnect from cluster Slurm database.
-
load
()¶
-
load_slurm_users
()¶
-
update
()¶
-