-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the log error messages and execute of cmd and output (#1234)
1. when we exit with sys.exit(1) the line before should be log.error instead of log.info 2. format with f-string which is more readable 3. in the method execute_command(cmd) log the cmd and the output instead of doing that multiple times in the code I faced these issues as part of jira ticket: RHOAIENG-2683
- Loading branch information
Showing
8 changed files
with
197 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,23 @@ | ||
from logging import log | ||
from time import sleep | ||
|
||
from logger import log | ||
from util import execute_command | ||
|
||
|
||
def aws_configure(aws_access_key_id, aws_secret_access_key, aws_region): | ||
""" | ||
Runs aws configure and set the configuration required | ||
for OpenShift/ROSA Installation | ||
""" | ||
cmd_aws_configure_key_id = [ | ||
"aws", | ||
"configure", | ||
"set", | ||
"default.aws_access_key_id", | ||
aws_access_key_id, | ||
] | ||
ret = execute_command(" ".join(cmd_aws_configure_key_id)) | ||
def aws_configure_execute_cmd(aws_key, aws_value, aws_profile): | ||
aws_configure_cmd = ["aws", "configure", "set", aws_key, aws_value, "--profile", aws_profile] | ||
ret = execute_command(" ".join(aws_configure_cmd)) | ||
if ret is None: | ||
print("Failed to configure aws_access_key_id") | ||
log.error(f"Failed to configure {aws_key}") | ||
return ret | ||
sleep(1) | ||
|
||
cmd_aws_configure_access_id = [ | ||
"aws", | ||
"configure", | ||
"set", | ||
"default.aws_secret_access_key", | ||
aws_secret_access_key, | ||
] | ||
ret = execute_command(" ".join(cmd_aws_configure_access_id)) | ||
if ret is None: | ||
print("Failed to configure aws_secret_access_key") | ||
return ret | ||
sleep(1) | ||
|
||
cmd_aws_configure_region = ["aws", "configure", "set", "default.region", aws_region] | ||
ret = execute_command(" ".join(cmd_aws_configure_region)) | ||
if ret is None: | ||
print("Failed to configure region") | ||
return ret | ||
def aws_configure(aws_access_key_id, aws_secret_access_key, aws_region, aws_profile="default"): | ||
""" | ||
Runs aws configure and set the configuration required | ||
for OpenShift/ROSA Installation | ||
""" | ||
aws_configure_execute_cmd(aws_key="aws_access_key_id", aws_value=aws_access_key_id, aws_profile=aws_profile) | ||
aws_configure_execute_cmd(aws_key="aws_secret_access_key", aws_value=aws_secret_access_key, aws_profile=aws_profile) | ||
aws_configure_execute_cmd(aws_key="region", aws_value=aws_region, aws_profile=aws_profile) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.