Path: blob/develop/awscli/customizations/emr/installapplications.py
1567 views
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.121314from awscli.customizations.emr import applicationutils15from awscli.customizations.emr import argumentschema16from awscli.customizations.emr import constants17from awscli.customizations.emr import emrutils18from awscli.customizations.emr import helptext19from awscli.customizations.emr.command import Command202122class InstallApplications(Command):23NAME = 'install-applications'24DESCRIPTION = ('Installs applications on a running cluster. Currently only'25' Hive and Pig can be installed using this command, and'26' this command is only supported by AMI versions'27' (3.x and 2.x).')28ARG_TABLE = [29{'name': 'cluster-id', 'required': True,30'help_text': helptext.CLUSTER_ID},31{'name': 'applications', 'required': True,32'help_text': helptext.INSTALL_APPLICATIONS,33'schema': argumentschema.APPLICATIONS_SCHEMA},34]35# Applications supported by the install-applications command.36supported_apps = ['HIVE', 'PIG']3738def _run_main_command(self, parsed_args, parsed_globals):3940parameters = {'JobFlowId': parsed_args.cluster_id}4142self._check_for_supported_apps(parsed_args.applications)43parameters['Steps'] = applicationutils.build_applications(44self.region, parsed_args.applications)[2]4546emrutils.call_and_display_response(self._session, 'AddJobFlowSteps',47parameters, parsed_globals)48return 04950def _check_for_supported_apps(self, parsed_applications):51for app_config in parsed_applications:52app_name = app_config['Name'].upper()5354if app_name in constants.APPLICATIONS:55if app_name not in self.supported_apps:56raise ValueError(57"aws: error: " + app_config['Name'] + " cannot be"58" installed on a running cluster. 'Name' should be one"59" of the following: " +60', '.join(self.supported_apps))61else:62raise ValueError(63"aws: error: Unknown application: " + app_config['Name'] +64". 'Name' should be one of the following: " +65', '.join(constants.APPLICATIONS))666768