[Beaker-devel] New sub-command to list access policy for a system
Amit Saha
asaha at redhat.com
Wed Sep 25 05:24:30 UTC 2013
----- Original Message -----
> From: "Amit Saha" <asaha at redhat.com>
> To: "Beaker development" <beaker-devel at lists.fedorahosted.org>
> Sent: Tuesday, September 24, 2013 5:38:48 PM
> Subject: Re: [Beaker-devel] New sub-command to list access policy for a system
>
>
>
> ----- Original Message -----
> > From: "Dan Callaghan" <dcallagh at redhat.com>
> > To: "Amit Saha" <asaha at redhat.com>
> > Cc: "Beaker development" <beaker-devel at lists.fedorahosted.org>
> > Sent: Tuesday, September 24, 2013 5:32:52 PM
> > Subject: Re: [Beaker-devel] New sub-command to list access policy for a
> > system
> >
> > Excerpts from Amit Saha's message of 2013-09-24 17:17:22 +1000:
> > > I noticed that there is no sub-command to list the existing policy for a
> > > system, so
> > > tried writing one [1]. My primary objective is to of course having it as
> > > a
> > > sub-command,
> > > unless there was another reason other than time that it wasn't added
> > > earlier.
> > >
> > > The second objective is to use it as the second example in our developer
> > > guide
> > > to show how you expose controller methods and write a client to access
> > > it.
> > >
> > >
> > > Example usage:
> > >
> > > # bkr policy-list --system beaker-test-vm1 --hub http://localhost/bkr
> > > --username admin --password foobar
> > > {
> > > "rules": [
> > > {
> > > "everybody": true,
> > > "permission": "control_system",
> > > "group": null,
> > > "id": 1,
> > > "user": null
> > > },
> > > {
> > > "everybody": true,
> > > "permission": "reserve",
> > > "group": null,
> > > "id": 4,
> > > "user": null
> > > }
> > > ],
> > > "possible_permissions": [
> > > {
> > > "value": "edit_policy",
> > > . ..
> > > . ..
> >
> > I like it, my only suggestion would be to accept a --format option like
> > the other commands. It would have --format=json for machine parsing, and
> > a tabular/linear format that is friendlier for humans and grepping.
> > Perhaps --format=text which spits out just a list of rules, one per
> > line:
> >
> > Group beakerdevs has permission edit_policy
> > User asaha has permission reserve
> > Everybody has permission control_system
Considering that the user/group names can and will most likely vary,
I used PrettyTable [1] to print the rules (when invoked with --format=list).
Example:
+------+-------+--------+----------------+
| Rule | User | Group | Permission |
+------+-------+--------+----------------+
| 1 | user7 | None | edit_system |
| 2 | user8 | None | control_system |
| 3 | None | group9 | control_system |
+------+-------+--------+----------------+
The patch is here [2].
[1] https://pypi.python.org/pypi/PrettyTable/ (Already available in RHEL 6 and Fedora repositories)
[2] http://gerrit.beaker-project.org/#/c/2293/
-Amit.
More information about the Beaker-devel
mailing list