<div dir="ltr"><div>Hi Juan,<br><br></div>I tried the following <br><div><div><div><br><action><br>
<vm><br>
<initialization><br>
<cloud_init><br>
...<br>
<files><br> <file><br> <name>ignored</name><br> <content><![CDATA[write_files:<br> -content: |<br> Some Content for my file<br> path: /tmp/myfile<br> permissions: '0644']]></content><br> <type>plaintext</type><br> </file><br> </files><span class="im"><br>
</span> </cloud_init><br>
<custom_script><![CDATA[<br>write_files:<br> -content: |<br> Some Content for my file<br> path: /tmp/myfile<br> permissions: '0644']]</custom_script><br><br> <br>But in that time i go the following errors from the api<br>Request syntactically incorrect. See the link description below for the correct usage:start a virtual machine in the system identified by the given idPOST<br>Content-Typeapplication/xml|json<br><br><br></div><div>If i change the xml format like <br><br><action><br>
<vm><br>
<initialization><br>
<cloud_init><br>
...<br>
<files><br> <file><br> <name>ignored</name><br> <content><![CDATA[write_files:<br> -content: |<br> Some Content for my file <br> path: /tmp/myfile<br> permissions: '0644']]></content><br> <type>plaintext</type><br> </file><br> </files><span class="im"><br>
</span> </cloud_init><br>
<custom_script><br>write_files:<br> -content: |<br> Some Content for my file<br> path: /tmp/myfile<br> permissions: '0644'</custom_script><br><br></div><div>the cloud init part won't work even though we didn't get any errors from the api. Could you please check it ?<br><br></div><div><br></div></div></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><span>-- <br></span>Regards
<br>Shanil
</div></div>
<br><div class="gmail_quote">On Thu, Sep 11, 2014 at 6:16 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"><span class="">On 09/11/2014 12:51 PM, Shanil S wrote:<br>
> Hi Juan,<br>
><br>
</span><span class="">> Also, i tried the following custom script from the ovirt panel and its<br>
> working<br>
><br>
> #cloud-config<br>
> write_files:<br>
> -content: |<br>
> # THIS IS MY TEXT FILE<br>
> Some Content for my file<br>
> path: /tmp/myfile<br>
> permissions: '0644'<br>
><br>
><br>
> but the same content script i tried from the ovir api call like<br>
><br>
> <custom_script>#cloud-config<br>
> write_files:<br>
> -content: |<br>
> # THIS IS MY TEXT FILE<br>
> Some Content for my file<br>
> path: /tmp/myfile<br>
> permissions: '0644' </custom_script><br>
> </initialization><br>
><br>
> But its not working, may be this is a bug in the ovirt api function call ?<br>
><br>
<br>
</span>Currently the "custom_script" element doesn't work in combination with<br>
"cloud-init". To make it work you will have to use the "files" element:<br>
<br>
<action><br>
<vm><br>
<initialization><br>
<cloud_init><br>
...<br>
<files><br>
<file><br>
<name>this is ignored</name><br>
<content><![CDATA[your script]]></content><br>
<span class=""> <type>plaintext</type><br>
</file><br>
</files><br>
</span> </cloud_init><br>
</initialization><br>
</vm><br>
</action><br>
<br>
As I wrote before there is a bug related to this:<br>
<br>
<a href="https://bugzilla.redhat.com/1138564" target="_blank">https://bugzilla.redhat.com/1138564</a><br>
<br>
If that bug is fixed (unlikely according to the last comments) then the<br>
"custom_script" element will start working, but for know I suggest you<br>
include your custom script in both places:<br>
<br>
<action><br>
<vm><br>
<initialization><br>
<cloud_init><br>
...<br>
<files><br>
<file><br>
<name>this is ignored</name><br>
<content><![CDATA[your script]]></content><br>
<span class=""> <type>plaintext</type><br>
</file><br>
</files><br>
</span> </cloud_init><br>
<custom_script><![CDATA[your script]]></custom_script><br>
<span class="im HOEnZb"> </initialization><br>
</vm><br>
</action><br>
<br>
><br>
> --<br>
> Regards<br>
> Shanil<br>
><br>
</span><span class="im HOEnZb">> On Thu, Sep 11, 2014 at 3:36 PM, Shanil S <<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a><br>
</span><span class="im HOEnZb">> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>>> wrote:<br>
><br>
> Hi Juan,<br>
><br>
</span><div class="HOEnZb"><div class="h5">> Okay sure..<br>
> The following xml i used<br>
><br>
> <action><br>
> <vm><br>
> <os><br>
> <boot dev='cdrom'/><br>
> </os><br>
> <initialization><br>
> <cloud_init><br>
> <host><br>
> <address>test2</address><br>
> </host><br>
><br>
> <users><br>
> <user><br>
> <user_name>root</user_name><br>
> <password>test</password><br>
> </user><br>
> </users><br>
> <network_configuration><br>
> <nics><br>
><br>
> <nic><br>
> <interface>virtio</interface><br>
> <name>eth0</name><br>
> <boot_protocol>none</boot_protocol><br>
> <on_boot>true</on_boot><br>
> </nic><br>
> </nics><br>
> <dns><br>
> <servers><br>
> <host><br>
> <address>x.x.x.x</address><br>
> </host><br>
> </servers><br>
> </dns><br>
> </network_configuration><br>
> </cloud_init><br>
> <custom_script> #cloud-config<br>
><br>
> phone_home:<br>
> url: <a href="http://x.x.com/api/xx/api_receive.php" target="_blank">http://x.x.com/api/xx/api_receive.php</a><br>
><br>
> </custom_script><br>
> </initialization><br>
> </vm><br>
> </action><br>
><br>
><br>
><br>
> --<br>
> Regards<br>
> Shanil<br>
><br>
> On Thu, Sep 11, 2014 at 1:48 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
</div></div><div class="HOEnZb"><div class="h5">> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>> wrote:<br>
><br>
> On 09/11/2014 06:54 AM, Shanil S wrote:<br>
> > Hi Juan,<br>
> ><br>
> > It seems the it doesn't contains the "phone_home " section in<br>
> the cat<br>
> > /mnt/openstack/latest/user_data<br>
> ><br>
> > the following is the output<br>
> ><br>
> > #cloud-config<br>
> > ssh_pwauth: true<br>
> > disable_root: 0<br>
> > output:<br>
> > all: '>> /var/log/cloud-init-output.log'<br>
> > user: root<br>
> > password: admin123<br>
> > chpasswd:<br>
> > expire: false<br>
> > runcmd:<br>
> > - 'sed -i ''/^datasource_list: /d'' /etc/cloud/cloud.cfg; echo<br>
> > ''datasource_list:<br>
> > ["NoCloud", "ConfigDrive"]'' >> /etc/cloud/cloud.cfg'<br>
> ><br>
> ><br>
> > but if i try with the<br>
> ><br>
> > <files><br>
> > <file><br>
> > <name>ignored</name><br>
> > <content><![CDATA[runcmd:<br>
> > - echo 'Test script !' > /iwashere_test.txt<br>
> > ]]></content><br>
> > <type>plaintext</type><br>
> > </file><br>
> > </files><br>
> ><br>
> > then it will create the /iwashere_test.txt and write the<br>
> contents and in<br>
> > that time the cat /mnt/openstack/latest/user_data is<br>
> ><br>
> > cat /mnt/openstack/latest/user_data<br>
> > #cloud-config<br>
> > ssh_pwauth: true<br>
> > disable_root: 0<br>
> > output:<br>
> > all: '>> /var/log/cloud-init-output.log'<br>
> > user: root<br>
> > password: admin123<br>
> > chpasswd:<br>
> > expire: false<br>
> > runcmd:<br>
> > - 'sed -i ''/^datasource_list: /d'' /etc/cloud/cloud.cfg; echo<br>
> > ''datasource_list:<br>
> > ["NoCloud", "ConfigDrive"]'' >> /etc/cloud/cloud.cfg'<br>
> > runcmd:<br>
> > - echo 'Test script !' > /iwashere_test.txt<br>
> ><br>
> > so, i think the custom script section is not working, i am<br>
> attaching the<br>
> > vm log as a screenshot.<br>
> ><br>
><br>
> Can you share the XML document that you sent to the RESTAPI in<br>
> order to<br>
> populate the "phone_home" section?<br>
><br>
> > On Wed, Sep 10, 2014 at 2:07 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
</div></div><span class="im HOEnZb">> > <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>
</span><div class="HOEnZb"><div class="h5">> > On 09/10/2014 06:44 AM, Shanil S wrote:<br>
> > > Hi Juan,<br>
> > ><br>
> > > What i am planning to do is to make work the following<br>
> script<br>
> > ><br>
> > > #cloud-config<br>
> > ><br>
> > > # phone_home: if this dictionary is present, then the<br>
> phone_home<br>
> > > # cloud-config module will post specified data back to<br>
> the given<br>
> > > # url<br>
> > > # default: none<br>
> > > # phone_home:<br>
> > > # url: <a href="http://my.foo.bar/$INSTANCE/" target="_blank">http://my.foo.bar/$INSTANCE/</a><br>
> > > # post: all<br>
> > > # tries: 10<br>
> > > #<br>
> > > phone_home:<br>
> > > url: <a href="http://my.example.com/$INSTANCE_ID/" target="_blank">http://my.example.com/$INSTANCE_ID/</a><br>
> > > post: [ pub_key_dsa, pub_key_rsa, pub_key_ecdsa,<br>
> instance_id ]<br>
> > ><br>
> > ><br>
> (<a href="http://cloudinit.readthedocs.org/en/latest/topics/examples.html#run-commands-on-first-boot" target="_blank">http://cloudinit.readthedocs.org/en/latest/topics/examples.html#run-commands-on-first-boot</a>)<br>
> > ><br>
> > > but it wasn't working when i tried, i hope to post the<br>
> above values to<br>
> > > the specific url and get the posted details.<br>
> > ><br>
> ><br>
> > I think it should work, but it depends completely on<br>
> cloud-init itself.<br>
> > I'd suggest you check the content of the generated cloud-init<br>
> > configuration file (as described in a previous mail). If<br>
> it contains the<br>
> > "phone_home" section then you can discard a problem with<br>
> oVirt, and<br>
> > focus on clud-init.<br>
> ><br>
> > ><br>
> > > On Wed, Sep 10, 2014 at 10:02 AM, Shanil S<br>
> <<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>><br>
> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>>><br>
> > > <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>><br>
> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a><br>
> <mailto:<a href="mailto:xielesshanil@gmail.com">xielesshanil@gmail.com</a>>>>> wrote:<br>
> > ><br>
> > > Hi Juan,<br>
> > ><br>
> > > Okay.. Thanks.. its working.<br>
> > ><br>
> > > I would like to execute other page something like test_script.php by<br>
> > > posting some values to it using the cloud init, Is it possible to do<br>
> > > it ?<br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > Regards<br>
> > > Shanil<br>
> > ><br>
> > > On Fri, Sep 5, 2014 at 10:08 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>><br>
</div></div><div class="HOEnZb"><div class="h5">> > > <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>>>> wrote:<br>
> > ><br>
> > > On 09/05/2014 12:55 PM, Shanil S wrote:<br>
> > > > Hi Juan,<br>
> > > ><br>
> > > > Thanks for your reply.<br>
> > > ><br>
> > > > I tried with the above but i was unable to<br>
> find the<br>
> > 'iwashere.txt' after<br>
> > > > executing the above xml.<br>
> > > ><br>
> > ><br>
> > > I repeated the test, this time with 3.4, and it<br>
> worked<br>
> > fine for<br>
> > > me. As<br>
> > > the formatting of the XML is very important I'd<br>
> suggest<br>
> > that you<br>
> > > take<br>
> > > the attached script (instead of copy & paste<br>
> from the mail),<br>
> > > change the<br>
> > > password and VM id and run it.<br>
> > ><br>
> > > There are two kind of things that can go wrong<br>
> here. One<br>
> > is that the<br>
> > > engine/VDSM combination may not be generating<br>
> the right<br>
> > file. To<br>
> > > verify<br>
> > > this start the VM with the attached script, and<br>
> once it is<br>
> > > started go to<br>
> > > the hypervisor where it is running and find the<br>
> corresponding<br>
> > > qemu process:<br>
> > ><br>
> > > # ps -ef | grep -- '-name myvm'<br>
> > ><br>
> > > This will give you a very long command line.<br>
> That command line<br>
> > > should<br>
> > > include a "-drive" option containing the full<br>
> path of the<br>
> > disk image<br>
> > > generated by the engine/VDSM, something like this:<br>
> > ><br>
> > > -drive<br>
> > ><br>
> ><br>
> file=/var/run/vdsm/payload/b5f087d4-022d-4d5f-8a1e-268c562c7bb1.b6fcddff571bb8c2028c61b623d172a6.img<br>
> > ><br>
> > > To inspect its content make a copy (just in<br>
> case) and<br>
> > mount it:<br>
> > ><br>
> > > # cp -drive<br>
> > ><br>
> ><br>
> file=/var/run/vdsm/payload/b5f087d4-022d-4d5f-8a1e-268c562c7bb1.b6fcddff571bb8c2028c61b623d172a6.img<br>
> > > /root/my.img<br>
> > > # mount -o loop,ro /root/my.img /mnt<br>
> > ><br>
> > > Inspect the content:<br>
> > ><br>
> > > # find /mnt<br>
> > > /mnt/openstack<br>
> > > /mnt/openstack/content<br>
> > > /mnt/openstack/content/0000<br>
> > > /mnt/openstack/latest<br>
> > > /mnt/openstack/latest/meta_data.json<br>
> > > /mnt/openstack/latest/user_data<br>
> > ><br>
> > > The content of the custom-script should be at<br>
> the end of the<br>
> > > "user_data"<br>
> > > file, so take a look at that:<br>
> > ><br>
> > > # cat /mnt/openstack/latest/user_data<br>
> > > #cloud-config<br>
> > > ssh_pwauth: true<br>
> > > disable_root: 0<br>
> > > output:<br>
> > > all: '>> /var/log/cloud-init-output.log'<br>
> > > user: root<br>
> > > password: mypassword<br>
> > > chpasswd:<br>
> > > expire: false<br>
> > > runcmd:<br>
> > > - 'sed -i ''/^datasource_list: /d''<br>
> > /etc/cloud/cloud.cfg; echo<br>
> > > ''datasource_list:<br>
> > > ["NoCloud", "ConfigDrive"]'' >><br>
> /etc/cloud/cloud.cfg'<br>
> > > runcmd:<br>
> > > - echo "I was here!" > /iwashere.txt<br>
> > ><br>
> > > If your custom script isn't there then there is some<br>
> > problem in the<br>
> > > engine/VDSM side, otherwise the problem is<br>
> probably in<br>
> > cloud-init<br>
> > > itself, and we will need someone with more<br>
> knowledge of<br>
> > > cloud-init to<br>
> > > debug it.<br>
> > ><br>
> > > Don't forget to umount the file when finished:<br>
> > ><br>
> > > # umount /mnt<br>
> > ><br>
> > > ><br>
> > > > On Fri, Sep 5, 2014 at 3:00 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>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>><br>
> > <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>>><br>
> > > > <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>><br>
> > <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
> <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/05/2014 10:46 AM, Sven Kieske wrote:<br>
> > > > ><br>
> > > > ><br>
> > > > > Am 05.09.2014 10:27, schrieb Juan Hernandez:<br>
> > > > >> Trying to make an example for this I<br>
> discovered that<br>
> > > the "custom_script"<br>
> > > > >> element is currently ignored if the<br>
> "cloud_init"<br>
> > > element is present.<br>
> > > > >> Instead we are taking the content of<br>
> the first "file"<br>
> > > element from the<br>
> > > > >> "cloud_init" element and appending it<br>
> to the<br>
> > cloud-init<br>
> > > configuration<br>
> > > > >> file. I believe that this is a bug, as<br>
> it breaks<br>
> > > backwards compatibility:<br>
> > > > >><br>
> > > > >> <a href="https://bugzilla.redhat.com/1138564" target="_blank">https://bugzilla.redhat.com/1138564</a><br>
> > > > ><br>
> > > > > Thanks for the report, I just proposed<br>
> this as a<br>
> > blocker<br>
> > > for the 3.4.4<br>
> > > > > release as it is a clear regression.<br>
> > > > > Also I rely on this functionality in my<br>
> 3.3. setup<br>
> > and I<br>
> > > want to upgrade<br>
> > > > > to 3.4 so I can't upgrade until this is<br>
> fixed and<br>
> > released.<br>
> > > ><br>
> > > > Agree, I set the bug as a blocker for 3.4.4.<br>
> > > ><br>
> > > > >><br>
> > > > >> However, you can exploit this bug to do<br>
> what you<br>
> > want.<br>
> > > This is an example:<br>
> > > > ><br>
> > > > > Well I guess this is a pretty bad idea,<br>
> because it<br>
> > will<br>
> > > just work<br>
> > > > > until the bug is fixed?<br>
> > > > ><br>
> > > ><br>
> > > > No, what I proposed in the example is to<br>
> put the custom<br>
> > > script in both<br>
> > > > the first "file" inside "clud_init" and in the<br>
> > > "custom_script" element.<br>
> > > > That should work with the current status<br>
> and also<br>
> > if/when<br>
> > > we fix the<br>
> > > > bug.<br>
> > > ><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>