Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/emr/installapplications.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
15
from awscli.customizations.emr import applicationutils
16
from awscli.customizations.emr import argumentschema
17
from awscli.customizations.emr import constants
18
from awscli.customizations.emr import emrutils
19
from awscli.customizations.emr import helptext
20
from awscli.customizations.emr.command import Command
21
22
23
class InstallApplications(Command):
24
NAME = 'install-applications'
25
DESCRIPTION = ('Installs applications on a running cluster. Currently only'
26
' Hive and Pig can be installed using this command, and'
27
' this command is only supported by AMI versions'
28
' (3.x and 2.x).')
29
ARG_TABLE = [
30
{'name': 'cluster-id', 'required': True,
31
'help_text': helptext.CLUSTER_ID},
32
{'name': 'applications', 'required': True,
33
'help_text': helptext.INSTALL_APPLICATIONS,
34
'schema': argumentschema.APPLICATIONS_SCHEMA},
35
]
36
# Applications supported by the install-applications command.
37
supported_apps = ['HIVE', 'PIG']
38
39
def _run_main_command(self, parsed_args, parsed_globals):
40
41
parameters = {'JobFlowId': parsed_args.cluster_id}
42
43
self._check_for_supported_apps(parsed_args.applications)
44
parameters['Steps'] = applicationutils.build_applications(
45
self.region, parsed_args.applications)[2]
46
47
emrutils.call_and_display_response(self._session, 'AddJobFlowSteps',
48
parameters, parsed_globals)
49
return 0
50
51
def _check_for_supported_apps(self, parsed_applications):
52
for app_config in parsed_applications:
53
app_name = app_config['Name'].upper()
54
55
if app_name in constants.APPLICATIONS:
56
if app_name not in self.supported_apps:
57
raise ValueError(
58
"aws: error: " + app_config['Name'] + " cannot be"
59
" installed on a running cluster. 'Name' should be one"
60
" of the following: " +
61
', '.join(self.supported_apps))
62
else:
63
raise ValueError(
64
"aws: error: Unknown application: " + app_config['Name'] +
65
". 'Name' should be one of the following: " +
66
', '.join(constants.APPLICATIONS))
67
68