6
MAAS implements a system of tags based on the physical properties of
7
the nodes. The idea behind this is that you can use the tags to
8
identify nodes with particular abilities which may be useful when it
9
comes to deploying services.
11
A real world example of this might be to identify nodes which have
12
fast GPUs installed, if you were planning on deploying software which
13
used CUDA or OpenCL which would make use of this hardware.
19
Before we can create a tag we need to know how we will select which nodes it
20
gets applied to. MAAS collects hardware information from the nodes using the
21
`"lshw" utility <http://ezix.org/project/wiki/HardwareLiSter>`_ to return
22
detailed information in XML format. The definitions used in creating a tag are
23
then constructed using XPath expressions.
24
If you are unfamiliar with XPath expressions, it is well worth checking out the
25
`w3schools documentation <http://www.w3schools.com/xpath/xpath_syntax.asp>`_.
26
For the lshw XML, we will just check all the available nodes for some
28
In our example case, we might want to find GPUs with a clock speed of over
30
In this case, the relevant XML node from the output will be labelled "display"
31
and does have a property called clock, so it will look like this::
33
//node[@id="display"]/clock > 1000000000
35
Now we have a definition, we can go ahead and create a tag.
41
Once we have sorted out what definition we will be using, creating the
42
tag is easy using the ``maas-cli`` command. You will need to :ref:`be
43
logged in to the API first <api-key>`::
45
$ maas-cli maas tags new name='gpu' \
46
comment='GPU with clock speed >1GHz for running CUDA type operations.' \
47
definition='//node[@id="display"]/clock > 1000000000'
49
The comment is really for your benefit. It pays to keep the actual tag name
50
short and to the point as you will be using it frequently in commands, but it
51
may subsequently be hard to work out what exactly was the difference between
52
tags like "gpu" and "fastgpu" unless you have a good comment. Something which
53
explains the definition in plain language is always a good idea!
55
To check which nodes this tag applies to we can use the tag command::
57
$ maas-cli maas tag nodes gpu
59
The process of updating the tags does take some time - not a lot of time, but
60
if nothing shows up straight away, try running the command again after a minute
67
You can use the tag in the web interface to discover applicable nodes, but the
68
real significance of it is when using juju to deploy services. Tags can be used
69
with juju constraints to make sure that a particular service only gets deployed
70
on hardware with the tag you have created.
73
To use the 'gpu' tag we created to run a service called 'cuda' we would use::
75
$ juju deploy --constraints maas-tags=gpu cuda
77
You could list several tags if required, and mix in other juju constraints if
80
$ juju deploy --constraints "mem=1024 maas-tags=gpu,intel" cuda
83
Manually assigning tags
84
-----------------------
86
MAAS supports the creation of arbitrary tags which don't depend on XPath
87
definitions ("nodes which make a lot of noise" perhaps). If a tag is created
88
without specifying the definition parameter then it will simply be ignored by
89
tag refresh mechanism, but the MAAS administrator will be able to manually add
90
and remove the tag from specific nodes.
92
In this example we are assuming you are using the 'maas' profile and you want
93
to create a tag called 'my_tag'::
95
$ maas-cli maas tags new name='my_tag' comment='nodes which go ping'
96
$ maas-cli maas tag update-nodes my_tag add="<system_id>"
98
The first line creates a new tag but omits the definition, so no nodes are
99
automatically added to it. The second line applies that tag to a specific node
100
referenced by its system id property.
102
You can easily remove a tag from a particular node, or indeed add
103
and remove them at the same time::
105
$ maas-cli maas tag update-nodes my_tag add=<system_id_1> \
106
add=<system_id_2> add=<system_id_3> remove=<system_id_4>
108
As the rule is that tags without a definition are ignored when rebuilds are
109
done, it is also possible to create a normal tag with a definition, and then
110
subsequently edit it to remove the definition. From this point the tag behaves
111
as if you had manually created it, but it still retains all the existing
112
associations it has with nodes. This is particularly useful if you have some
113
hardware which is conceptually similar but doesn't easily fit within a single
116
$ maas-cli maas tag new name='my_tag' comment='nodes I like ' \
117
definition='contains(//node[@id=network]/vendor, "Intel")'
118
$ maas-cli maas tag update my_tag definition=''
119
$ maas-cli mass tag update-nodes my_tag add=<system_id>
123
If you add and remove the same node in one operation, it ends up having
124
the tag removed (even if the tag was in place before the operation).