/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2016-06-27 20:21:50 UTC
  • Revision ID: teddy@recompile.se-20160627202150-ml201ilxwjf1g29w
mandos-ctl: Implement --dump-json option

* mandos-ctl (main): Implement --dump-json option
* mandos-ctl.xml (NAME, DESCRIPTION): Change description to the more
                                      accurate "control or query".
  (SYNOPSIS): Add required group around action options and add new
              "--dump-json" option.
  (OPTIONS): Document new "--dump-json" option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
    "ApprovalDelay": "Approval Delay",
66
66
    "ApprovalDuration": "Approval Duration",
67
67
    "Checker": "Checker",
68
 
    "ExtendedTimeout": "Extended Timeout",
69
 
    "Expires": "Expires",
70
 
    "LastCheckerStatus": "Last Checker Status",
 
68
    "ExtendedTimeout": "Extended Timeout"
71
69
}
72
70
defaultkeywords = ("Name", "Enabled", "Timeout", "LastCheckedOK")
73
71
domain = "se.recompile"
402
400
                        "ApprovalPending", "ApprovedByDefault",
403
401
                        "LastApprovalRequest", "ApprovalDelay",
404
402
                        "ApprovalDuration", "Checker",
405
 
                        "ExtendedTimeout", "Expires",
406
 
                        "LastCheckerStatus")
 
403
                        "ExtendedTimeout")
407
404
        else:
408
405
            keywords = defaultkeywords
409
406
        
410
407
        if options.dump_json:
411
 
            json.dump({client["Name"]: {key:
412
 
                                        bool(client[key])
413
 
                                        if isinstance(client[key],
414
 
                                                      dbus.Boolean)
415
 
                                        else client[key]
 
408
            json.dump({client["Name"]: {key: client[key]
416
409
                                        for key in keywords }
417
410
                       for client in clients.values() },
418
411
                      fp = sys.stdout, indent = 4,