Fix APIv1 bug that prevented deletion of a cloned zvol
I'm trying to delete a cloned ZFS snapshot:
curl -v -X DELETE /api/v1.0/storage/volume/tank/zvols/<volname>/
This returns the following response:
* HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Content-Type: application/json < Content-Length: 121 < Server: Werkzeug/0.14.1 Python/3.6.5 < Date: Tue, 13 Nov 2018 11:30:39 GMT < "The object '<ZFSVol: tank/volname>' has an empty attribute 'description' and doesn't allow a default or null value."
Cloned volumes have the comments/description attribute empty and there is no REST method to PUT a description on an existing Zvol - it can only be set at ZVol creation.
If I use the web GUI to manually set random comments to ZVols, I can then delete them via the API.
In /usr/local/www/freenasUI/api/resources.py, in the ZVolResource class, I made the following change by hand:
- comments = fields.CharField(attribute='description') + comments = fields.CharField(attribute='description', null=True)
And now I can delete ZFS vols via the API without issues.
So, the tastypie-defined comments field for ZVols should be made optional or cloning a snapshot should set a default comment or allow the ZVolResource.put() method to edit the "comments" attribute.