ONTAP Rest API Discussions

Qos Policy Delete Fails "entry does not exist"

kramar
2,610 Views

 

Leveraging example to delete QoS policy from https://library.netapp.com/ecmdocs/ECMLP2858435/html/resources/qos_policy.html

 

from netapp_ontap import HostConnection

from netapp_ontap.resources import QosPolicy

with HostConnection( "172.21.69.245", username="admin", password="password", verify=False 😞

resource = QosPolicy(uuid="d38bafc0-5a51-11e9-bd5b-005056ac6f1f")

resource.delete(return_timeout=0) 

 

returns the following error

Traceback (most recent call last):
File "./qospolicy_get.py", line 7, in <module>
resource.delete(return_timeout=0)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/resources/qos_policy.py", line 307, in delete
return super()._delete(
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 50, in wrapper
return on_api_fail(error)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 72, in on_api_fail
raise NetAppRestError(cause=error) from None
netapp_ontap.error.NetAppRestError: Caused by HTTPError('404 Client Error: Not Found for url: https://192.168.112.80:443/api/storage/qos/policies?return_timeout=0'): entry doesn't exist

1 ACCEPTED SOLUTION

kramar
2,594 Views

Thanks David

 

Was too lazy to post my actual code, I did use a QOS uuid that exists see below

 

from netapp_ontap import HostConnection
from netapp_ontap.resources import QosPolicy

with HostConnection(
"192.168.112.80", username="admin", password="*****", verify=False
😞
resource = QosPolicy(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5")
resource.delete(return_timeout=0)

 

Traceback (most recent call last):
File "./qos_delete.py", line 8, in <module>
resource.delete(return_timeout=0)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/resources/qos_policy.py", line 307, in delete
return super()._delete(
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 50, in wrapper
return on_api_fail(error)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 72, in on_api_fail
raise NetAppRestError(cause=error) from None
netapp_ontap.error.NetAppRestError: Caused by HTTPError('404 Client Error: Not Found for url: https://192.168.112.80:443/api/storage/qos/policies?return_timeout=0'): entry doesn't exist

 

cluster97::> qos policy-group show -fields policy-group,vserver,class,uuid
policy-group vserver uuid class
------------ ------- ------------------------------------ ------------
test svm0 aa663668-0e8f-11eb-9bc3-000c295dcee5 user-defined
test2 svm0 40d822ac-0e90-11eb-9bc3-000c295dcee5 user-defined

 

However 

QosPolicy.delete_collection(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5") 

 

Does work, not sure why the python libraries do not like

QosPolicy.delete(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5")

 

Thanks for your help

View solution in original post

3 REPLIES 3

RobertBlackhart
2,608 Views

That UUID that you tried is the same one from the example. I doubt that is the same as the one on your system. The 404 error is ONTAP saying that there is no resource at that location.

 

You should either do a get_collection() to iterate over all records to find the one that you want to delete, or you should use .find() with some query to find the single one you want.

 

Since a QosPolicy has a name, using find() is probably the easiest way. You might write something like this:

from netapp_ontap import HostConnection
from netapp_ontap.resources import QosPolicy

with HostConnection( "172.21.69.245", username="admin", password="password", verify=False):
    QosPolicy.find(name="myPolicyName").delete()

 

You could alternatively use delete_collection() if you wanted to delete multiple with one call:

 

from netapp_ontap import HostConnection
from netapp_ontap.resources import QosPolicy

with HostConnection( "172.21.69.245", username="admin", password="password", verify=False):
    QosPolicy.delete_collection(name="myPolicy*")

 

Which would delete all QoS policies that had a name starting with "myPolicy".

kramar
2,595 Views

Thanks David

 

Was too lazy to post my actual code, I did use a QOS uuid that exists see below

 

from netapp_ontap import HostConnection
from netapp_ontap.resources import QosPolicy

with HostConnection(
"192.168.112.80", username="admin", password="*****", verify=False
😞
resource = QosPolicy(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5")
resource.delete(return_timeout=0)

 

Traceback (most recent call last):
File "./qos_delete.py", line 8, in <module>
resource.delete(return_timeout=0)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/resources/qos_policy.py", line 307, in delete
return super()._delete(
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 50, in wrapper
return on_api_fail(error)
File "/usr/local/lib/python3.8/dist-packages/netapp_ontap/utils.py", line 72, in on_api_fail
raise NetAppRestError(cause=error) from None
netapp_ontap.error.NetAppRestError: Caused by HTTPError('404 Client Error: Not Found for url: https://192.168.112.80:443/api/storage/qos/policies?return_timeout=0'): entry doesn't exist

 

cluster97::> qos policy-group show -fields policy-group,vserver,class,uuid
policy-group vserver uuid class
------------ ------- ------------------------------------ ------------
test svm0 aa663668-0e8f-11eb-9bc3-000c295dcee5 user-defined
test2 svm0 40d822ac-0e90-11eb-9bc3-000c295dcee5 user-defined

 

However 

QosPolicy.delete_collection(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5") 

 

Does work, not sure why the python libraries do not like

QosPolicy.delete(uuid="aa663668-0e8f-11eb-9bc3-000c295dcee5")

 

Thanks for your help

RobertBlackhart
2,591 Views

OK, now that I take another look at your latest output, I see that the Python library is not filling in the UUID as part of the URL. The problem here is that the YAML docs (partly from which the library is generated) for the qos endpoint are specified as thus:

/storage/qos/policies/{policy.uuid}

 

So, the library is looking for a policy.uuid field to use as the key and not uuid. But the YAML docs are wrong (i.e. ONTAP isn't implemented that way) and need to be updated. This will be fixed when version 9.8.0rc1 of the library is released (will be released at the same time 9.8RC1 of ONTAP is generally available).

 

The workaround in the meantime is to use one of the methods below where you don't set the uuid directly but instead use find() or delete_collection().

Public