-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-15268 test: handle errors in add_del_user #15708
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
""" | ||
(C) Copyright 2018-2024 Intel Corporation. | ||
(C) Copyright 2025 Hewlett Packard Enterprise Development LP | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
""" | ||
|
@@ -113,6 +114,27 @@ def groupadd(log, hosts, group, force=False, sudo=False): | |
return run_remote(log, hosts, command) | ||
|
||
|
||
def groupdel(log, hosts, group, force=False, sudo=False): | ||
"""Run groupdel remotely. | ||
Args: | ||
log (logger): logger for the messages produced by this method | ||
hosts (NodeSet): hosts on which to run the command | ||
group (str): the group to delete | ||
force (bool, optional): whether to use the force option. Default is False | ||
sudo (bool, optional): whether to execute commands with sudo. Default is False | ||
Returns: | ||
CommandResult: groups of command results from the same hosts with the same return status | ||
""" | ||
command = ' '.join(filter(None, [ | ||
'sudo -n' if sudo else None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you think it would make sense to standardize on using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
'groupdel', | ||
'-f' if force else None, | ||
group])) | ||
return run_remote(log, hosts, command) | ||
|
||
|
||
def useradd(log, hosts, user, group=None, parent_dir=None, sudo=False): | ||
"""Run useradd remotely. | ||
|
@@ -158,6 +180,27 @@ def userdel(log, hosts, user, sudo=False): | |
return run_remote(log, hosts, command) | ||
|
||
|
||
def usermod(log, hosts, login, groups, sudo=False): | ||
"""Run usermod remotely. | ||
Args: | ||
log (logger): logger for the messages produced by this method | ||
hosts (NodeSet): hosts on which to run the command | ||
login (str): login username | ||
groups (list): list of new groups | ||
sudo (bool): whether to execute commands with sudo. Default is False | ||
Returns: | ||
CommandResult: groups of command results from the same hosts with the same return status | ||
""" | ||
command = ' '.join(filter(None, [ | ||
'sudo -n' if sudo else None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment |
||
'usermod', | ||
f'-G {",".join(groups)}', | ||
login])) | ||
return run_remote(log, hosts, command) | ||
|
||
|
||
def get_group_id(log, hosts, group, sudo=False): | ||
"""Get a group's id on remote nodes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this now assume that the user account is pre-existing? If so, should we at least have a comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safe to assume root already exists