How can one view tag definitions


#1

Looking at https://docs.maas.io/2.5/en/nodes-tags?_ga=2.73567570.130175317.1557869484-1432046611.1553535110 one could surmise that there is a way to view the tag definitions (given the output in the documentation). Is there a way to view/query the maas api to see what it has stored? As a quick follow-up, is there a way to view the definitions from maas-cli? Whenever I follow the documentation above to view the XML/YAML from the UI, there are no definitions. We’re using 2.5.2.


#2

You can view tags using the CLI with the following command

maas $PROFILE tags read

#3

Thanks! So. I know you can view tags using the tags read command. I want to know if there’s a way to view tag definitions, which is the automated tags added at commission time associated with lshw.


#4

At the moment the built-in tags that MAAS creates during commissioning are not exposed over the API as something that is discoverable.

The tags shows with

maas $PROFILE tags read

Will include the xpath expressions if defined on the tags. Those tags will also be auto placed on machines during commissioning if those xpath expressions matches for that machine.

Also on the updating of a tag’s xpath expression or on creation of a new tag with xpath expression, MAAS will reprocess all of the machines to determine if that change or creation causes the tag to be assigned or unassigned from already commissioned machines. It performs this action without the need to re-commission the machines.


#5

Great! Thank you Blake.


#8

FWIW, more on managing tags is available in the docs:

https://docs.maas.io/2.5/en/nodes-tags
https://docs.maas.io/2.5/en/manage-cli-tags


#9

yup. I already knew about those. We’re trying to find the best way to develop code around building tags based on hardware and then using that code for a project we’re working on. Enter tags where during commissioning that stuff is already apparently enumerated in maas. The question is, how does one use them? So I wanted to first see if there were a way to few the enumerated tags. Anyway, this is still something we’re working on and may just use pools instead, though eventually, we’re going to need to know how to tap into the API to allocate machines based on hardware. Any thoughts, ideas, code snippets (perhaps juju source since juju does this) would be helpful.


#10

So a tag with an xpath definition will automatically tag machines on commissioning, and you can later use those tags to request machines that match a certain tag. For example:

maas machines allocate tags=tag1 not_tags=tag2


#11

Thank you for responding! I think we’re having a minor disconnect in communication and it may just be that what I’m asking can be fixed with better documentation.

Tag definitions must be manually added, right? The MaaS documentation was a bit sparse on that topic (https://docs.maas.io/2.5/en/manage-cli-tags?_ga=2.205753936.256522369.1558661462-1005582649.1558661462#tag-creation-and-auto-assignment). Is the list in https://docs.maas.io/2.5/en/nodes-tags an exhaustive list of attributes stored for each machine during maas commission or is this really just a sub-list. Obviously I can create my own lshw -xml output from any maas node, but I wonder if MaaS munges it at all. Obviously, any tag definitions added will not be reflected in the lshw output of a node, correct? The document there states that one can view the lshw output from the webui, but that’s incorrect so I’m wondering to what extent the documentation is correct? I’d also love more examples on how to properly create tag definitions myself. I’m getting some good ideas from https://gist.github.com/ThinGuy/5956fe5db681c87e90260a4a39b64612 and https://www.dell.com/support/article/us/en/04/sln311104/using-tags-with-maas-and-juju-in-ubuntu-server-14-04-lts?lang=en.


#12

Tag definitions have to be manually added and MAAS will auto-tag machines during commissioning that match that definition.

https://docs.maas.io/2.5/en/nodes-tags


#13

Great! That answers my question(s) for now. Thanks @andreserl. I still think some disambiguation in the documentation could be done; FYI. Nevertheless, I appreciate your patience.