<div dir="ltr"><br><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 30, 2014 at 12:52 PM, Branimir Pejakovic <span dir="ltr"><<a href="mailto:branimirp@gmail.com" target="_blank">branimirp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Oct 30, 2014 at 12:39 PM, Shahar Havivi <span dir="ltr"><<a href="mailto:shaharh@redhat.com" target="_blank">shaharh@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>On 30.10.14 12:30, Branimir Pejakovic wrote:<br>
> On Thu, Oct 30, 2014 at 12:02 PM, Shahar Havivi <<a href="mailto:shaharh@redhat.com" target="_blank">shaharh@redhat.com</a>> wrote:<br>
><br>
> > On 30.10.14 10:06, Branimir Pejakovic wrote:<br>
> > > On Thu, Oct 30, 2014 at 7:22 AM, Shahar Havivi <<a href="mailto:shaharh@redhat.com" target="_blank">shaharh@redhat.com</a>><br>
> > wrote:<br>
> > ><br>
> > > > On 29.10.14 17:35, Branimir Pejakovic wrote:<br>
> > > > > Hi list,<br>
> > > > ><br>
> > > > > I was wondering is there a way to add multiple files to a vm via<br>
> > > > cloud-init<br>
> > > > > using python SDK. I was able to add /etc/resolv.conf and<br>
> > additionally I<br>
> > > > > would like to add config files for NICs (ifcfg-ethX) with appropriate<br>
> > > > > values (ip,gw,netmask). I used an example given here:<br>
> > > > > <a href="http://www.ovirt.org/Features/Cloud-Init_Integration" target="_blank">http://www.ovirt.org/Features/Cloud-Init_Integration</a> . But<br>
> > > > unfortunately I<br>
> > > > > cannot do the same thing If I want to write multiple files to a vm in<br>
> > > > > params.Action class.<br>
> > > > ><br>
> > > > > Thank you in advance!<br>
> > > > you can use the custom script text box in oVirts cloud-init section,<br>
> > > > there you can add any cloud-init section - adding files examples can be<br>
> > > > found<br>
> > > > here:<br>
> > > ><br>
> > > ><br>
> > <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>
> > > ><br>
> > > > Shahar Havivi.<br>
> > > ><br>
> > > ><br>
> > > Hi Shahar,<br>
> > ><br>
> > > Thank you for the reply.<br>
> > ><br>
> > > To be honest I knew for those scripts but I want to do it in automate<br>
> > > fashion just like in that example that I put in my original message. I<br>
> > have<br>
> > > tried to specify in params.Files class multiple files:<br>
> > ><br>
> > > vm_file1 = params.Files(file=[params.File(name = 'file1', content =<br>
> > > file1_content, type_= 'PLAINTEXT')])<br>
> > > vm_file2 = params.Files(file=[params.File(name = 'file2', content =<br>
> > > file2_content, type_= 'PLAINTEXT')])<br>
> > ><br>
> > > and then give them as arguments to params.CloudInit _init_ constructor<br>
> > > (files=...) just like in that example above but it seems that I am doing<br>
> > > something wrong because it does not write multiple files - it writes only<br>
> > > when you specify one file all right. The exception is "Error: 'list'<br>
> > object<br>
> > > has no attribute 'export'" (I tried to specify those files as a list -<br>
> > > files=[vm_file1,vm_file2]).<br>
> > ><br>
> > > Thanks for any help.<br>
> > The custom script is currently the only option to add files via Cloud-Init<br>
> ><br>
> > Thanks,<br>
> > Shahar Havivi.<br>
> ><br>
> ><br>
> Hi Shahar,<br>
><br>
> Granted. But the example in python<br>
> <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>
> I just want to know how to do the same thing in case when I want to write<br>
> more than one file to a VM - and yes - all those multiple files that I<br>
> want to write are specified via custom scripts.<br>
><br>
> From the link - (The "Python SDK" paragraph: scontent object holds the<br>
> custom script):<br>
><br>
> scontent = "write_files:\n- content: |\n search<br>
> <a href="http://example.com" target="_blank">example.com</a>\n nameserver 10.10.10.1\n nameserver<br>
> 10.10.10.2\n path: /etc/resolv.conf"<br>
><br>
> For example (and just for example), I want to write to /etc/issue and<br>
> /etc/hosts not only /etc/resolv.conf. In essence, when vm goes to run-once<br>
> mode I want to write more than one file to a vm via Python (using<br>
> CloudInit) in automated fashion (and not touching oVirt GUI at all).<br>
</div></div>You don'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></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!</div></div></div></div>
</blockquote></div><br><br><div dir="ltr"><div><div><div><div>Hi,<br><br></div>Please if somebody can help me because I
am pretty stuck. As I said in previous posts I used this Python
example <a href="http://www.ovirt.org/Features/Cloud-Init_Integration">http://www.ovirt.org/Features/Cloud-Init_Integration</a> to set root
password, hostname and resolv.conf. It worked without any problems for
3.4 oVirt version and equivalent Python SDK
(ovirt-engine-sdk-python-3.4.x.noarch). <br><br></div><div>Then, I have
tried to write through yuml scripts more conf files than just
resolv.conf to configure guest. I also saw this post on the list:
<a href="http://lists.ovirt.org/pipermail/users/2014-October/028539.html">http://lists.ovirt.org/pipermail/users/2014-October/028539.html</a>. So
based on that, I decided to upgraded oVirt and SDK
(ovirt-engine-sdk-python-3.5.0.7-1.el6.noarch) to 3.5 version. The upgrade itself passed without any
problem. <br><br>From that point forward I tried to use custom_script
parameter (as suggested by Shahar) inside Initialization class and CloudInit class without any
luck. <br></div><div><br></div>Can somebody please provide a simple Python code to submit yaml script to cloud-init?<br> <br>Also
after the upgrade the example script I mentioned above can only change
hostname. It does not write resolv.conf anymore nor it sets root
password. I don't know if something is changed inside methods? For example,
customization of virtual machine (memory,cpu,high availability, pinning
to a certain host etc works without any problems).<br><br></div><div>Thank you!<br><br></div><div>Best regards,<br><br></div>Branimir</div></div>
</div></div>