recipes to dump partition configuration or buildout section in json files
[slapos.git] / slapos / recipe / jsondump.py
1
2 import json
3 import os
4
5 class Recipe(object):
6 def __init__(self, buildout, name, options):
7 parameter_dict = {
8 key: value
9 for key, value in options.items()
10 if key not in ['json-output', 'recipe']
11 }
12
13 with os.fdopen(os.open(options['json-output'], os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
14 fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
15 fout.close()
16
17 def install(self):
18 return []
19