Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/emr/addsteps.py
1567 views
1
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
from awscli.customizations.emr import argumentschema
15
from awscli.customizations.emr import emrutils
16
from awscli.customizations.emr import helptext
17
from awscli.customizations.emr import steputils
18
from awscli.customizations.emr.command import Command
19
20
21
class AddSteps(Command):
22
NAME = 'add-steps'
23
DESCRIPTION = ('Add a list of steps to a cluster.')
24
ARG_TABLE = [
25
{'name': 'cluster-id', 'required': True,
26
'help_text': helptext.CLUSTER_ID
27
},
28
{'name': 'steps',
29
'required': True,
30
'nargs': '+',
31
'schema': argumentschema.STEPS_SCHEMA,
32
'help_text': helptext.STEPS
33
},
34
{'name': 'execution-role-arn',
35
'required': False,
36
'help_text': helptext.EXECUTION_ROLE_ARN
37
}
38
]
39
40
def _run_main_command(self, parsed_args, parsed_globals):
41
parsed_steps = parsed_args.steps
42
43
release_label = emrutils.get_release_label(
44
parsed_args.cluster_id, self._session, self.region,
45
parsed_globals.endpoint_url, parsed_globals.verify_ssl)
46
47
step_list = steputils.build_step_config_list(
48
parsed_step_list=parsed_steps, region=self.region,
49
release_label=release_label)
50
parameters = {
51
'JobFlowId': parsed_args.cluster_id,
52
'Steps': step_list
53
}
54
55
if parsed_args.execution_role_arn is not None:
56
parameters['ExecutionRoleArn'] = parsed_args.execution_role_arn
57
58
emrutils.call_and_display_response(self._session, 'AddJobFlowSteps',
59
parameters, parsed_globals)
60
return 0
61
62