Account Script python reference
LMI account provider client library.
This set of functions can create, modify and delete users and groups on
a remote managed system.
-
lmi.scripts.account.add_to_group(ns, group, users)[source]
Add users to a group.
Parameters: |
- group (LMIInstance or LMIInstanceName of LMI_Group.) – The group.
- users (List (or generator) of LMIInstances or LMIInstanceNames of
LMI_Account.) – Users to add.
|
-
lmi.scripts.account.create_group(ns, group, reserved=False, gid=None)[source]
Create a new group on the system.
Parameters: |
- group (string) – Name of the group.
- reserved (boolean) – Whether the group is a system one (its GID will be
allocated lower than system-defined threshold).
- gid (int) – Required GID. It will be allocated automatically if it’s None.
|
Return type: | LMIInstanceName of the created group.
|
Returns: | Created group.
|
-
lmi.scripts.account.create_user(ns, name, gecos=None, home=None, create_home=True, shell=None, uid=None, gid=None, create_group=True, reserved=False, password=None, plain_password=False)[source]
Create a new user.
Parameters: |
- name (string) – Name of the user.
- gecos (string) – GECOS information of the new user.
- home (string) – Home directory.
- create_home (boolean) – True, if home directory should be automatically created.
- shell (string) – User’s shell.
- uid (int) – Desired UID. If None, system will allocate a free one.
- gid (int) – Desired GID. If None, system will allocate a free one.
- create_group (boolean) – True, if user’s private group should be created.
- reserved (boolean) – True, if the account is system one, i.e. it’s UID will
be allocated in system account space (below system defined
threshold). (default=False, the account is an user).
- password (string) – User password.
- plain_password (boolean) – True, if the provided password is plain text string,
False if it is already hashed by crypt().
|
Return type: | LMIInstanceName
|
Returns: | Created used.
|
-
lmi.scripts.account.delete_group(ns, group)[source]
Delete a group.
Parameters: | group (LMIInstance or LMIInstanceName of LMI_Group.) – The group to delete. |
-
lmi.scripts.account.delete_user(ns, user, no_delete_group=False, no_delete_home=False, force=False)[source]
Delete a user.
Parameters: |
- user (LMIInstance or LMIInstanceName of LMI_Account.) – User to delete.
- no_delete_group (boolean) – True, if the user’s private group should be preserved.
(default = False, the group is deleted).
- no_delete_home (boolean) – True, if user’s home directory should be preserved.
(default = False, home is deleted).
- force (boolean) – True, if the home directory should be remove even though the
user is not owner of the directory. (default = False, do not remove
user’s home if it is owned by someone else).
|
-
lmi.scripts.account.get_group(ns, groupname)[source]
Return LMIInstance of the group. This function raises LmiFailed if the user
is not found.
Parameters: | groupname (string) – Name of the group. |
Return type: | LMIInstance of LMI_Group |
Returns: | The group. |
-
lmi.scripts.account.get_user(ns, username)[source]
Return LMIInstance of the user. This function raises LmiFailed if the user
is not found.
Parameters: | username (string) – Name of the user. |
Return type: | LMIInstance of LMI_Account |
Returns: | The user. |
-
lmi.scripts.account.get_users_in_group(ns, group)[source]
Yields users in given group.
Parameters: | group (LMIInstance or LMIInstanceName of LMI_Group.) – The group to inspect. |
Returns: | Generator of LMIInstances of LMI_Account. |
-
lmi.scripts.account.is_in_group(group, user)[source]
Return True if user is in group
Parameters: |
- group (LMIInstance or LMIInstanceName of LMI_Group.) – The group.
- user (LMIInstance or LMIInstanceName of LMI_Account.) – User to check.
|
-
lmi.scripts.account.list_groups(ns)[source]
Yield all groups on the system.
Return type: | generator of LMIInstances. |
-
lmi.scripts.account.list_users(ns)[source]
Yield all users on the system.
Return type: | generator of LMIInstances. |
-
lmi.scripts.account.remove_from_group(ns, group, users)[source]
Remove users from a group.
Parameters: |
- group (LMIInstance or LMIInstanceName of LMI_Group.) – The group.
- users (List (or generator) of LMIInstances or LMIInstanceNames of
LMI_Account.) – Users to remove.
|