← Back to team overview

maas-devel team mailing list archive

Re: Allow API to use <system_id | hostname> for all operations that currently require the system_id

 

On 29 May 2014 13:46, Raphaël Badin <raphael.badin@xxxxxxxxxxxxx> wrote:
> [...]
>
>> For this reason, I think we need to look at this in the context of some of
>> the
>> upcoming work on general usability.
>>
>> My opinion is that changing the API is the wrong thing to do here.  If we
>> want
>> to make the command line more usable, I think we need to move maas back to
>> maas-cli and write a wrapper (called maas) around it to add a sugary layer
>> for
>> end users.  This can include something that accepts hostnames for
>> operations
>> involving nodes.  It can also include something that makes the parameters
>> to
>> some of the operations a lot easier to understand.
>
>
> I agree with the idea that changing the API would be wrong.
>
> Even though the CLI is a bit rough to use right now (mostly because the
> inline (maas -h) documentation is a bit vague and the online documentation
> non-existant — two things that we've been wanting to fix for a long time,
> see https://bugs.launchpad.net/maas/+bugs?field.tag=cli), keeping its
> behaviour close to the API's behaviour has clear advantages.
>
> I wonder if, instead of changing the core *behaviour* by adding the option
> to look up the nodes using hostnames, we shouldn't improve the CLI so that
> it's easier to *extract* information from the returned responses.  This is
> based on the idea that most of the pain we feel when using the CLI comes
> from the awkwardness of having to deal with JSON-formatted output.  While
> this is fine when using the API in Python, JSON is clumsy to use on the
> command-line (even though I know that they are workarounds, for instance by
> piping the JSON blob into a Python command).
>
> More precisely, it would make it very easy to get the system id of a node
> whose hostname you know;  I'm thinking about something along the lines of:
>
> $ maas <profile> nodes list hostname=<hostname> *limit=1
> get-field=system_id* → system_id
>
> The main functionality already exists (getting the filtered list of nodes);
> the part the we would need to add would be the limitation and the field
> extraction.

Fwiw, jsonpath-rw 1.2.0 is in main in Trusty, and would fit the bill here.
https://pypi.python.org/pypi/jsonpath-rw

>
> @Andres & al. don't you think that, if you had access (through a very clear
> call to the CLI) to the system_id of a node using its hostname, this would
> solve your usability problem?

Were scripts possible to write in straight Python, using a Python
client API, we'd make a lot of people happy. Then the CLI becomes all
about satisfying humans, and something like jsonpath would make this
even more powerful.

Some might argue that we should also make the CLI good for scripting
from sh/bash, much like some might argue ridiculously that we ought to
inject heroin into kids to prevent them from using it.


Follow ups

References