[ovirt-users] Documentation of cloud-init

Juan Hernandez jhernand at redhat.com
Fri Jul 25 16:44:37 UTC 2014


On 07/25/2014 12:59 PM, Amedeo Salvati wrote:
> Hy guys,
> 
> after some headache I was able to use cloud-init via python-sdk (thanks
> to Juan), and I hope no one will fight anymore with them :D, so if you
> want I think it's better to document with a simple example it's use on
> web page available at:
> 
> http://www.ovirt.org/Features/Cloud-Init_Integration
> 
> below simple change that you can integrate on web page:
> 
> - fix api design example of usage for files xml, on the web page you can
> find:
> 
> ...
>        <files>
>          <file>
>            <name>/tmp/testFile1.txt</name>
>            <content>temp content</content>
>            <type>PLAINTEXT</type>
>          </file>
>        </files>
> ...
> 
> but on params.File there aren't any "type" parameter only "type_" so you
> can change xml with:
> 
> ...
>        <files>
>          <file>
>            <name>/tmp/testFile1.txt</name>
>            <content>temp content</content>
>            <type_>PLAINTEXT</type_>
>          </file>
>        </files>
> ...
> 

This won't be correct, the correct XML tag name is "type", as in the
example in the web page. It is not good idea to use this as a parmeter
in python because it hides the "type" builtin function. That is why we
renamed it to "type_".

> - insert an example of using cloud-init via python-sdk (I hope java-sdk
> haven't big differences).
> 
> for this you can insert on web page an example of setting via
> cloud-init: hostname, reset root password and write a simple text file,
> and finally simple python code is:
> 
> ...
> scontent = "write_files:\n-   content: |\n        #simple file\n       
> PIPPO=\"ciao\"\n    path: /etc/pippo.txt"
> action = params.Action(
>   vm=params.VM(
>     initialization=params.Initialization(
>       cloud_init=params.CloudInit(
>     host=params.Host(address="rheltest029"),
>     users=params.Users(
>       user=[params.User(user_name="root", password="pippolo")]
>       ),
>     files=params.Files(
>       file=[params.File(name="/etc/pippo.txt", content=scontent,
> type_="PLAINTEXT")]
>       )
>     )
>       )
>   )
> )
> vm.start( action )
> ...
> 

I think that you can edit that page and add this Python snippet. If you
don't have an account for the wiki you can request one here:

  http://www.ovirt.org/Special:RequestAccount

And if you want you can also submit a patch for the ovirt-engine-sdk
project, adding your script in the (not yet existing) examples directory.

> HTH
> Amedeo Salvati
> 


-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.



More information about the Users mailing list