1414
1515from awscli .customizations .commands import BasicCommand
1616from awscli .customizations .emr import constants
17+ from awscli .customizations .emr import defaultconfig
1718from awscli .customizations .emr import emrutils
1819from awscli .customizations .emr import steputils
1920from awscli .customizations .emr import hbaseutils
@@ -32,18 +33,19 @@ class CreateCluster(BasicCommand):
3233 DESCRIPTION = (
3334 'Creates and starts running an EMR cluster.\n '
3435 '\n Quick start:\n '
35- '\n aws emr create-cluster --ami-version 3.1.0 '
36- ' --instance-groups InstanceGroupType=MASTER,InstanceCount=1,'
37- 'InstanceType=m3.xlarge InstanceGroupType=CORE,InstanceCount=2,'
38- 'InstanceType=m3.xlarge --auto-terminate\n ' )
36+ '\n aws emr create-cluster --ami-version <ami-version> '
37+ '--instance-type <instance-type> --instance-count <instance-count>\n ' )
3938 ARG_TABLE = [
4039 {'name' : 'ami-version' ,
41- 'required ' : True ,
42- 'help_text ' : helptext . AMI_VERSION },
40+ 'help_text ' : helptext . AMI_VERSION ,
41+ 'required ' : True },
4342 {'name' : 'instance-groups' ,
44- 'required' : True ,
4543 'schema' : argumentschema .INSTANCE_GROUPS_SCHEMA ,
4644 'help_text' : helptext .INSTANCE_GROUPS },
45+ {'name' : 'instance-type' ,
46+ 'help_text' : helptext .INSTANCE_TYPE },
47+ {'name' : 'instance-count' ,
48+ 'help_text' : helptext .INSTANCE_COUNT },
4749 {'name' : 'auto-terminate' , 'action' : 'store_true' ,
4850 'group_name' : 'auto_terminate' ,
4951 'help_text' : helptext .AUTO_TERMINATE },
@@ -83,7 +85,8 @@ class CreateCluster(BasicCommand):
8385 'schema' : argumentschema .BOOTSTRAP_ACTIONS_SCHEMA },
8486 {'name' : 'applications' ,
8587 'help_text' : helptext .APPLICATIONS ,
86- 'schema' : argumentschema .APPLICATIONS_SCHEMA },
88+ 'schema' : argumentschema .APPLICATIONS_SCHEMA ,
89+ 'default' : defaultconfig .APPLICATIONS },
8790 {'name' : 'steps' ,
8891 'schema' : argumentschema .STEPS_SCHEMA ,
8992 'help_text' : helptext .STEPS },
@@ -102,10 +105,17 @@ def _run_main(self, parsed_args, parsed_globals):
102105 bootstrap_actions = []
103106 params ['Name' ] = parsed_args .name
104107
105- is_valid_ami = re .match ('\d?\..*' , parsed_args .ami_version )
106- if is_valid_ami is None :
107- raise exceptions .\
108- InvalidAmiVersionError (ami_version = parsed_args .ami_version )
108+ instances_config = {}
109+ instances_config ['InstanceGroups' ] = \
110+ instancegroupsutils .validate_and_build_instance_groups (
111+ instance_groups = parsed_args .instance_groups ,
112+ instance_type = parsed_args .instance_type ,
113+ instance_count = parsed_args .instance_count )
114+
115+ is_valid_ami_version = re .match ('\d?\..*' , parsed_args .ami_version )
116+ if is_valid_ami_version is None :
117+ raise exceptions .InvalidAmiVersionError (
118+ ami_version = parsed_args .ami_version )
109119 params ['AmiVersion' ] = parsed_args .ami_version
110120 emrutils .apply_dict (
111121 params , 'AdditionalInfo' , parsed_args .additional_info )
@@ -117,18 +127,11 @@ def _run_main(self, parsed_args, parsed_globals):
117127 parsed_args .ec2_attributes ['InstanceProfile' ] = EC2_ROLE_NAME
118128
119129 emrutils .apply_dict (params , 'ServiceRole' , parsed_args .service_role )
120- instances_config = {}
121- instances_config ['InstanceGroups' ] = \
122- instancegroupsutils .build_instance_groups (
123- parsed_args .instance_groups )
124130
125131 if (
126132 parsed_args .no_auto_terminate is False and
127133 parsed_args .auto_terminate is False ):
128- raise exceptions .\
129- MissingBooleanOptionsError (
130- true_option = '--auto-terminate' ,
131- false_option = '--no-auto-terminate' )
134+ parsed_args .no_auto_terminate = True
132135
133136 instances_config ['KeepJobFlowAliveWhenNoSteps' ] = \
134137 emrutils .apply_boolean_options (
0 commit comments