def _build_ec2_attributes(self, cluster, parsed_attrs): keys = parsed_attrs.keys() instances = cluster['Instances'] if 'AvailabilityZone' in keys and 'SubnetId' in keys: raise exceptions.SubnetAndAzValidationError emrutils.apply_params(src_params=parsed_attrs, src_key='KeyName', dest_params=instances, dest_key='Ec2KeyName') emrutils.apply_params(src_params=parsed_attrs, src_key='SubnetId', dest_params=instances, dest_key='Ec2SubnetId') if 'AvailabilityZone' in keys: instances['Placement'] = dict() emrutils.apply_params(src_params=parsed_attrs, src_key='AvailabilityZone', dest_params=instances['Placement'], dest_key='AvailabilityZone') emrutils.apply_params(src_params=parsed_attrs, src_key='InstanceProfile', dest_params=cluster, dest_key='JobFlowRole') emrutils.apply(params=cluster, key='Instances', value=instances) return cluster
def _build_ec2_attributes(self, cluster, parsed_attrs): keys = parsed_attrs.keys() instances = cluster['Instances'] if 'AvailabilityZone' in keys and 'SubnetId' in keys: raise exceptions.SubnetAndAzValidationError emrutils.apply_params( src_params=parsed_attrs, src_key='KeyName', dest_params=instances, dest_key='Ec2KeyName') emrutils.apply_params( src_params=parsed_attrs, src_key='SubnetId', dest_params=instances, dest_key='Ec2SubnetId') if 'AvailabilityZone' in keys: instances['Placement'] = dict() emrutils.apply_params( src_params=parsed_attrs, src_key='AvailabilityZone', dest_params=instances['Placement'], dest_key='AvailabilityZone') emrutils.apply_params( src_params=parsed_attrs, src_key='InstanceProfile', dest_params=cluster, dest_key='JobFlowRole') emrutils.apply(params=cluster, key='Instances', value=instances) return cluster
def _build_bootstrap_actions(self, cluster, parsed_boostrap_actions): cluster_ba_list = cluster.get("BootstrapActions") if cluster_ba_list is None: cluster_ba_list = [] bootstrap_actions = [] if len(cluster_ba_list) + len(parsed_boostrap_actions) > constants.MAX_BOOTSTRAP_ACTION_NUMBER: raise ValueError("aws: error: maximum number of " "bootstrap actions for a cluster exceeded.") for ba in parsed_boostrap_actions: ba_config = {} if ba.get("Name") is not None: ba_config["Name"] = ba.get("Name") else: ba_config["Name"] = constants.BOOTSTRAP_ACTION_NAME script_arg_config = {} emrutils.apply_params(src_params=ba, src_key="Path", dest_params=script_arg_config, dest_key="Path") emrutils.apply_params(src_params=ba, src_key="Args", dest_params=script_arg_config, dest_key="Args") emrutils.apply(params=ba_config, key="ScriptBootstrapAction", value=script_arg_config) bootstrap_actions.append(ba_config) result = cluster_ba_list + bootstrap_actions if len(result) > 0: cluster["BootstrapActions"] = result return cluster
def _build_ec2_attributes(self, cluster, parsed_attrs): keys = parsed_attrs.keys() instances = cluster["Instances"] if "AvailabilityZone" in keys and "SubnetId" in keys: raise exceptions.SubnetAndAzValidationError emrutils.apply_params(src_params=parsed_attrs, src_key="KeyName", dest_params=instances, dest_key="Ec2KeyName") emrutils.apply_params( src_params=parsed_attrs, src_key="SubnetId", dest_params=instances, dest_key="Ec2SubnetId" ) if "AvailabilityZone" in keys: instances["Placement"] = dict() emrutils.apply_params( src_params=parsed_attrs, src_key="AvailabilityZone", dest_params=instances["Placement"], dest_key="AvailabilityZone", ) emrutils.apply_params( src_params=parsed_attrs, src_key="InstanceProfile", dest_params=cluster, dest_key="JobFlowRole" ) emrutils.apply(params=cluster, key="Instances", value=instances) return cluster
def _build_bootstrap_actions( self, cluster, parsed_boostrap_actions): cluster_ba_list = cluster.get('BootstrapActions') if cluster_ba_list is None: cluster_ba_list = [] bootstrap_actions = [] if len(cluster_ba_list) + len(parsed_boostrap_actions) \ > constants.MAX_BOOTSTRAP_ACTION_NUMBER: raise ValueError('aws: error: maximum number of ' 'bootstrap actions for a cluster exceeded.') for ba in parsed_boostrap_actions: ba_config = {} if ba.get('Name') is not None: ba_config['Name'] = ba.get('Name') else: ba_config['Name'] = constants.BOOTSTRAP_ACTION_NAME script_arg_config = {} emrutils.apply_params( src_params=ba, src_key='Path', dest_params=script_arg_config, dest_key='Path') emrutils.apply_params( src_params=ba, src_key='Args', dest_params=script_arg_config, dest_key='Args') emrutils.apply( params=ba_config, key='ScriptBootstrapAction', value=script_arg_config) bootstrap_actions.append(ba_config) result = cluster_ba_list + bootstrap_actions if len(result) > 0: cluster['BootstrapActions'] = result return cluster
def _build_ec2_attributes(self, cluster, parsed_attrs): keys = parsed_attrs.keys() instances = cluster['Instances'] if ('SubnetId' in keys and 'SubnetIds' in keys): raise exceptions.MutualExclusiveOptionError( option1="SubnetId", option2="SubnetIds") if ('AvailabilityZone' in keys and 'AvailabilityZones' in keys): raise exceptions.MutualExclusiveOptionError( option1="AvailabilityZone", option2="AvailabilityZones") if ('SubnetId' in keys or 'SubnetIds' in keys) \ and ('AvailabilityZone' in keys or 'AvailabilityZones' in keys): raise exceptions.SubnetAndAzValidationError emrutils.apply_params( src_params=parsed_attrs, src_key='KeyName', dest_params=instances, dest_key='Ec2KeyName') emrutils.apply_params( src_params=parsed_attrs, src_key='SubnetId', dest_params=instances, dest_key='Ec2SubnetId') emrutils.apply_params( src_params=parsed_attrs, src_key='SubnetIds', dest_params=instances, dest_key='Ec2SubnetIds') if 'AvailabilityZone' in keys: instances['Placement'] = dict() emrutils.apply_params( src_params=parsed_attrs, src_key='AvailabilityZone', dest_params=instances['Placement'], dest_key='AvailabilityZone') if 'AvailabilityZones' in keys: instances['Placement'] = dict() emrutils.apply_params( src_params=parsed_attrs, src_key='AvailabilityZones', dest_params=instances['Placement'], dest_key='AvailabilityZones') emrutils.apply_params( src_params=parsed_attrs, src_key='InstanceProfile', dest_params=cluster, dest_key='JobFlowRole') emrutils.apply_params( src_params=parsed_attrs, src_key='EmrManagedMasterSecurityGroup', dest_params=instances, dest_key='EmrManagedMasterSecurityGroup') emrutils.apply_params( src_params=parsed_attrs, src_key='EmrManagedSlaveSecurityGroup', dest_params=instances, dest_key='EmrManagedSlaveSecurityGroup') emrutils.apply_params( src_params=parsed_attrs, src_key='ServiceAccessSecurityGroup', dest_params=instances, dest_key='ServiceAccessSecurityGroup') emrutils.apply_params( src_params=parsed_attrs, src_key='AdditionalMasterSecurityGroups', dest_params=instances, dest_key='AdditionalMasterSecurityGroups') emrutils.apply_params( src_params=parsed_attrs, src_key='AdditionalSlaveSecurityGroups', dest_params=instances, dest_key='AdditionalSlaveSecurityGroups') emrutils.apply(params=cluster, key='Instances', value=instances) return cluster