vm-host parameters help is wrong

Bug #2024466 reported by Marian Gasparovic
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Committed
Medium
Wyatt Rees

Bug Description

$ maas root vm-host parameters
usage: maas root vm-host parameters [--help] [-d] [-k] id [data ...]

Obtain VM host parameters
...
Note: This method is reserved for admin users.

the following arguments are required: id, data

However data is not required, it is not even supposed to do anything

`vm-host parameters id` returns all parameters in one output

`vm-host parameters id certificate` says
'certificate' is not a name=value or name@=filename pair

Eithr parameter command needs to support data and return just that field from the output or help should be corrected to not suggest `data` is a valid argument or that it is required argument.

To be clear parameters -h shows `data` as argument and parameters without specifying id says id and data are required arguments

Related branches

Changed in maas:
status: New → Triaged
importance: Undecided → Medium
milestone: none → 3.5.0
Changed in maas:
milestone: 3.5.0 → 3.5.x
Wyatt Rees (wyattrees)
Changed in maas:
assignee: nobody → Wyatt Rees (wyattrees)
status: Triaged → In Progress
Revision history for this message
Wyatt Rees (wyattrees) wrote :

We can fix this by changing how we add data to the argument parser. Currently, `data` is specified as a positional argument with `nargs="*"` and a custom type function. This forces `data` to be recognized as a required argument and specifies it as a list of key=value pairs: https://git.launchpad.net/maas/tree/src/maascli/api.py#n105

Unfortunately, argparse does not allow you to specify positional arguments as optional, unless you use `nargs="?"`. If we do use `nargs="?"`, the argument is no longer recognized as a list. However, we can then also modify the custom type converter (https://git.launchpad.net/maas/tree/src/maascli/api.py#n198) to convert a list of key=value pairs (rather than just one key=value pair, as is done now). This does remove "data" from the error message specifying required arguments, but has a side effect: whenever the `data` argument is presented for any command using it, it must be wrapped in quotes.

As a side-note: changing the API to actually use the `data` argument doesn't make a ton of sense, since the `data` argument must be presented as key=value pairs, but this specific action only requires a key.

Changed in maas:
milestone: 3.5.x → 3.6.0
Changed in maas:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.