jsondump recipe: use GenericBaseRecipe.
[slapos.git] / slapos / recipe / jsondump.py
1
2 from slapos.recipe.librecipe import GenericBaseRecipe
3
4 import json
5 import os
6
7 class Recipe(GenericBaseRecipe):
8
9 def install(self):
10 parameter_dict = {
11 key: value
12 for key, value in self.options.items()
13 if key not in ['json-output', 'recipe']
14 }
15
16 with os.fdopen(os.open(self.options['json-output'], os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
17 fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
18
19 return [self.options['json-output']]
20
21 update = install
22