Skip to content

Commit

Permalink
fix: fix Deadline Cloud Monitor to be lower cased monitor
Browse files Browse the repository at this point in the history
Signed-off-by: Cecilia Cho <162955484+chocecil@users.noreply.github.com>
  • Loading branch information
chocecil committed Apr 29, 2024
1 parent 1ab3ccc commit a3f924e
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 37 deletions.
40 changes: 20 additions & 20 deletions src/deadline/client/api/_loginout.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def _login_deadline_cloud_monitor(
on_cancellation_check: Optional[Callable],
config: Optional[ConfigParser] = None,
):
# Deadline Cloud Monitor writes the absolute path to itself to the config file
# Deadline Cloud monitor writes the absolute path to itself to the config file
deadline_cloud_monitor_path = get_setting("deadline-cloud-monitor.path", config=config)
profile_name = get_setting("defaults.aws_profile_name", config=config)
args = [deadline_cloud_monitor_path, "login", "--profile", profile_name]

# Open Deadline Cloud Monitor, non-blocking the user will keep Deadline Cloud Monitor running in the background.
# Open Deadline Cloud monitor, non-blocking the user will keep Deadline Cloud monitor running in the background.
try:
if sys.platform.startswith("win"):
# We don't hookup to stdin but do this to avoid issues on windows
Expand All @@ -58,30 +58,30 @@ def _login_deadline_cloud_monitor(
time.sleep(0.5)
except FileNotFoundError:
raise DeadlineOperationError(
f"Could not find Deadline Cloud Monitor at {deadline_cloud_monitor_path}."
f"Please ensure Deadline Cloud Monitor is installed correctly and set up the {profile_name} profile again."
f"Could not find Deadline Cloud monitor at {deadline_cloud_monitor_path}. "
f"Please ensure Deadline Cloud monitor is installed correctly and set up the {profile_name} profile again."
)
if on_pending_authorization:
on_pending_authorization(
credentials_source=AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN
)
# And wait for the user to complete login
while True:
# Deadline Cloud Monitor is a GUI app that will keep on running
# Deadline Cloud monitor is a GUI app that will keep on running
# So we sit here and test that profile for validity until it works
if check_authentication_status(config) == AwsAuthenticationStatus.AUTHENTICATED:
return f"Deadline Cloud Monitor Profile: {profile_name}"
return f"Deadline Cloud monitor Profile: {profile_name}"
if on_cancellation_check:
# Check if the UI has signaled a cancel
if on_cancellation_check():
p.kill()
raise Exception()
if p.poll():
# Deadline Cloud Monitor has stopped, we assume it returned us an error on one line on stderr
# but let's be specific about Deadline Cloud Monitor failing incase the error is non-obvious
# Deadline Cloud monitor has stopped, we assume it returned us an error on one line on stderr
# but let's be specific about Deadline Cloud monitor failing incase the error is non-obvious
# and let's tack on stdout incase it helps
err_prefix = (
f"Deadline Cloud Monitor was not able to log into the {profile_name} profile: "
f"Deadline Cloud monitor was not able to log into the {profile_name} profile: "
)
out = p.stdout.read().decode("utf-8") if p.stdout else ""
raise DeadlineOperationError(f"{err_prefix}:\n{out}")
Expand All @@ -95,12 +95,12 @@ def login(
config: Optional[ConfigParser] = None,
) -> str:
"""
For AWS profiles created by Deadline Cloud Monitor, logs in to provide access to Deadline Cloud.
For AWS profiles created by Deadline Cloud monitor, logs in to provide access to Deadline Cloud.
Args:
on_pending_authorization (Callable): A callback that receives method-specific information to continue login.
All methods: 'credentials_source' parameter of type AwsCredentialsSource
For Deadline Cloud Monitor: No additional parameters
For Deadline Cloud monitor: No additional parameters
on_cancellation_check (Callable): A callback that allows the operation to cancel before login completes
config (ConfigParser, optional): The AWS Deadline Cloud configuration
object to use instead of the config file.
Expand All @@ -111,44 +111,44 @@ def login(
on_pending_authorization, on_cancellation_check, config
)
raise UnsupportedProfileTypeForLoginLogout(
"Logging in is only supported for AWS Profiles created by Deadline Cloud Monitor."
"Logging in is only supported for AWS Profiles created by Deadline Cloud monitor."
)


def logout(config: Optional[ConfigParser] = None) -> str:
"""
For AWS profiles created by Deadline Cloud Monitor, logs out of Deadline Cloud.
For AWS profiles created by Deadline Cloud monitor, logs out of Deadline Cloud.
Args:
config (ConfigParser, optional): The AWS Deadline Cloud configuration
object to use instead of the config file.
"""
credentials_source = get_credentials_source(config)
if credentials_source == AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN:
# Deadline Cloud Monitor writes the absolute path to itself to the config file
# Deadline Cloud monitor writes the absolute path to itself to the config file
deadline_cloud_monitor_path = get_setting("deadline-cloud-monitor.path", config=config)
profile_name = get_setting("defaults.aws_profile_name", config=config)
args = [deadline_cloud_monitor_path, "logout", "--profile", profile_name]

# Open Deadline Cloud Monitor, blocking
# Unlike login, that opens the regular Deadline Cloud Monitor GUI, logout is a CLI command that clears the profile
# Open Deadline Cloud monitor, blocking
# Unlike login, that opens the regular Deadline Cloud monitor GUI, logout is a CLI command that clears the profile
# This makes it easier as we can execute and look at the return cdoe
try:
output = subprocess.check_output(args)
except FileNotFoundError:
raise DeadlineOperationError(
f"Could not find Deadline Cloud Monitor at {deadline_cloud_monitor_path}."
f"Please ensure Deadline Cloud Monitor is installed correctly and set up the {profile_name} profile again."
f"Could not find Deadline Cloud monitor at {deadline_cloud_monitor_path}. "
f"Please ensure Deadline Cloud monitor is installed correctly and set up the {profile_name} profile again."
)
except subprocess.CalledProcessError as e:
raise DeadlineOperationError(
f"Deadline Cloud Monitor was unable to log out the profile {profile_name}."
f"Deadline Cloud monitor was unable to log out the profile {profile_name}."
f"Return code {e.returncode}: {e.output}"
)

# Force a refresh of the cached boto3 Session
invalidate_boto3_session_cache()
return output.decode("utf8")
raise UnsupportedProfileTypeForLoginLogout(
"Logging out is only supported for AWS Profiles created by Deadline Cloud Monitor."
"Logging out is only supported for AWS Profiles created by Deadline Cloud monitor."
)
10 changes: 5 additions & 5 deletions src/deadline/client/api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_boto3_client(service_name: str, config: Optional[ConfigParser] = None) -

def get_credentials_source(config: Optional[ConfigParser] = None) -> AwsCredentialsSource:
"""
Returns DEADLINE_CLOUD_MONITOR_LOGIN if Deadline Cloud Monitor wrote the credentials, HOST_PROVIDED otherwise.
Returns DEADLINE_CLOUD_MONITOR_LOGIN if Deadline Cloud monitor wrote the credentials, HOST_PROVIDED otherwise.
Args:
config (ConfigParser, optional): The AWS Deadline Cloud configuration
Expand All @@ -127,7 +127,7 @@ def get_credentials_source(config: Optional[ConfigParser] = None) -> AwsCredenti
except ProfileNotFound:
return AwsCredentialsSource.NOT_VALID
if "monitor_id" in profile_config:
# Deadline Cloud Monitor Desktop adds the "monitor_id" key
# Deadline Cloud monitor Desktop adds the "monitor_id" key
return AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN
else:
return AwsCredentialsSource.HOST_PROVIDED
Expand All @@ -137,7 +137,7 @@ def get_user_and_identity_store_id(
config: Optional[ConfigParser] = None,
) -> tuple[Optional[str], Optional[str]]:
"""
If logged in with Deadline Cloud Monitor Desktop, returns a tuple
If logged in with Deadline Cloud monitor Desktop, returns a tuple
(user_id, identity_store_id), otherwise returns None.
"""
session = get_boto3_session(config=config)
Expand Down Expand Up @@ -265,15 +265,15 @@ def check_authentication_status(config: Optional[ConfigParser] = None) -> AwsAut
Returns AwsAuthenticationStatus enum value:
- CONFIGURATION_ERROR if there is an unexpected error accessing credentials
- AUTHENTICATED if they are fine
- NEEDS_LOGIN if a Deadline Cloud Monitor login is required.
- NEEDS_LOGIN if a Deadline Cloud monitor login is required.
"""

with _modified_logging_level(logging.getLogger("botocore.credentials"), logging.ERROR):
try:
get_boto3_session(config=config).client("sts").get_caller_identity()
return AwsAuthenticationStatus.AUTHENTICATED
except Exception:
# We assume that the presence of a Deadline Cloud Monitor profile
# We assume that the presence of a Deadline Cloud monitor profile
# means we will know everything necessary to start it and login.

if get_credentials_source(config) == AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN:
Expand Down
10 changes: 5 additions & 5 deletions src/deadline/client/cli/_groups/auth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

def _cli_on_pending_authorization(**kwargs):
"""
Callback for `login`, to tell the user that Deadline Cloud Monitor is opening
Callback for `login`, to tell the user that Deadline Cloud monitor is opening
"""

if kwargs["credentials_source"] == AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN:
click.echo("Opening Deadline Cloud Monitor. Please log in and then return here.")
click.echo("Opening Deadline Cloud monitor. Please log in and then return here.")


@click.group(name="auth")
Expand All @@ -45,7 +45,7 @@ def auth_login():
Logs in to the AWS Deadline Cloud configured AWS profile.
This is for any profile type that AWS Deadline Cloud knows how to login to
Currently only supports Deadline Cloud Monitor
Currently only supports Deadline Cloud monitor
"""
click.echo(
f"Logging into AWS Profile {config_file.get_setting('defaults.aws_profile_name')!r} for AWS Deadline Cloud"
Expand All @@ -62,11 +62,11 @@ def auth_login():
@_handle_error
def auth_logout():
"""
Logs out of the Deadline Cloud Monitor configured AWS profile.
Logs out of the Deadline Cloud monitor configured AWS profile.
"""
api.logout()

click.echo("Successfully logged out of all Deadline Cloud Monitor AWS profiles")
click.echo("Successfully logged out of all Deadline Cloud monitor AWS profiles")


@cli_auth.command(name="status")
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/client/cli/_groups/handle_web_url_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def cli_handle_web_url(
step_id = url_queries.pop("step_id", None)
task_id = url_queries.pop("task_id", None)

# Add the standard option "profile", using the one provided by the url (set by Deadline Cloud Monitor)
# Add the standard option "profile", using the one provided by the url (set by Deadline Cloud monitor)
# or choosing a best guess based on farm and queue IDs
aws_profile_name = url_queries.pop(
"profile",
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/client/config/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
SETTINGS: Dict[str, Dict[str, Any]] = {
"deadline-cloud-monitor.path": {
"default": "",
"description": "The filesystem path to Deadline Cloud Monitor, set during login process.",
"description": "The filesystem path to Deadline Cloud monitor, set during login process.",
},
"defaults.aws_profile_name": {
"default": "(default)",
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/client/ui/deadline_authentication_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
This is checked with an sts:GetCallerIdentity AWS API call.
2. Do the credentials grant access to AWS Deadline Cloud APIs?
This is checked with a simplified deadline:ListFarms AWS API call.
3. Do the credentials use Deadline Cloud Monitor?
3. Do the credentials use Deadline Cloud monitor?
This is checked by looking for the relevant properties
in the AWS profile configuration.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/client/ui/dialogs/deadline_login_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def on_pending_authorization(**kwargs):
== AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN
):
self.login_thread_message.emit(
"Opening Deadline Cloud Monitor. Please log in before returning here."
"Opening Deadline Cloud monitor. Please log in before returning here."
)

def on_cancellation_check():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _set_submit_button_state(self):

def refresh_deadline_settings(self):
# Enable/disable the Login and Logout buttons based on whether
# the configured profile is for Deadline Cloud Monitor
# the configured profile is for Deadline Cloud monitor
self.login_button.setEnabled(
self.deadline_authentication_status.creds_source
== api.AwsCredentialsSource.DEADLINE_CLOUD_MONITOR_LOGIN
Expand Down
4 changes: 2 additions & 2 deletions test/unit/deadline_client/cli/test_cli_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def test_cli_deadline_cloud_monitor_login_and_logout(fresh_deadline_config):
"""
Confirm that the CLI login/logout command invokes Deadline Cloud Monitor as expected
Confirm that the CLI login/logout command invokes Deadline Cloud monitor as expected
"""
scoped_config = {
"credential_process": "/bin/DeadlineCloudMonitor get-credentials --profile sandbox-us-west-2",
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_cli_deadline_cloud_monitor_login_and_logout(fresh_deadline_config):
assert result.exit_code == 0

assert (
"Successfully logged in: Deadline Cloud Monitor Profile: sandbox-us-west-2"
"Successfully logged in: Deadline Cloud monitor Profile: sandbox-us-west-2"
in result.output
)
assert result.exit_code == 0
Expand Down

0 comments on commit a3f924e

Please sign in to comment.