<div dir="ltr"><div>Hi Juan,<br><br></div>I tried with the above touch command but it seems the 'iwashere' file isn'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"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></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>
> Hi Juan,<br>
><br>
</div><div class="">> Okay.. Thanks for your update. Also i found some sample cloud init<br>
> scripts from here<br>
> <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>
> tried the following scripts<br>
><br>
> - type: foo/wark<br>
> filename: bar<br>
> content: |<br>
> This is my payload<br>
> hello<br>
> - this is also payload<br>
> - |<br>
> multi line payload<br>
> here<br>
> -<br>
> type: text/upstart-job<br>
> filename: my-upstart.conf<br>
> content: |<br>
> Test file contents<br>
><br>
> And run the start vm using the above script using cloud init and api,<br>
> Could you please tell me where i can find the result of the above script ?<br>
> I think the above script will create a file like my-upstart.conf<br>
><br>
<br>
</div>As I said I am not a cloud-init expert, so I don't really know what is<br>
the meaning or effect of this script. But I think that you need to use<br>
the "runcmd" option. For example:<br>
<br>
<action><br>
...<br>
<initialization><br>
<cloud-init>...</cloud-init><br>
<custom-script><![CDATA[runcmd:<br>
- touch /iwashere<br>
]]></custom-script><br>
</initialization><br>
</action><br>
<br>
If you use this it should run the "touch /iwashere" command, and you can<br>
check that it did verifying that the "/iwashere" file exists.<br>
<br>
As I said I didn't test this, so I may not work. I'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>
><br>
> On Thu, Sep 4, 2014 at 1:56 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
</div><div><div class="h5">> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>> wrote:<br>
><br>
> On 09/04/2014 06:29 AM, Shanil S wrote:<br>
> > Hi Juan,<br>
> ><br>
> > Is there anyways to specify the custom script from a file in the xml ?<br>
> > ie, i have a script in a file called script.sh and i would like to<br>
> > include this script in the xml with the api call. Is there any methods<br>
> > for this ?<br>
> ><br>
><br>
> You can deploy files using cloud-init, and the run them using the custom<br>
> script. Something like this:<br>
><br>
> <action><br>
> ...<br>
> <initialization><br>
> <cloud-init><br>
> <files><br>
> <file name="/root/myscript.sh"/><br>
> <content><![CDATA[#!/bin/sh the content of your<br>
> script]]></content><br>
> </file><br>
> </files><br>
> </cloud-init><br>
> <custom_script><![CDATA[runcmd:<br>
> - sh /root/myscript.sh<br>
> ]]></custom_script><br>
> </initialization><br>
> </action><br>
><br>
> But I'm not a cloud-init expert, and I didn't test this, so I don't<br>
> really know if the custom_script will run before or after the files are<br>
> deployed. It makes more sense to run the scripts after deploying the<br>
> files, but you will have to test it yourself.<br>
><br>
> The content of the files and the scripts has to be embedded in the XML<br>
> document that you send to the RESTAPI server, there is no way to send an<br>
> XML document and a separate file. Building this kind of XML document<br>
> shouldn't be complicated if you use the CDATA syntax like in the example<br>
> above.<br>
><br>
> Another thing that you may consider, if you have to run a complicated<br>
> script or set of scripts, is to have them pre-installed in the template<br>
> that you use to create the VM, then you just need to run them.<br>
><br>
> > --<br>
> > Regards<br>
> > Shanil<br>
> ><br>
> ><br>
> > On Tue, Sep 2, 2014 at 3:02 PM, Shanil S <<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a><br>
> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>><br>
</div></div>> > <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>>>><br>
<div class="im HOEnZb">> wrote:<br>
> ><br>
> > Hi Juan,<br>
> ><br>
> > Thanks for the solution.<br>
> ><br>
> > --<br>
> > Regards<br>
> > Shanil<br>
> ><br>
> ><br>
> > On Tue, Sep 2, 2014 at 2:59 PM, Juan Hernandez<br>
> <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
</div><div class="HOEnZb"><div class="h5">> > <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>>> wrote:<br>
> ><br>
> > On 09/02/2014 05:46 AM, Shanil S wrote:<br>
> > > Hi All,<br>
> > ><br>
> > > From the ovirt admin panel, there is an option to give the<br>
> > custom script<br>
> > > in the cloud init ( Run Once-> cloud init- > Custom<br>
> script ).<br>
> > Is there<br>
> > > any ways to pass the custom script to cloud init using the<br>
> > rest api ?<br>
> > ><br>
> ><br>
> > The custom script should go inside the "custom_script" element<br>
> > inside<br>
> > the "initialization" element:<br>
> ><br>
> > <action><br>
> > ...<br>
> > <initialization><br>
> > <cloud_init>...</cloud_init><br>
> > <custom_script>your custom script</custom_script><br>
> > </initialization><br>
> > </action><br>
> ><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>