add "owner" as a search constraint to maas cli machines command
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Incomplete
|
Low
|
Unassigned | ||
MAAS documentation |
Triaged
|
Medium
|
Unassigned |
Bug Description
For anyone with an admin account who has logged into the MAAS api and is using maas-cli, they should be able to list all machines a user owns, in any state, or in a specified state...
the user story would be "As a MAAS admin, I want to see every machine $USER currently owns in any state so I can determine if they have too many allocated systems"
or
"As a MAAS admin, I want to see every deployed machine $USER currently owns"
As a workaround it IS kinda possible to do this with some jq hackery (sauce: https:/
$ maasuser=jdoe; maas $MYMAAS machines read | jq -r '(.[] | [.hostname, .system_id, .owner]) | @tsv' | column -t |grep $maasuser
littleserver pqfcag jdoe
bigserver 86wp7a jdoe
however, this seems like such a basic admin task that any account with admin privileges should be able to do this without hackery like so:
maas $MYMASS machines read owner=jdoe
maas $MYMAAS machines read owner=jdoe status_
I use "machines" here because getting info about machines is part of machine/machines commands in maas-cli. The JSON output for maas LOGIN machines read includes ownership ( "owner": "bladernr") and status like power state ("power_state": "on") and deployment status ("status_name": "Deployed")
So it seems reasonable that maas-cli could just add those fields as filters like it already does for things like id, hostname, vlan, etc.
In fact, it already lets you grab a dump of every machine in a given status:
maas LOGIN machines read status=deployed
So it seems just adding in owner as a new constraint would resolve this. (*well, you'd also need to define "status" better, because status appears to be not well described. But searching for status=
There was the suggestion that the biggest issue would be permissions, but that seems fairly easy to sort out too...
if I'm an admin user, I can see the status of every machine registered in MAAS.
If I'm a standard user, I can still only see the machines I own or are available to me:
$ maas ubuntu machines read |grep owner
"owner": "ubuntu",
"owner": null,
"owner": null,
"owner": null,
$ maas ubuntu machines read | jq -r '(.[] | [.hostname, .system_id, .owner]) | @tsv' | column -t
server1 hs8fxs ubuntu
server2 4nbeyy
server3 pcyggy
server4 4w4b46
Those last two are the same MAAS server used before, only I'm doing the commands as a non-admin user, so instead of seeing the 30 registered machines I'd see as an admin, I only see the one machine the ubuntu user has deployed, and the three that are not allocated to anyone else.
description: | updated |
summary: |
- maas cli should make it easy for an admin to list all machines a user - owns + add "owner" as a search constraint to maas cli machines command |
tags: | added: cli |
Changed in maas: | |
status: | New → Triaged |
importance: | Undecided → Low |
milestone: | none → 2.10-next |
Changed in maas: | |
milestone: | 3.0.0 → none |
Hi Jeff,
You can already do this, and the maas cli allows filtering by owner e.g. https:/ /pastebin. canonical. com/p/3xJvGmFFY D/
Does look like it's missing from the doc though