[ovirt-users] Problem while adding a VM NIC via REST API

Juan Hernández jhernand at redhat.com
Fri Jun 2 14:09:30 UTC 2017


On 06/02/2017 03:56 PM, Bruno Rodriguez wrote:
> Hello everyone,
> 
> I have some scripts that create VMs, which are in perl using libcurl and
> oVirt REST API. They work quite fine but I'm experiencing something unusual.
> 
> After I create the machine (let's suppose it's called server.pic.es
> <http://server.pic.es>) with UUID 123abc I post the following REST API
> call to https://... /vms/123abc/nics 
> 
>                 <nic>
>                 <name>server.pic.es_nic1</name>
>                 <interface>virtio</interface>
>                 <network><name>VLANXXX</name></network>
>                 </nic>
> 
> The NIC is created and attached to the VM but it's network field is
> empty, not in the VLANXXX. I don't know if I'm missing something but
> this worked flawlessly with 3.6.9 REST API.
> 
> Some people could say: "it's because you're using Perl". Yup, that's
> probably a mental issue of mine and I should visit a doctor about using
> it, but it doesn't work even using a fancy REST browser extension to
> send requests (ARC for chromium), anyways the REST reply is a "201:
> Created" that looks OK...
> 
> Any idea or suggestion will be welcome. Thanks in advance!
> 

It is not because of Perl :-) .

In version 4 of the API it is mandatory to specify the NIC profile, as
the network may have multiple profiles. So you need to find the
identifier of that NIC profile and then send a request like this:

  <nic>
    <name>server.pic.es_nic1</name>
    <interface>virtio</interface>
    <vnic_profile id="the_id_of_the_profile"/>
  </nic>

You can find the identifiers of the profiles like this:

  GET /ovirt-engine/api/networks/the_identifier_of_the_network/vnicprofildes

If you want the old behavior, the behavior of version 3 of the API, you
can just add to your request the 'Version: 3' HTTP header. But note that
version 3 of the API is deprecated since version 4.0 of the engine, and
it will be removed with version 4.2 of the engine.


More information about the Users mailing list