Skip to content
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

Update error logic for create-default-roles #1618

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions awscli/customizations/datapipeline/createdefaultroles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
DATAPIPELINE_DEFAULT_RESOURCE_ROLE_ASSUME_POLICY
from awscli.customizations.commands import BasicCommand
from awscli.customizations.datapipeline.translator \
import display_response, dict_to_string, get_region
import display_response, dict_to_string, get_region, remove_cli_error_event
from botocore.exceptions import ClientError

LOG = logging.getLogger(__name__)
Expand All @@ -35,12 +35,12 @@ class CreateDefaultRoles(BasicCommand):
DESCRIPTION = ('Creates the default IAM role ' +
DATAPIPELINE_DEFAULT_SERVICE_ROLE_NAME + ' and ' +
DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME +
'\n which are used while creating an EMR cluster. '
'\nIf the roles do not exist, create-default-roles '
' which are used while creating an EMR cluster.\n'
'If the roles do not exist, create-default-roles '
'will automatically create them and set their policies.'
'\nIf these roles are already '
' If these roles are already '
'created create-default-roles'
'will not update their policies.'
' will not update their policies.'
'\n')

def __init__(self, session, formatter=None):
Expand All @@ -53,6 +53,7 @@ def _run_main(self, parsed_args, parsed_globals, **kwargs):
self._iam_client = self._session.create_client(
'iam', self._region, self._endpoint_url,
parsed_globals.verify_ssl)
remove_cli_error_event(self._iam_client)
return self._create_default_roles(parsed_args, parsed_globals)

def _create_role(self, role_name, role_arn, role_policy):
Expand Down
10 changes: 10 additions & 0 deletions awscli/customizations/datapipeline/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def get_region(session, parsed_globals):
return region


def remove_cli_error_event(client):
"""This unregister call will go away once the client switchover
is done, but for now we're relying on S3 catching a ClientError
when we check if a bucket exists, so we need to ensure the
botocore ClientError is raised instead of the CLI's error handler.
"""
client.meta.events.unregister(
'after-call', unique_id='awscli-error-handler')


# Method to display the response for a particular CLI operation
def display_response(session, operation_name, result, parsed_globals):
cli_operation_caller = CLIOperationCaller(session)
Expand Down