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 via 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?