Escape EMR template fields to avoid invalid XML responses (#1467)
I had an EMR step that contained a `&` and this caused the ListStep call to fail. I've added the `| escape` filter to handle it in this case and a few other cases that look like they could suffer the same fate.
This commit is contained in:
parent
508b392697
commit
1b20f21a75
@ -462,10 +462,10 @@ DESCRIBE_JOB_FLOWS_TEMPLATE = """<DescribeJobFlowsResponse xmlns="http://elastic
|
|||||||
<ScriptBootstrapAction>
|
<ScriptBootstrapAction>
|
||||||
<Args>
|
<Args>
|
||||||
{% for arg in bootstrap_action.args %}
|
{% for arg in bootstrap_action.args %}
|
||||||
<member>{{ arg }}</member>
|
<member>{{ arg | escape }}</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Args>
|
</Args>
|
||||||
<Path>{{ bootstrap_action.script_path }}</Path>
|
<Path>{{ bootstrap_action.script_path | escape }}</Path>
|
||||||
</ScriptBootstrapAction>
|
</ScriptBootstrapAction>
|
||||||
</BootstrapActionConfig>
|
</BootstrapActionConfig>
|
||||||
</member>
|
</member>
|
||||||
@ -568,12 +568,12 @@ DESCRIBE_JOB_FLOWS_TEMPLATE = """<DescribeJobFlowsResponse xmlns="http://elastic
|
|||||||
<MainClass>{{ step.main_class }}</MainClass>
|
<MainClass>{{ step.main_class }}</MainClass>
|
||||||
<Args>
|
<Args>
|
||||||
{% for arg in step.args %}
|
{% for arg in step.args %}
|
||||||
<member>{{ arg }}</member>
|
<member>{{ arg | escape }}</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Args>
|
</Args>
|
||||||
<Properties/>
|
<Properties/>
|
||||||
</HadoopJarStep>
|
</HadoopJarStep>
|
||||||
<Name>{{ step.name }}</Name>
|
<Name>{{ step.name | escape }}</Name>
|
||||||
</StepConfig>
|
</StepConfig>
|
||||||
</member>
|
</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -596,7 +596,7 @@ DESCRIBE_STEP_TEMPLATE = """<DescribeStepResponse xmlns="http://elasticmapreduce
|
|||||||
<Config>
|
<Config>
|
||||||
<Args>
|
<Args>
|
||||||
{% for arg in step.args %}
|
{% for arg in step.args %}
|
||||||
<member>{{ arg }}</member>
|
<member>{{ arg | escape }}</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Args>
|
</Args>
|
||||||
<Jar>{{ step.jar }}</Jar>
|
<Jar>{{ step.jar }}</Jar>
|
||||||
@ -605,13 +605,13 @@ DESCRIBE_STEP_TEMPLATE = """<DescribeStepResponse xmlns="http://elasticmapreduce
|
|||||||
{% for key, val in step.properties.items() %}
|
{% for key, val in step.properties.items() %}
|
||||||
<member>
|
<member>
|
||||||
<key>{{ key }}</key>
|
<key>{{ key }}</key>
|
||||||
<value>{{ val }}</value>
|
<value>{{ val | escape }}</value>
|
||||||
</member>
|
</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Properties>
|
</Properties>
|
||||||
</Config>
|
</Config>
|
||||||
<Id>{{ step.id }}</Id>
|
<Id>{{ step.id }}</Id>
|
||||||
<Name>{{ step.name }}</Name>
|
<Name>{{ step.name | escape }}</Name>
|
||||||
<Status>
|
<Status>
|
||||||
<!-- does not exist for botocore 1.4.28
|
<!-- does not exist for botocore 1.4.28
|
||||||
<FailureDetails>
|
<FailureDetails>
|
||||||
@ -646,7 +646,7 @@ LIST_BOOTSTRAP_ACTIONS_TEMPLATE = """<ListBootstrapActionsResponse xmlns="http:/
|
|||||||
<member>
|
<member>
|
||||||
<Args>
|
<Args>
|
||||||
{% for arg in bootstrap_action.args %}
|
{% for arg in bootstrap_action.args %}
|
||||||
<member>{{ arg }}</member>
|
<member>{{ arg | escape }}</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Args>
|
</Args>
|
||||||
<Name>{{ bootstrap_action.name }}</Name>
|
<Name>{{ bootstrap_action.name }}</Name>
|
||||||
@ -760,22 +760,22 @@ LIST_STEPS_TEMPLATE = """<ListStepsResponse xmlns="http://elasticmapreduce.amazo
|
|||||||
<Config>
|
<Config>
|
||||||
<Args>
|
<Args>
|
||||||
{% for arg in step.args %}
|
{% for arg in step.args %}
|
||||||
<member>{{ arg }}</member>
|
<member>{{ arg | escape }}</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Args>
|
</Args>
|
||||||
<Jar>{{ step.jar }}</Jar>
|
<Jar>{{ step.jar | escape }}</Jar>
|
||||||
<MainClass/>
|
<MainClass/>
|
||||||
<Properties>
|
<Properties>
|
||||||
{% for key, val in step.properties.items() %}
|
{% for key, val in step.properties.items() %}
|
||||||
<member>
|
<member>
|
||||||
<key>{{ key }}</key>
|
<key>{{ key }}</key>
|
||||||
<value>{{ val }}</value>
|
<value>{{ val | escape }}</value>
|
||||||
</member>
|
</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Properties>
|
</Properties>
|
||||||
</Config>
|
</Config>
|
||||||
<Id>{{ step.id }}</Id>
|
<Id>{{ step.id }}</Id>
|
||||||
<Name>{{ step.name }}</Name>
|
<Name>{{ step.name | escape }}</Name>
|
||||||
<Status>
|
<Status>
|
||||||
<!-- does not exist for botocore 1.4.28
|
<!-- does not exist for botocore 1.4.28
|
||||||
<FailureDetails>
|
<FailureDetails>
|
||||||
|
@ -443,7 +443,7 @@ def test_bootstrap_actions():
|
|||||||
BootstrapAction(
|
BootstrapAction(
|
||||||
name='bs1',
|
name='bs1',
|
||||||
path='path/to/script',
|
path='path/to/script',
|
||||||
bootstrap_action_args=['arg1', 'arg2']),
|
bootstrap_action_args=['arg1', 'arg2&arg3']),
|
||||||
BootstrapAction(
|
BootstrapAction(
|
||||||
name='bs2',
|
name='bs2',
|
||||||
path='path/to/anotherscript',
|
path='path/to/anotherscript',
|
||||||
@ -551,7 +551,7 @@ def test_steps():
|
|||||||
input='s3n://elasticmapreduce/samples/wordcount/input',
|
input='s3n://elasticmapreduce/samples/wordcount/input',
|
||||||
output='s3n://output_bucket/output/wordcount_output'),
|
output='s3n://output_bucket/output/wordcount_output'),
|
||||||
StreamingStep(
|
StreamingStep(
|
||||||
name='My wordcount example2',
|
name='My wordcount example & co.',
|
||||||
mapper='s3n://elasticmapreduce/samples/wordcount/wordSplitter2.py',
|
mapper='s3n://elasticmapreduce/samples/wordcount/wordSplitter2.py',
|
||||||
reducer='aggregate',
|
reducer='aggregate',
|
||||||
input='s3n://elasticmapreduce/samples/wordcount/input2',
|
input='s3n://elasticmapreduce/samples/wordcount/input2',
|
||||||
|
Loading…
Reference in New Issue
Block a user