Set permissions for new dataset created from python script

Joined
Jan 3, 2019
Messages
8
Hello,

I have a python script that creates a dataset and a nfs share.
It was really simple to implement based on basic Freenas python function but I also need to set default persmissions for this newly created dataset.

Is there a way to do this from python like from the web interface under Dataset > Change permissions? I mainly need to change the group ownership.

Thanks for your help,
Kevin
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,544
Hello,

I have a python script that creates a dataset and a nfs share.
It was really simple to implement based on basic Freenas python function but I also need to set default persmissions for this newly created dataset.

Is there a way to do this from python like from the web interface under Dataset > Change permissions? I mainly need to change the group ownership.

Thanks for your help,
Kevin
You may want to look into using the rest API for this.
 
Joined
Jan 3, 2019
Messages
8
You may want to look into using the rest API for this.
Thank you for your answer.

That's exaclty what I'm doing so far. I should have been clearer in my question.

But using the following function, I don't know how to pass additional information such as ownership.
Code:
    def __create_dataset(self, path, **kwargs):
        parent, name = os.path.split(path)
        data = {'name': name}
        if kwargs:
            data.update(kwargs)
        self.request('/storage/dataset/%s' % parent, method='POST', data=data)


Can I append this to data through kwargs?

Kind regards,
Kevin
 
Last edited:
Top