-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adcli: adding class and methods for adcli #145
base: master
Are you sure you want to change the base?
Conversation
d6f3db9
to
1052062
Compare
sssd_test_framework/utils/adcli.py
Outdated
def _join( | ||
self, | ||
*, | ||
domain: str| None = None, |
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.
There should be probably either domain or domain_controller.
The manual page states that it expects domain so I would go with that.
Getting both None or both populated is a recipe for a disaster.
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'd like to bring in Sumit as well.
I don't really know if we have use for this in SSSD, I don't really think so. I'm fine with including the patch though. However, in this case, operation that changes something must be also able to revert that change. In this case join
, so this should be MultihostReentrantUtility.
sssd_test_framework/utils/adcli.py
Outdated
self.fs: LinuxFileSystem = fs | ||
"""Filesystem utils.""" | ||
|
||
def _info( |
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.
Why do you use underscores on the methods name? Those should be all public methods, right?
sssd_test_framework/utils/adcli.py
Outdated
self, | ||
*, | ||
domain: str | None = None, | ||
domain_controller: str | None, |
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.
default to None as well?
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.
modified
sssd_test_framework/utils/adcli.py
Outdated
def _join( | ||
self, | ||
*, | ||
domain: str| None = None, | ||
domain_controller: str| None = None, | ||
domain_realm: str| None = None, | ||
host_fqdn: str| None = None, | ||
host_keytab: str| None = None, | ||
computer_name: str| None = None, | ||
login_ccache: str| None = None, | ||
login_user: str| None = None, | ||
login_type: str| None = None, | ||
domain_ou: str| None = None, | ||
service_name: str| None = None, | ||
os_name: str| None = None, | ||
os_version: str| None = None, | ||
os_service_pack: str| None = None, | ||
user_principal: str| None = None, | ||
trusted_for_delegation: str| None = None, | ||
dont_expire_password: str| None = None, | ||
add_service_principal: str| None = None, | ||
description: str| None = None, | ||
setattrs: str| None = None, | ||
no_password: str| None = None, | ||
promp_password: str| None = None, | ||
stdin_password: str| None = None, | ||
one_time_password: str| None = None, | ||
show_password: str| None = None, | ||
show_details: str| None = None, | ||
add_samba_data: str| None = None, | ||
samba_data_tool: str| None = None, | ||
ldap_passwd: str| None = None, |
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.
Use **kwargs or *args to handle additional argument and keep only required arguments here. Otherwise it would be difficult to maintain.
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.
ack
Hi, on which level the revert should work. E.g. before calling bye, |
1052062
to
dfdf2a7
Compare
It's a question of how is it going to be used. Right now, in sssd-test-framework, we have this: https://github.com/SSSD/sssd-test-framework/blob/master/sssd_test_framework/topology_controllers.py#L74
In adcli, I assume that Shridar is going to call adcli.join() insinde a test. So the logic should be: MultihostUtility (cannot be used in MultihostHost objects, only in MultihostRole objects inside tests):
MultihostReentrantUtility (cannot be used in MultihostHost objects and in MultihostRole objects):
Docs: https://pytest-mh.readthedocs.io/en/latest/articles/extending/multihost-utilities.html Other way would be to rely on the backup/restore mechanisms to make sure everything is reverted after each test. But in this case, it needs to be thoroughly documented so the expectation is clear. That might be enough. So it really depends on how is it going to be used. |
@pbrezina, @shridhargadekar : We will probably need a way to either skip topology setup/teardown (no enrolling) so we can join ourselves or create topologies like KnownTopology.UnjoinedAD that will have the machines but not enrolled client. We can use these for example for tests like ldap sasl authid that needs a specific setup (--user-principal=host/name@REALM) to work correctly. |
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 there are still some questions to be addressed but, it looks like a good start for an interface to adcli. My only question currently is about additional join options.
sssd_test_framework/utils/adcli.py
Outdated
def join( | ||
self, | ||
domain: str, | ||
) -> str: |
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.
Could we need to run join with additional options/arguments like computer name, host keytab, user principal or others? If we do, I think we might be able to use something like the arg list used in utils/tools.py in SSHKeyUtils.generate here:
https://github.com/SSSD/sssd-test-framework/blob/master/sssd_test_framework/utils/tools.py#L770
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 the change work? I'd think you'd need to keep the domain inside the CLIBuilderArgs to do something like:
if args is None:
args = []
bargs: CLIBuilderArgs = {
"domain": (self.cli.option.POSITIONAL, domain),
}
self.host.conn.exec(["adcli", "join"] + self.cli.args(bargs) + [*args])
I haven't tested the above but, I'm just trying to mirror what was done in the SSHKeyUtils.generate(). Also, I'm not sure of the adcli command order. Maybe args should be right after the join?
Adding adcli class, and methods including info, discovery, join
dfdf2a7
to
8048de6
Compare
args: CLIBuilderArgs = { | ||
} |
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.
Can be removed.
""" | ||
args: CLIBuilderArgs = { | ||
} | ||
self.host.conn.exec(["adcli", "join"] + self.cli.args(args)) |
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.
*args
|
||
class ADCLI(MultihostUtility[MultihostHost]): | ||
""" | ||
Call commands from adcli |
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.
Make a note that this utility does not revert changes.
Given the use case, I think it is fine to rely on reverting the AD host in the topology controller, but it needs to be documented.
""" | ||
args: CLIBuilderArgs = { | ||
} | ||
self.host.conn.exec(["adcli", "join"] + self.cli.args(args)) |
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 call write any files? Like /etc/krb5.keytab maybe? If yes, you need to call fs.backup(file) to make sure it is restored. For AD state, we can rely on the topology controller, but we should handle any changes done to the host.
Adding adcli class, and methods including info, discovery, join