-
Notifications
You must be signed in to change notification settings - Fork 20
Gdm c9s updates #250
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
base: master
Are you sure you want to change the base?
Gdm c9s updates #250
Changes from all commits
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 |
|---|---|---|
|
|
@@ -95,9 +95,21 @@ def join_domain(self, client: ClientHost, provider: IPAHost | ADHost | SambaHost | |
| self.logger.info(f"Running realm join failed with:\n{result.stdout}\n{result.stderr}") | ||
| self.logger.info("Trying uninstall and join again.") | ||
| if isinstance(provider, (IPAHost)): | ||
| client.conn.exec(["ipa-client-install", "--uninstall", "-U"]) | ||
| result = client.conn.exec(["ipa-client-install", "--uninstall", "-U"], raise_on_error=False) | ||
| if result.rc != 0: | ||
| self.logger.info( | ||
| f"Running ipa-client-install --uninstall failed with:\n{result.stdout}\n{result.stderr}" | ||
| ) | ||
| self.logger.info("Trying to remove sssd.conf now") | ||
| client.fs.rm("/etc/sssd/sssd.conf") | ||
| else: | ||
| client.conn.exec(["realm", "leave", "--unattended", provider.domain], input=provider.adminpw) | ||
| result = client.conn.exec( | ||
| ["realm", "leave", "--unattended", provider.domain], input=provider.adminpw, raise_on_error=False | ||
| ) | ||
| if result.rc != 0: | ||
| self.logger.info(f"Running realm leave failed with:\n{result.stdout}\n{result.stderr}") | ||
| self.logger.info("Trying to remove sssd.conf now") | ||
|
Contributor
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 here |
||
| client.fs.rm("/etc/sssd/sssd.conf") | ||
|
Comment on lines
97
to
+112
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. The error handling logic for if isinstance(provider, (IPAHost)):
uninstall_cmd = ["ipa-client-install", "--uninstall", "-U"]
uninstall_input = None
cmd_desc = "ipa-client-install --uninstall"
else:
uninstall_cmd = ["realm", "leave", "--unattended", provider.domain]
uninstall_input = provider.adminpw
cmd_desc = "realm leave"
result = client.conn.exec(uninstall_cmd, input=uninstall_input, raise_on_error=False)
if result.rc != 0:
self.logger.info(f"Running {cmd_desc} failed with:\n{result.stdout}\n{result.stderr}")
self.logger.info("Trying to remove sssd.conf now")
client.fs.rm("/etc/sssd/sssd.conf") |
||
| client.conn.exec(["realm", "join", provider.domain], input=provider.adminpw) | ||
|
|
||
|
|
||
|
|
@@ -361,7 +373,11 @@ class GDMTopologyController(ProvisionedBackupTopologyController): | |
| @BackupTopologyController.restore_vanilla_on_error | ||
| def topology_setup(self, client: ClientHost, ipa: IPAHost, keycloak: KeycloakHost) -> None: | ||
| short_hostname = client.conn.run("hostname").stdout.split(".")[0].strip() | ||
| hostname = f"{short_hostname}.{keycloak.domain}" | ||
| hostname = f"{short_hostname}.{ipa.domain}" | ||
| client.fs.backup("/etc/hostname") | ||
| client.fs.backup("/etc/hosts") | ||
| client.conn.run(f"echo {hostname} > /etc/hostname") | ||
| client.fs.write("/etc/hosts", client.fs.read("/etc/hosts").replace("client.test", hostname)) | ||
|
Comment on lines
375
to
+380
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. |
||
|
|
||
| # Change client hostname to match the domain | ||
| self.logger.info(f"Changing hostname to {hostname}") | ||
|
|
@@ -382,6 +398,16 @@ def topology_setup(self, client: ClientHost, ipa: IPAHost, keycloak: KeycloakHos | |
|
|
||
| # Create an IdP client | ||
| keycloak.kclogin() | ||
|
|
||
| # First delete client if it exists | ||
| result = keycloak.conn.run( | ||
| "/opt/keycloak/bin/kcadm.sh get clients -q clientId=ipa_oidc_client " "--fields=id|jq -r '.[0].id'", | ||
| raise_on_error=False, | ||
| ) | ||
| if result.rc == 0 and "null" not in result.stdout: | ||
| client_id = result.stdout.strip() | ||
| keycloak.conn.run(f"/opt/keycloak/bin/kcadm.sh delete clients/{client_id}") | ||
|
|
||
| keycloak.conn.run( | ||
| "/opt/keycloak/bin/kcadm.sh create clients -r master " | ||
| '-b \'{"clientId": "ipa_oidc_client", "clientAuthenticatorType": "client-secret", ' | ||
|
|
@@ -392,7 +418,14 @@ def topology_setup(self, client: ClientHost, ipa: IPAHost, keycloak: KeycloakHos | |
| ) | ||
|
|
||
| ipa.kinit() | ||
| ipa.conn.run( | ||
|
|
||
| # Check if IPA entry for Keycloak already exists and delete | ||
| result = ipa.conn.run("ipa idp-show keycloak", raise_on_error=False) | ||
| if "ipa_oidc_client" in result.stdout: | ||
| self.logger.info(f"IPA already enrolled in keycloak. Removing.") | ||
|
Contributor
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. This doesn't need to be an f-string
Contributor
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. nitpick, two spaces before 'Removing" |
||
| ipa.conn.run("ipa idp-del keycloak") | ||
|
|
||
| result = ipa.conn.run( | ||
|
Contributor
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. Either you check for something on |
||
| f"ipa idp-add keycloak --provider keycloak --base-url {keycloak.hostname}:8443/auth " | ||
| "--org master --client-id ipa_oidc_client --secret", | ||
| input="IPA_Secret123", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,11 +117,19 @@ def wait_for_login(self, client: Client) -> None: | |
| :param client: Client role object to read log | ||
| :type client: Client role | ||
| """ | ||
| result = client.journald.journalctl( | ||
| grep="Opening and taking control of.*card", unit=None, since="5 seconds ago" | ||
| ) | ||
| if result.rc != 0: | ||
| result = client.journald.journalctl(grep=None, unit=None, since="5 seconds ago") | ||
|
|
||
| rc = 0 | ||
| checks = ["Opening and taking control of.*card", "Adding device.*card"] | ||
| for check in checks: | ||
| if not re.search(check, result.stdout): | ||
| rc += 1 | ||
|
|
||
| if rc >= len(checks): | ||
| raise AssertionError("Unable to see gnome-shell take control of video card") | ||
|
Comment on lines
+122
to
129
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. Instead of iterating through the checks and calling checks = ["Opening and taking control of.*card", "Adding device.*card"]
pattern = "|".join(checks)
if not re.search(pattern, result.stdout):
raise AssertionError("Unable to see gnome-shell take control of video card")
Contributor
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. This one makes sense |
||
| import time | ||
|
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. |
||
|
|
||
| time.sleep(2) | ||
|
|
||
| def check_home_screen(self) -> bool: | ||
| """ | ||
|
|
||
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 state
Removing sssd.conf now, unless a check for the removal of the file exists somewhere