<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Is there any way to pass parameters to a custom script in ambari ? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234837#M196657</link>
    <description>&lt;P&gt;I'm working on a POC to take NN metadata backup. For this, i'm compressing the NN's metadata using a custom script that i will call through ambari API. (https://community.hortonworks.com/articles/139788/running-custom-scripts-through-ambari.html) . If i simply hardcode the datadirectory name it will work. However, i'm looking to pass them as an argument while submitting the request. Anyone aware of the method ?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jul 2019 13:31:40 GMT</pubDate>
    <dc:creator>narendra_klu9</dc:creator>
    <dc:date>2019-07-05T13:31:40Z</dc:date>
    <item>
      <title>Is there any way to pass parameters to a custom script in ambari ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234837#M196657</link>
      <description>&lt;P&gt;I'm working on a POC to take NN metadata backup. For this, i'm compressing the NN's metadata using a custom script that i will call through ambari API. (https://community.hortonworks.com/articles/139788/running-custom-scripts-through-ambari.html) . If i simply hardcode the datadirectory name it will work. However, i'm looking to pass them as an argument while submitting the request. Anyone aware of the method ?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 13:31:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234837#M196657</guid>
      <dc:creator>narendra_klu9</dc:creator>
      <dc:date>2019-07-05T13:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to pass parameters to a custom script in ambari ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234838#M196658</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="#"&gt;@Narendra Neerukonda&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As the Article Says :&lt;/P&gt;&lt;PRE&gt;Note: You can add comma separated inputs if you need any inputs for the script.&lt;/PRE&gt;&lt;P&gt;you can actually pass the parameters to the script like this :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;curl -u &amp;lt;username&amp;gt;:&amp;lt;password&amp;gt; -X POST -H 'X-Requested-By:ambari' -d'{"RequestInfo":{"context":"Execute my action", "action":"my_action", "parameters" : {"my_input" : "value"}}, "Requests/resource_filters":[{"service_name":"", "component_name":"", "hosts":"&amp;lt;comma_separated_host_names&amp;gt;"}]' &lt;A href="http://&amp;lt;ambari_host&amp;gt;:&amp;lt;port&amp;gt;/api/v1/clusters/&amp;lt;cluster_name&amp;gt;/requests" target="_blank"&gt;http://&amp;lt;ambari_host&amp;gt;:&amp;lt;port&amp;gt;/api/v1/clusters/&amp;lt;cluster_name&amp;gt;/requests&lt;/A&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Where "my_input" is paramter name and "value" is the value to be passed.&lt;/P&gt;&lt;P&gt;Hope this helps. Please accept answer and vote up if it did.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 15:38:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234838#M196658</guid>
      <dc:creator>akhilsnaik</dc:creator>
      <dc:date>2019-07-05T15:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to pass parameters to a custom script in ambari ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234839#M196659</link>
      <description>&lt;P&gt;The above question and the entire response thread below was originally posted in the &lt;A href="https://community.hortonworks.com/spaces/101/index.html"&gt;Community Help&lt;/A&gt; track. On Sat Jul 6 17:30 UTC 2019, a member of the HCC moderation staff moved it to the &lt;A href="https://community.hortonworks.com/spaces/61/operations-track_2.html"&gt;Cloud &amp;amp; Operations&lt;/A&gt; track. The &lt;EM&gt;Community Help Track&lt;/EM&gt; is intended for questions about using the HCC site itself, not technical questions.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 00:36:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234839#M196659</guid>
      <dc:creator>ask_bill_brooks</dc:creator>
      <dc:date>2019-07-07T00:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to pass parameters to a custom script in ambari ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234840#M196660</link>
      <description>&lt;P&gt;My previous comment is still under moderation but the solution is: Apparently, it's mandatory to pass  value for service_name and component_name.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 17:02:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234840#M196660</guid>
      <dc:creator>narendra_klu9</dc:creator>
      <dc:date>2019-07-08T17:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to pass parameters to a custom script in ambari ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234841#M196661</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/18735/asnaik.html" nodeid="18735"&gt;@Akhil S Naik&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;I'm able to pass the parameters now.&lt;/P&gt;&lt;P&gt;However, there is a problem i'm facing when i'm submitting the request with "Requests/resource_filters".&lt;/P&gt;&lt;P&gt;If i do the below, the custom script is executed but, it gets executed on all hosts instead of only server1 and server2:&lt;/P&gt;&lt;P&gt;-d '{"RequestInfo":{"context":"Execute an action", "action" : "stream_file", "parameters" : {"file" : "/hadoop_mount/hdfs.tar.gz"},"service_name" : "", "component_name":"", "hosts":"server1,server2"}}' &lt;A rel="noopener noreferrer noopener noreferrer noopener noreferrer noopener noreferrer" href="http://sl55caehmpc501.visa.com:8080/api/v1/clusters/Qualys_TSR/requests" target="_blank"&gt;http://ambari-server:8080/api/v1/clusters/&amp;lt;clustername&amp;gt;/requests&lt;/A&gt; &lt;/P&gt;&lt;P&gt;To resolve this i added below as per from your above sample:&lt;/P&gt;&lt;P&gt;-d '{"RequestInfo":{"context":"Execute an action", "action" : "stream_file", "parameters" : {"file" : "/hadoop01/hdfs.tar.gz"}},"Requests/resource_filters":[{"service_name" : "", "component_name":"", "hosts":"server1,server2"}]}' &lt;A rel="noopener noreferrer noopener noreferrer noopener noreferrer noopener noreferrer" href="http://sl55caehmpc501.visa.com:8080/api/v1/clusters/Qualys_TSR/requests" target="_blank"&gt;http://ambari-server:8080/api/v1/clusters/&amp;lt;clustername&amp;gt;/requests&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But when i submit this, even though the command goes to only the required hosts, it just goes into hung state (grey colored gears  -  Execution doesn't start at all.) Any idea on what might be blocking the execution ?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;With Regards,&lt;/P&gt;&lt;P&gt;Narendra&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;To the users who will come here in future, the parameter you passed will be available from the configs (config = Script.get_config()) inside your code and at config['roleParams']['my_input'] to be precise.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 21:35:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-any-way-to-pass-parameters-to-a-custom-script-in/m-p/234841#M196661</guid>
      <dc:creator>narendra_klu9</dc:creator>
      <dc:date>2019-07-08T21:35:59Z</dc:date>
    </item>
  </channel>
</rss>

