<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 12:39 PM, Shahar Havivi <span dir="ltr">&lt;<a href="mailto:shaharh@redhat.com" target="_blank">shaharh@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="HOEnZb"><div class="h5">On 30.10.14 12:30, Branimir Pejakovic wrote:<br>
&gt; On Thu, Oct 30, 2014 at 12:02 PM, Shahar Havivi &lt;<a href="mailto:shaharh@redhat.com">shaharh@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; On 30.10.14 10:06, Branimir Pejakovic wrote:<br>
&gt; &gt; &gt; On Thu, Oct 30, 2014 at 7:22 AM, Shahar Havivi &lt;<a href="mailto:shaharh@redhat.com">shaharh@redhat.com</a>&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; On 29.10.14 17:35, Branimir Pejakovic wrote:<br>
&gt; &gt; &gt; &gt; &gt; Hi list,<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; I was wondering is there a way to add multiple files to a vm via<br>
&gt; &gt; &gt; &gt; cloud-init<br>
&gt; &gt; &gt; &gt; &gt; using python SDK. I was able to add /etc/resolv.conf and<br>
&gt; &gt; additionally I<br>
&gt; &gt; &gt; &gt; &gt; would like to add config files for NICs (ifcfg-ethX) with appropriate<br>
&gt; &gt; &gt; &gt; &gt; values (ip,gw,netmask). I used an example given here:<br>
&gt; &gt; &gt; &gt; &gt; <a href="http://www.ovirt.org/Features/Cloud-Init_Integration" target="_blank">http://www.ovirt.org/Features/Cloud-Init_Integration</a> . But<br>
&gt; &gt; &gt; &gt; unfortunately I<br>
&gt; &gt; &gt; &gt; &gt; cannot do the same thing If I want to write multiple files to a vm in<br>
&gt; &gt; &gt; &gt; &gt; params.Action class.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; Thank you in advance!<br>
&gt; &gt; &gt; &gt; you can use the custom script text box in oVirts cloud-init section,<br>
&gt; &gt; &gt; &gt; there you can add any cloud-init section - adding files examples can be<br>
&gt; &gt; &gt; &gt; found<br>
&gt; &gt; &gt; &gt; here:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; <a href="http://cloudinit.readthedocs.org/en/latest/topics/examples.html#writing-out-arbitrary-files" target="_blank">http://cloudinit.readthedocs.org/en/latest/topics/examples.html#writing-out-arbitrary-files</a><br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;   Shahar Havivi.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; Hi Shahar,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thank you for the reply.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; To be honest I knew for those scripts but I want to do it in automate<br>
&gt; &gt; &gt; fashion just like in that example that I put in my original message. I<br>
&gt; &gt; have<br>
&gt; &gt; &gt; tried to specify in params.Files class multiple files:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; vm_file1 = params.Files(file=[params.File(name = &#39;file1&#39;, content =<br>
&gt; &gt; &gt; file1_content, type_= &#39;PLAINTEXT&#39;)])<br>
&gt; &gt; &gt; vm_file2 = params.Files(file=[params.File(name = &#39;file2&#39;, content =<br>
&gt; &gt; &gt; file2_content, type_= &#39;PLAINTEXT&#39;)])<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; and then give them as arguments to params.CloudInit _init_ constructor<br>
&gt; &gt; &gt; (files=...)  just like in that example above but it seems that I am doing<br>
&gt; &gt; &gt; something wrong because it does not write multiple files - it writes only<br>
&gt; &gt; &gt; when you specify one file all right. The exception is &quot;Error: &#39;list&#39;<br>
&gt; &gt; object<br>
&gt; &gt; &gt; has no attribute &#39;export&#39;&quot; (I tried to specify those files as a list -<br>
&gt; &gt; &gt; files=[vm_file1,vm_file2]).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks for any help.<br>
&gt; &gt; The custom script is currently the only option to add files via Cloud-Init<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt;   Shahar Havivi.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; Hi Shahar,<br>
&gt;<br>
&gt; Granted. But the example in python<br>
&gt; <a href="http://www.ovirt.org/Features/Cloud-Init_Integration" target="_blank">http://www.ovirt.org/Features/Cloud-Init_Integration</a> uses custom script :)<br>
&gt; I just want to know how to do the same thing in case when I want to write<br>
&gt; more than one file to a VM - and yes  - all those multiple files that I<br>
&gt; want to write are specified via custom scripts.<br>
&gt;<br>
&gt; From the link - (The &quot;Python SDK&quot; paragraph: scontent object holds the<br>
&gt; custom script):<br>
&gt;<br>
&gt;  scontent = &quot;write_files:\n-   content: |\n        search<br>
&gt; <a href="http://example.com" target="_blank">example.com</a>\n        nameserver 10.10.10.1\n        nameserver<br>
&gt; 10.10.10.2\n    path: /etc/resolv.conf&quot;<br>
&gt;<br>
&gt; For example (and just for example), I want to write to /etc/issue and<br>
&gt; /etc/hosts not only /etc/resolv.conf. In essence, when vm goes to run-once<br>
&gt; mode I want to write more than one file to a vm via Python (using<br>
&gt; CloudInit) in automated fashion (and not touching oVirt GUI at all).<br>
</div></div>You don&#39;t need to use the GUI,<br>
the sdks initialization have custom_script as string which is equivalent to<br>
the text box that you see in the GUI, and you can put the same content there<br>
(ie multiple files).<br>
Is that sufficient enough?<br></blockquote><div><br></div><div>Hi Shahar,<br><br></div><div>Thanks! I will try this one. I was not aware of this feature. Although I can see that it was mentioned on the list (my bad).<br><br></div><div>Thank you for your effort! I really do appreciate it!<br><br><br></div><div>Best regards,<br><br>Branimir <br></div></div><div class="gmail_signature"><div dir="ltr"><div><br></div></div></div>
</div></div>