[ovirt-users] qos problem in ovirt python sdk

Juan Hernández jhernand at redhat.com
Tue Aug 16 14:57:26 UTC 2016


On 08/16/2016 03:52 AM, like.ma at cs2c.com.cn wrote:
> Hello,
> 
> I'm using ovirt3.6.7, and i want to use QoS function by restapi. But i
> fount i can't update the qos to unlimited. 
> For example, i assigned a qos named qos1 to a vnic profile named
> vprofile1, then i want to set the qos of vprofile1 to unlimited,
> so i set the qos to None in sdk when update vnic profile, but after
> update the vnic profile still has qos named qos1.
> 
> So, how should i do if i want to set qos of a vnic profile to unlimited?
> 
> Look forward to your help!
> Thanks 
> 

This is a general issue with the way the API works: we don't have
different methods for updating or replacing completely the
representation of an object, we use PUT for everything. This means that
we have to assume that when you send a request without an attribute what
you mean is that you want to preserve it. For example, when you send
something like this:

  PUT /ovirt-engine/api/vnicprofiles/123
  <vnic_profile>
    <!-- Empty, trying to reset the QoS, but won't work :-( -->
  </vnic_profile>

We have to assume that you want to preserve the attributes, as otherwise
we would just remove all of them. A side effect of this is that there is
no way to express that what you want to do is remove the QoS.

The workaround for that is to create an unlimited QoS (manually or via
the API) and then update the VNIC profile to use that instead of the
previous one. For example:

---8<---
# Find the data center:
dc = api.datacenters.get(name='mydc')

# Find the "unlimited" QoS, or create it if it doesn't exit
# yet:
unlimited = dc.qoss.get(name='unlimitednetwork')
if unlimited is None:
   unlimited = dc.qoss.add(
       params.QoS(
           name='unlimitednetwork',
           type_='network',
       )
   )

# Find the VNIC profile:
profile = api.vnicprofiles.get(name='myprofile')

# Change the VNIC profile to use the unlimited QoS:
profile.set_qos(
    params.QoS(id=unlimited.get_id())
)
profile.update()
--->8---

-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.



More information about the Users mailing list