[ovirt-users] Documentation of cloud-init

Amedeo Salvati amedeo at oscert.net
Fri Jul 25 10:59:21 UTC 2014


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>
...

- 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 )
...

HTH
Amedeo Salvati
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20140725/7e2e3cdb/attachment-0001.html>


More information about the Users mailing list