dbmanage: add getaction

This commit is contained in:
boyska 2019-11-02 16:01:52 +01:00
parent 2d84c6b696
commit 4aaf0acd62

View file

@ -1,4 +1,5 @@
from __future__ import print_function
import sys
import argparse
import json
@ -9,7 +10,12 @@ from .config import get_conf
def main_list(args):
m = EventModel(args.file)
for alarm, action in m.get_all_alarms_expanded():
print(json.dumps(dict(alarm=alarm, action=action), indent=4))
json.dump(dict(alarm=alarm, action=action), sys.stdout, indent=4)
def main_getaction(args):
m = EventModel(args.file)
json.dump(m.get_action_by_id(int(args.actionid)), sys.stdout, indent=4)
def main_add(args):
@ -29,6 +35,11 @@ def main():
sub = p.add_subparsers()
sub_list = sub.add_parser("list")
sub_list.set_defaults(func=main_list)
sub_getaction = sub.add_parser("getaction")
sub_getaction.set_defaults(func=main_getaction)
sub_getaction.add_argument('actionid')
sub_add = sub.add_parser("add")
sub_add.add_argument("--interval", type=int, default=3600)
sub_add.set_defaults(func=main_add)