~lutostag/ubuntu/trusty/maas/1.5.4+keystone

« back to all changes in this revision

Viewing changes to docs/tags.rst

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-03-04 11:49:44 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20130304114944-azcvu9anlf8mizpa
Tags: upstream-1.3+bzr1452+dfsg
ImportĀ upstreamĀ versionĀ 1.3+bzr1452+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _deploy-tags:
 
2
 
 
3
Making use of Tags
 
4
==================
 
5
 
 
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.
 
10
 
 
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.
 
14
 
 
15
 
 
16
Tag definitions
 
17
---------------
 
18
 
 
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
 
27
properties.
 
28
In our example case, we might want to find GPUs with a clock speed of over
 
29
1GHz.
 
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::
 
32
 
 
33
 //node[@id="display"]/clock > 1000000000
 
34
 
 
35
Now we have a definition, we can go ahead and create a tag.
 
36
 
 
37
 
 
38
Creating a tag
 
39
--------------
 
40
 
 
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>`::
 
44
 
 
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'
 
48
 
 
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!
 
54
 
 
55
To check which nodes this tag applies to we can use the tag command::
 
56
 
 
57
  $ maas-cli maas tag nodes gpu
 
58
 
 
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
 
61
or so.
 
62
 
 
63
 
 
64
Using the tag
 
65
-------------
 
66
 
 
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.
 
71
 
 
72
Example:
 
73
To use the 'gpu' tag we created to run a service called 'cuda' we would use::
 
74
 
 
75
  $ juju deploy --constraints maas-tags=gpu cuda
 
76
 
 
77
You could list several tags if required, and mix in other juju constraints if
 
78
needed::
 
79
 
 
80
  $ juju deploy --constraints "mem=1024 maas-tags=gpu,intel" cuda
 
81
 
 
82
 
 
83
Manually assigning tags
 
84
-----------------------
 
85
 
 
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.
 
91
 
 
92
In this example we are assuming you are using the 'maas' profile and you want
 
93
to create a tag called 'my_tag'::
 
94
 
 
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>"
 
97
 
 
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.
 
101
 
 
102
You can easily remove a tag from a particular node, or indeed add
 
103
and remove them at the same time::
 
104
 
 
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>
 
107
 
 
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
 
114
tag definition::
 
115
 
 
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>
 
120
 
 
121
.. tip::
 
122
 
 
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).