Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Setting dataset quota through API

Joined
Jan 20, 2014
Messages
4
Unfortunately, the API is really limited. If you want the API to officially do your thing, , maybe you could try feature request?

If you really want to get it done, there are, include some very dangerous actions, something you could do to work with thing you could do.

The "best", out of API of course, would be try to simulate login process, get the session and cookies information, and then may be you could post the necessary information to you FreeNAS. Well, It is obviously just login GUI in programmatic way, but I would say it is the best things you could do.

Well, that's it if you want to stay "safe".
 
Joined
Mar 3, 2015
Messages
2
Thanks for your reply!

I was just checking out the possibility of doing it that way. It seems the "internal" API of FreeNAS is returning JSON data which makes it easy to parse and handle. Ofcourse through the official API would be the best, but this would work. Will definitely try a feature request. Should not be too hard to implement. :)
 
Joined
Jan 20, 2014
Messages
4
I have been studying the GUI, and I found that although many page have use JSON, some pages are rendered on the server-side. For example, the page showing system information is already rendered as HTML, which I feel kind of disappointed. Anyway, off-topic.

Hope your implementation goes well.
 
Joined
Sep 2, 2016
Messages
1
My solution is changing the API source code.

first open the ssh service of your server through the Web GUI
then, edit /usr/local/www/freenasUI/api/resources.py like this https://gist.github.com/alfredcai/712f711147dbe75a854a5d989544d613
after that reboot your server

then request example as following:
Code:
POST /api/v1.0/storage/volume/tank/datasets/ HTTP/1.1
Content-Type: application/json
{
  "name": "foo",
  "quota":"5GB"
}

if you still post data like:{"name":"foo"}, it will still create dataset with no quota limit.

I just add quota attribution of dataset.
if you want more attributions, you can refer to dataset_create function in gui/storage/views.py https://github.com/freenas/freenas/blob/master/gui/storage/views.py#L422, which is the create dataset action through Web GUI.
 
Top