<div dir="ltr"><div>Hi Juan,<br><br></div>I tried with the above touch command but it seems the &#39;iwashere&#39; file isn&#39;t created after executing it the above command.<br></div><div class="gmail_extra"><br clear="all">
<div><div dir="ltr"><span>-- <br></span>Regards
<br>Shanil
</div></div>
<br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 3:02 PM, Juan Hernandez <span dir="ltr">&lt;<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On 09/04/2014 10:58 AM, Shanil S wrote:<br>
&gt; Hi Juan,<br>
&gt;<br>
</div><div class="">&gt; Okay.. Thanks for your update. Also i found some sample cloud init<br>
&gt; scripts from here<br>
&gt; <a href="https://github.com/number5/cloud-init/tree/master/doc/examples" target="_blank">https://github.com/number5/cloud-init/tree/master/doc/examples</a> and i<br>
&gt; tried the following scripts<br>
&gt;<br>
&gt; - type: foo/wark<br>
&gt; filename: bar<br>
&gt; content: |<br>
&gt; This is my payload<br>
&gt; hello<br>
&gt; - this is also payload<br>
&gt; - |<br>
&gt; multi line payload<br>
&gt; here<br>
&gt; -<br>
&gt; type: text/upstart-job<br>
&gt; filename: my-upstart.conf<br>
&gt; content: |<br>
&gt; Test file contents<br>
&gt;<br>
&gt; And run the start vm using the above script using cloud init and api,<br>
&gt; Could you please tell me where i can find the result of the above script ?<br>
&gt; I think the above script will create a file like my-upstart.conf<br>
&gt;<br>
<br>
</div>As I said I am not a cloud-init expert, so I don&#39;t really know what is<br>
the meaning or effect of this script. But I think that you need to use<br>
the &quot;runcmd&quot; option. For example:<br>
<br>
&lt;action&gt;<br>
  ...<br>
  &lt;initialization&gt;<br>
    &lt;cloud-init&gt;...&lt;/cloud-init&gt;<br>
    &lt;custom-script&gt;&lt;![CDATA[runcmd:<br>
 - touch /iwashere<br>
]]&gt;&lt;/custom-script&gt;<br>
  &lt;/initialization&gt;<br>
&lt;/action&gt;<br>
<br>
If you use this it should run the &quot;touch /iwashere&quot; command, and you can<br>
check that it did verifying that the &quot;/iwashere&quot; file exists.<br>
<br>
As I said I didn&#39;t test this, so I may not work. I&#39;d appreciate if you<br>
can test it, and once it works update the wiki with the correct<br>
instructions:<br>
<br>
<a href="http://www.ovirt.org/REST-Api#How_can_I_run_a_custom_script_using_cloud-init.3F" target="_blank">http://www.ovirt.org/REST-Api#How_can_I_run_a_custom_script_using_cloud-init.3F</a><br>
<div class=""><br>
&gt;<br>
&gt; On Thu, Sep 4, 2014 at 1:56 PM, Juan Hernandez &lt;<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
</div><div><div class="h5">&gt; &lt;mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     On 09/04/2014 06:29 AM, Shanil S wrote:<br>
&gt;     &gt; Hi Juan,<br>
&gt;     &gt;<br>
&gt;     &gt; Is there anyways to specify the custom script from a file in the xml ?<br>
&gt;     &gt; ie, i have a script in a file called script.sh and i would like to<br>
&gt;     &gt; include this script in the xml with the api call. Is there any methods<br>
&gt;     &gt; for this ?<br>
&gt;     &gt;<br>
&gt;<br>
&gt;     You can deploy files using cloud-init, and the run them using the custom<br>
&gt;     script. Something like this:<br>
&gt;<br>
&gt;       &lt;action&gt;<br>
&gt;         ...<br>
&gt;         &lt;initialization&gt;<br>
&gt;           &lt;cloud-init&gt;<br>
&gt;             &lt;files&gt;<br>
&gt;               &lt;file name=&quot;/root/myscript.sh&quot;/&gt;<br>
&gt;                 &lt;content&gt;&lt;![CDATA[#!/bin/sh the content of your<br>
&gt;     script]]&gt;&lt;/content&gt;<br>
&gt;               &lt;/file&gt;<br>
&gt;             &lt;/files&gt;<br>
&gt;           &lt;/cloud-init&gt;<br>
&gt;           &lt;custom_script&gt;&lt;![CDATA[runcmd:<br>
&gt;      - sh /root/myscript.sh<br>
&gt;     ]]&gt;&lt;/custom_script&gt;<br>
&gt;         &lt;/initialization&gt;<br>
&gt;       &lt;/action&gt;<br>
&gt;<br>
&gt;     But I&#39;m not a cloud-init expert, and I didn&#39;t test this, so I don&#39;t<br>
&gt;     really know if the custom_script will run before or after the files are<br>
&gt;     deployed. It makes more sense to run the scripts after deploying the<br>
&gt;     files, but you will have to test it yourself.<br>
&gt;<br>
&gt;     The content of the files and the scripts has to be embedded in the XML<br>
&gt;     document that you send to the RESTAPI server, there is no way to send an<br>
&gt;     XML document and a separate file. Building this kind of XML document<br>
&gt;     shouldn&#39;t be complicated if you use the CDATA syntax like in the example<br>
&gt;     above.<br>
&gt;<br>
&gt;     Another thing that you may consider, if you have to run a complicated<br>
&gt;     script or set of scripts, is to have them pre-installed in the template<br>
&gt;     that you use to create the VM, then you just need to run them.<br>
&gt;<br>
&gt;     &gt; --<br>
&gt;     &gt; Regards<br>
&gt;     &gt; Shanil<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt; On Tue, Sep 2, 2014 at 3:02 PM, Shanil S &lt;<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a><br>
&gt;     &lt;mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>&gt;<br>
</div></div>&gt;     &gt; &lt;mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a> &lt;mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>&gt;&gt;&gt;<br>
<div class="im HOEnZb">&gt;     wrote:<br>
&gt;     &gt;<br>
&gt;     &gt;     Hi Juan,<br>
&gt;     &gt;<br>
&gt;     &gt;     Thanks for the solution.<br>
&gt;     &gt;<br>
&gt;     &gt;     --<br>
&gt;     &gt;     Regards<br>
&gt;     &gt;     Shanil<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;     On Tue, Sep 2, 2014 at 2:59 PM, Juan Hernandez<br>
&gt;     &lt;<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> &lt;mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>&gt;<br>
</div><div class="HOEnZb"><div class="h5">&gt;     &gt;     &lt;mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> &lt;mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>&gt;&gt;&gt; wrote:<br>

&gt;     &gt;<br>
&gt;     &gt;         On 09/02/2014 05:46 AM, Shanil S wrote:<br>
&gt;     &gt;         &gt; Hi All,<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt; From the ovirt admin panel, there is an option to give the<br>
&gt;     &gt;         custom script<br>
&gt;     &gt;         &gt; in the cloud init ( Run Once-&gt; cloud init- &gt; Custom<br>
&gt;     script ).<br>
&gt;     &gt;         Is there<br>
&gt;     &gt;         &gt; any ways to pass the custom script to cloud init using the<br>
&gt;     &gt;         rest api ?<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;         The custom script should go inside the &quot;custom_script&quot; element<br>
&gt;     &gt;         inside<br>
&gt;     &gt;         the &quot;initialization&quot; element:<br>
&gt;     &gt;<br>
&gt;     &gt;           &lt;action&gt;<br>
&gt;     &gt;             ...<br>
&gt;     &gt;             &lt;initialization&gt;<br>
&gt;     &gt;               &lt;cloud_init&gt;...&lt;/cloud_init&gt;<br>
&gt;     &gt;               &lt;custom_script&gt;your custom script&lt;/custom_script&gt;<br>
&gt;     &gt;             &lt;/initialization&gt;<br>
&gt;     &gt;           &lt;/action&gt;<br>
&gt;     &gt;<br>
<br>
<br>
<br>
--<br>
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>
3ºD, 28016 Madrid, Spain<br>
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.<br>
</div></div></blockquote></div><br></div>