VM create with network interface via the API

Hello all and thank you in advance for your help. I have been able to work out how to add vm via a call to the vms API. I am passing in a template via the api call and that is working. I do not have a network installed in the template. My use case for that was to hit “New vm”, fill in the hostname and network and let cloud-init set the hostname. That way I can create a new vm with just a few clicks. What I can’t seem to figure out is how to define the network interface in the add vm api call. It looks like I should have to add the network interface in a second call after creation. If I add the interface in the <initialization> section for cloud-init I seems to have a chicken and egg problem. When I add the <initialization> section and the data for the ip address, netmask, default gateway, I get; <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <fault> <detail>[Cannot add VM. Static IPv4 address is missing in cloud-init configuration.]</detail> <reason>Operation Failed</reason> </fault> That would seem to indicate to me that I need and interface before I can configure it. That makes sense. But how do I get an interface before I create the vm ? What might I be missing? The desired result is create a vm and set the hostname and ip info via the api so that I get a fully formed vm connected to the network. That gets me to the point of being able to download build scripts to install and start puppet. Alan

On Thu, 20 Sep 2018 18:37:40 -0000 "Alan Bunch" <picsdallas@gmail.com> wrote:
Hello all and thank you in advance for your help.
I have been able to work out how to add vm via a call to the vms API. I am passing in a template via the api call and that is working. I do not have a network installed in the template. My use case for that was to hit “New vm”, fill in the hostname and network and let cloud-init set the hostname. That way I can create a new vm with just a few clicks.
What I can’t seem to figure out is how to define the network interface in the add vm api call. It looks like I should have to add the network interface in a second call after creation. If I add the interface in the <initialization> section for cloud-init I seems to have a chicken and egg problem. When I add the <initialization> section and the data for the ip address, netmask, default gateway, I get; <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <fault> <detail>[Cannot add VM. Static IPv4 address is missing in cloud-init configuration.]</detail> <reason>Operation Failed</reason> </fault>
In https://github.com/oVirt/ovirt-system-tests/blob/master/basic-suite-4.2/test... and https://github.com/oVirt/ovirt-system-tests/blob/master/network-suite-master... are examples of how to use cloud-init.
That would seem to indicate to me that I need and interface before I can configure it. That makes sense. But how do I get an interface before I create the vm ?
If you want to use the python sdk, please find in github.com - ovirt-engine-sdk how to add a vNIC to a VM. You can add the vNIC after VM is created, but before the VM is booted the first time.
What might I be missing?
The desired result is create a vm and set the hostname and ip info via the api so that I get a fully formed vm connected to the network. That gets me to the point of being able to download build scripts to install and start puppet.
Alan _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/YQRSABCJ7Y3L44...

"You can add the vNIC after VM is created, but before the VM is booted the first time." Sometime you just need someone to point out the obvious. For some reason it just never occurred to me to add the nic BEFORE the first start. This is my first time using api to control vms and I am still very low on the learning curve. Thank you so much for pointing me in the correct direction. Alan
participants (2)
-
Alan Bunch
-
Dominik Holler