<div dir="ltr">I am attempting to run a VM with a cloud-init script, but can't seem to get the syntax working for the python ovirtsdk4 library. We are running ovirt 4.<div><br></div><div>My cloud init script never appears to work and the users option does not work either. If I use root_password and user_name for types.Initialization (as in the example below) it will generate the correct users, but if I put in the types.CloudInit piece it will break it.</div><div><br></div><div><div>types.Initialization(</div><div> user_name=cloud_init_<wbr>username,</div><div> root_password=cloud_init_<wbr>password,</div><div> regenerate_ssh_keys=True,</div><div> host_name="testingcloudinit",</div><div> nic_configurations=[</div><div> types.NicConfiguration(</div><div> boot_protocol=types.<wbr>BootProtocol.DHCP,</div><div> name='ens3',</div><div> on_boot=True</div><div> )</div><div> ],</div><div> custom_script=cloud_init_<wbr>script</div><div>)</div><div><br></div><div><br></div><div>What I currently have is below. cloud_init_script is the script I want to run as a string. Looking at the REST API documentation it shows that I need to upload the file as a CDATA entry, but I am unsure of how I can ensure that in python. Is there potentially a way I could get the full XML call in python to ensure API compliance?</div><div><br></div><div><div>vm_service.start(</div><div> use_cloud_init=True,</div><div> vm=types.Vm(</div><div> initialization=types.<wbr>Initialization(</div><div> nic_configurations=[types.<wbr>NicConfiguration(</div><div> boot_protocol=types.<wbr>BootProtocol.DHCP,</div><div> name="ens3",</div><div> on_boot=True</div><div> )],</div><div> cloud_init=types.CloudInit(</div><div> files=[types.File(</div><div> name="initialrunner",</div><div> content=cloud_init_script,</div><div> type="plaintext"</div><div> ),</div><div> ],</div><div> users=[types.User(</div><div> user_name=cloud_init_username,</div><div> password=cloud_init_password</div><div> )]</div><div> )</div><div> )</div><div> )</div><div>)</div></div><div><br></div><div>Documentation that I have been using:</div><div><a href="http://www.ovirt.org/develop/release-management/features/cloud/cloud-init-integration/" target="_blank">http://www.ovirt.org/develop/<wbr>release-management/features/<wbr>cloud/cloud-init-integration/</a> (seems old and for a earlier ovirtsdk version)<br></div><div><a href="http://cloudinit.readthedocs.io/en/latest/topics/examples.html#run-commands-on-first-boot" target="_blank">http://cloudinit.readthedocs.<wbr>io/en/latest/topics/examples.<wbr>html#run-commands-on-first-<wbr>boot</a> (official cloud init documentation)<br></div><div><a href="https://www.mail-archive.com/users@ovirt.org/msg35549.html" target="_blank">https://www.mail-archive.com/<wbr>users@ovirt.org/msg35549.html</a> (message board conversation about this REST API)<br></div><div><a href="http://lists.ovirt.org/pipermail/users/2014-September/027198.html" target="_blank">http://lists.ovirt.org/<wbr>pipermail/users/2014-<wbr>September/027198.html</a> (about the cloud-init script specifically)<br></div><div><a href="http://lists.ovirt.org/pipermail/users/2014-November/028878.html" target="_blank">http://lists.ovirt.org/<wbr>pipermail/users/2014-November/<wbr>028878.html</a> (for a old version of ovirtsdk it appears)<br></div><div><a href="http://www.ovirt.org/develop/api/rest-api/rest-api/#How_can_I_run_a_custom_script_using_cloud-init.3F" target="_blank">http://www.ovirt.org/develop/<wbr>api/rest-api/rest-api/#How_<wbr>can_I_run_a_custom_script_<wbr>using_cloud-init.3F</a> (appears to be up to date but just documents the REST API)</div></div></div>