Last active
April 3, 2018 22:48
-
-
Save alfredcai/712f711147dbe75a854a5d989544d613 to your computer and use it in GitHub Desktop.
set dataset quota by FreeNas API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatasetResource(DojoResource): | |
# ...other functions | |
def obj_create(self, bundle, **kwargs): | |
bundle = self.full_hydrate(bundle) | |
props = None | |
dataset_quota = bundle.data.get('quota') | |
if dataset_quota: | |
props = { | |
'casesensitivity':'sensitive', | |
'compression':'inherit', | |
'atime':'inherit', | |
'quota':dataset_quota.__str__() | |
} | |
err, msg = notifier().create_zfs_dataset( | |
path='%s/%s' % (kwargs.get('parent').vol_name, bundle.data.get('name')), | |
props=props) | |
if err != 0: | |
bundle.errors['__all__'] = msg | |
raise ImmediateHttpResponse( | |
response=self.error_response(bundle.request, bundle.errors) | |
) | |
else: | |
notifier().dataset_init_unix('%s/%s' % (kwargs.get('parent').vol_name,bundle.data.get('name'))) | |
# FIXME: authorization | |
bundle.obj = self.obj_get(bundle, pk=bundle.data.get('name'), **kwargs) | |
return bundle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
F*ng awesome, you best!