Automating VM creation

Hello All, I am trying to automate the procedure of creating VM from template. I am using python oVirt sdk. My script not only creates but assigns IP to VM and performes runtime configuration. All created VMs should have predefined static IP, thus i can't set ip in template. So i need to somehow modify an ip address on VM's disk image. On RHEL ip is stored in file /etc/sysconfig/network-scripts/icfg-eth0. My options are: 1). Connect to hypervisor via SSH and patch disk (assuming i know the offset of ip on disk image). This will only work for RAW disk images. 2). Connect to hypervisor vis SSH, mount image using libguestfs utils (guestmount). This works on cow disks too. Do i have any other options to modify VM files? What is the best option in terms of security and relaiability? Can i somehow mount disk images stored on hypervisor on another VM? The last step of VM creation is to run it and perform configuration(for ex. ipa-client-install) My script connects to VM using ssh and runs required commands. Is there a better way to run commands on VM? Regards Andrey

Just a quick shot: use cloud-init, which configures vms at first startup, see the docs and this mailing list archives on how to do so. cloud init itself has some shortages and can't handle everything but you can attach custom scripts which handle the rest or simply replace cloud-init inside the vm with your own custom script to parse and interpret cloud-init data. HTH On 24/09/14 13:16, Andrey Tepin wrote:
Do i have any other options to modify VM files? What is the best option in terms of security and relaiability? Can i somehow mount disk images stored on hypervisor on another VM?
-- Mit freundlichen Grüßen / Regards Sven Kieske Systemadministrator Mittwald CM Service GmbH & Co. KG Königsberger Straße 6 32339 Espelkamp T: +49-5772-293-100 F: +49-5772-293-333 https://www.mittwald.de Geschäftsführer: Robert Meyer St.Nr.: 331/5721/1033, USt-IdNr.: DE814773217, HRA 6640, AG Bad Oeynhausen Komplementärin: Robert Meyer Verwaltungs GmbH, HRB 13260, AG Bad Oeynhausen

Thank you for your reply Sven! I will look into cloud-init ---------------------------------------------------------------------------------- Just a quick shot: use cloud-init, which configures vms at first startup, see the docs and this mailing list archives on how to do so. cloud init itself has some shortages and can't handle everything but you can attach custom scripts which handle the rest or simply replace cloud-init inside the vm with your own custom script to parse and interpret cloud-init data. HTH On 24/09/14 13:16, Andrey Tepin wrote:
Do i have any other options to modify VM files? What is the best option in terms of security and relaiability? Can i somehow mount disk images stored on hypervisor on another VM?
-- Mit freundlichen Grüßen / Regards Sven Kieske Systemadministrator Mittwald CM Service GmbH & Co. KG Königsberger Straße 6 32339 Espelkamp T: +49-5772-293-100 F: +49-5772-293-333 https://www.mittwald.de Geschäftsführer: Robert Meyer St.Nr.: 331/5721/1033, USt-IdNr.: DE814773217, HRA 6640, AG Bad Oeynhausen Komplementärin: Robert Meyer Verwaltungs GmbH, HRB 13260, AG Bad Oeynhausen _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (2)
-
Andrey Tepin
-
Sven Kieske