<div dir="ltr"><div><div>Hi Juan,<br><br>Okay.. Thanks for your update. Also i found some sample cloud init scripts from here <a href="https://github.com/number5/cloud-init/tree/master/doc/examples">https://github.com/number5/cloud-init/tree/master/doc/examples</a> and i 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></div>And run the start vm using the above script using cloud init and api, Could you please tell me where i can find the result of the above script ?<br></div>I think the above script will create a file like my-upstart.conf</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 1:56 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 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>
</div>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>
<div class=""><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>
</div><div class="">> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>>> 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 <<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/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 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>
> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3,<br>
> planta<br>
> 3ºD, 28016 Madrid, Spain<br>
> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red<br>
> Hat S.L.<br>
><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
> <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
<div class="HOEnZb"><div class="h5">><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>