Hello,

Two ways of thinking:

  1. the vdsm hook could be very easy to write so as to make what you desire (ovirtsdk4 is presinstalled on ovirt node):
    import ovirtsdk4 as sdk
    import ovirtsdk4.types as types
    from vdsm.hook import hooking
    # Get the vm name from xml definition:
    domxml = hooking.read_domxml()
    vm_name = domxml.getElementsByTagName('name')[0].firstChild.nodeValue
    print(vm_name)
    connection = sdk.Connection(
    url='https://engine.example.com/ovirt-engine/api',
    username='admin@internal',
    password='password',
    ca_file='ca.pem',
    )
    # Find the virtual machine:
    vms_service = connection.system_service().vms_service()
    vm = vms_service.list(search = vm_name)[0]
    # Find the service that manages the virtual machine:
    vm_service = vms_service.vm_service(vm.id)
    # Start the virtual machine enabling cloud-init and providing the
    # password for the `root` user and the hostname:
    vm_service.start(
    use_cloud_init=True,
    vm=types.Vm(
    initialization=types.Initialization(
    user_name='root',
    root_password='password',
    host_name= vm_name + 'example.com'
    )
    )
    )
    # Close the connection to the server:
    connection.close()
    Then place it as executable in /usr/libexec/vdsm/hooks/before_vm_start on each host that should be able to run the pool vms.

  2. As the web UI already auto fills the VM hostname cloud-init field with the vm name (or fqdn), the VM Hostname should do the same with vm pool, but it doesn't. You could open a RFE for this, it shouldn't be very complicated to patch it.
Le 17/01/2022 à 12:34, Luca Contessa a écrit :
I thought that:- you know the name of the future VM
I will try to clarify: I'm trying to obtain from the oVirt engine the name of the VM created inside the pool.
For example if the VM in pool LinuxPool is called LinuxMachine-1 I want the cloud-init to know that the VM is called LinuxMachine-1 and with this info add the suffix using the method you described.
Again, thank you a lot for the response.
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/GKIRUVQ7R65MH6QU73XVDF5GCQCKDZTK/
-- 
Nathanaël Blanchet

Supervision réseau
SIRE
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 	
Tél. 33 (0)4 67 54 84 55
Fax  33 (0)4 67 54 84 14
blanchet@abes.fr