8
$ maas-cli <profile> <command> [parameters]
10
The available commands are dependent on the API you are connecting to and the
11
profile you use. The currently available options are explained below.
17
As well as the web interface, many tasks can be performed by accessing
18
the MAAS API directly through the maas-cli command. This section
19
details how to login with this tool and perform some common
26
Before the API will accept any commands from maas-cli, you must first
27
login. To do this, you need the API key which can be found in the user
30
Login to the web interface on your MAAS. Click on the username in the
31
top right corner and select 'Preferences' from the menu which appears.
33
The very first item is a list of MAAS keys. One will have already been
34
generated when the system was installed. It's easiest to just select
35
and copy the key (it's quite long!) and then paste it into the
36
commandline. The format of the login command is::
38
$ maas-cli login <profile-name> <hostname> <key>
40
The profile created is an easy way of associating your credentials with any
41
subsequent call to the API. So an example login might look like this::
43
$ maas-cli login maas http://10.98.0.13/MAAS/api/1.0 AWSCRMzqMNy:jjk...5e1FenoP82Qm5te2
45
which creates the profile 'maas' and registers it with the given key at the
46
specified API endpoint.
47
If you omit the credentials, they will be prompted for in the console. It is
48
also possible to use a hyphen, '-' in place of the credentials. In this case a
49
single line will be read from stdin, stripped of any whitespace and used as the
50
credentials, which can be useful if you are devolping scripts for specific
52
If an empty string is passed instead of the credentials, the profile will be
53
logged in anonymously (and consequently some of the API calls will not be
60
The ``maas-cli`` command exposes the whole API, so you can do anything
61
you actually *can* do with MAAS using this command. Unsurprisingly,
62
this leaves us with a vast number of options.
64
The main maas-cli commands are:
70
lists the details [name url auth-key] of all the currently logged-in
73
:samp:`login <profile> <url> <key>`
75
Logs in to the MAAS controller API at the given URL, using the key
76
provided and associates this connection with the given profile name.
78
:samp:`logout <profile>`
80
Logs out from the given profile, flushing the stored credentials.
84
Refreshes the API descriptions of all the current logged in
85
profiles. This may become necessary for example when upgrading the
86
maas packages to ensure the command-line options match with the API.
88
:samp:`<profile> [command] [options] ...`
90
Using the given profile name instructs ``maas-cli`` to direct the
91
subsequent commands and options to the relevant MAAS, which for the
92
current API are detailed below...
97
This command is used for creating and destroying the
98
MAAS authorisation tokens associated with a profile.
100
Usage: maas-cli *<profile>* account [-d --debug] [-h --help]
101
create-authorisation-token | delete-authorisation-token [token_key=\
104
.. program:: maas-cli account
108
Displays debug information listing the API responses.
112
Display usage information.
114
:samp:`-k, --insecure`
116
Disables the SSL certificate check.
118
:samp:`create-authorisation-token`
120
Creates a new MAAS authorisation token for the current profile
121
which can be used to authenticate connections to the API.
123
:samp:`delete-authorisation-token token_key=<value>`
125
Removes the given key from the list of authorisation tokens.
131
API calls which operate on individual nodes. With these commands, the
132
node is always identified by its "system_id" property - a unique tag
133
allocated at the time of enlistment. To discover the value of the
134
system_id, you can use the ``maas-cli <profile> nodes list`` command.
136
USAGE: maas-cli <profile> node [-h] release | start | stop | delete |
137
read | update <system_id>
139
.. program:: maas-cli node
143
Display usage information.
145
:samp:`release <system_id>`
147
Releases the node given by *<system_id>*
149
:samp:`start <system_id>`
151
Powers up the node identified by *<system_id>* (where MAAS has
152
information for power management for this node).
154
:samp:`stop <system_id>`
156
Powers off the node identified by *<system_id>* (where MAAS has
157
information for power management for this node).
159
:samp:`delete <system_id>`
161
Removes the given node from the MAAS database.
163
:samp:`read <system_id>`
165
Returns all the current known information about the node specified
168
:samp:`update <system_id> [parameters...]`
170
Used to change or set specific values for the node. The valid
171
parameters are listed below::
174
The new hostname for this node.
177
Sets the architecture type, where <value>
178
is a string containing a valid architecture type,
181
distro_series=<value>
182
Sets the series of Ubuntu to use.
185
Sets the type of power management used on the node, e.g. "ipmi" or
188
power_parameters_{param1}... =<value>
189
Set the given power parameters. Note that the valid options for these
190
depend on the power type chosen.
192
power_parameters_skip_check 'true' | 'false'
193
Whether to sanity check the supplied parameters against this node's
194
declared power type. The default is 'false'.
200
Example: Setting the power parameters for an ipmi enabled node::
202
maas-cli maas node update <system_id> \
204
power_parameters_power_address=192.168.22.33 \
205
power_parameters_power_user=root \
206
power_parameters_power_pass=ubuntu;
214
Usage: maas-cli <profile> nodes [-h] is-registered | list-allocated |
215
acquire | list | accept | accept-all | new | check-commissioning
217
.. program:: maas-cli nodes
221
Display usage information.
224
:samp:`accept <system_id>`
226
Accepts the node referenced by <system_id>.
230
Accepts all currently discovered but not previously accepted nodes.
234
Allocates a node to the profile used to issue the command. Any
235
ready node may be allocated.
237
:samp:`is-registered mac_address=<address>`
239
Checks to see whether the specified MAC address is registered to a
244
Returns a JSON formatted object listing all the currently known
245
nodes, their system_id, status and other details.
247
:samp:`list-allocated`
249
Returns a JSON formatted object listing all the currently allocated
250
nodes, their system_id, status and other details.
252
:samp:`new architecture=<value> mac_addresses=<value> [parameters]`
254
Creates a new node entry given the provided key=value information
255
for the node. A minimum of the MAC address and architecture must be
256
provided. Other parameters may also be supplied::
258
architecture="<value>" - The architecture of the node, must be
259
one of the recognised architecture strings (e.g. "i386/generic")
260
hostname="<value>" - a name for this node. If not supplied a name
262
mac_addresses="<value>" - The mac address(es)
263
allocated to this node.
264
powertype="<value>" - the power type of
265
the node (e.g. virsh, ipmi)
268
:samp:`check-commissioning`
270
Displays current status of nodes in the commissioning phase. Any
271
that have not returned before the system timeout value are listed
275
Accept and commission all discovered nodes::
277
$ maas-cli maas nodes accept-all
279
List all known nodes::
281
$ maas-cli maas nodes list
283
Filter the list using specific key/value pairs::
285
$ maas-cli maas nodes list architecture="i386/generic"
291
Usage: maas-cli <profile> node-groups [-d --debug] [-h --help] [-k
292
--insecure] register | list | refresh-workers | accept | reject
294
.. program:: maas-cli node-groups
298
Displays debug information listing the API responses.
302
Display usage information.
304
:samp:`-k, --insecure`
306
Disables the SSL certificate check.
308
:samp:`register uuid=<value> name=<value> interfaces=<json_string>`
310
Registers a new node group with the given name and uuid. The
311
interfaces parameter must be supplied in the form of a JSON string
312
comprising the key/value data for the interface to be used, for
313
example: interface='["ip":"192.168.21.5","interface":"eth1", \
314
"subnet_mask":"255.255.255.0","broadcast_ip":"192.168.21.255", \
315
"router_ip":"192.168.21.1", "ip_range_low":"192.168.21.10", \
316
"ip_range_high":"192.168.21.50"}]'
320
Returns a JSON list of all currently defined node groups.
322
:samp:`refresh_workers`
324
It sounds a bit like they will get a cup of tea and a
325
biscuit. Actually this just sends each node-group worker an update
326
of its credentials (API key, node-group name). This command is
327
usually not needed at a user level, but is often used by worker
330
:samp:`accept <uuid>`
332
Accepts a node-group or number of nodegroups indicated by the
335
:samp:`reject <uuid>`
337
Rejects a node-group or number of nodegroups indicated by the
344
For managing the interfaces. See also
345
"node_group_interfaces"
347
Usage: maas-cli *<profile>* node-group-interface [-d --debug] [-h
348
--help] [-k --insecure] read | update | delete [parameters...]
350
..program:: maas-cli node-group-interface
352
:samp:`read <uuid> <interface>`
354
Returns the current settings for the given UUID and interface
356
:samp:`update [parameters]`
358
Changes the settings for the interface according to the given
361
management= 0 | 1 | 2
362
The service to be managed on the interface ( 0= none, 1=DHCP, 2=DHCP
366
Apply the given dotted decimal value as the subnet mask.
369
Apply the given dotted decimal value as the broadcast IP address for
373
Apply the given dotted decimal value as the default router address
377
The lowest value of IP address to allocate via DHCP
379
ip_range_high=<value>
380
The highest value of IP address to allocate via DHCP
382
:samp:`delete <uuid> <interface>`
384
Removes the entry for the given UUID and interface.
388
Configuring DHCP and DNS.
390
To enable MAAS to manage DHCP and DNS, it needs to be supplied with the relevant
391
interface information. To do this we need to first determine the UUID of the
392
node group affected::
394
$ uuid=$(maas-cli <profile> node-groups list | grep uuid | cut -d\" -f4)
396
Once we have the UUID we can use this to update the node-group-interface for
397
that nodegroup, and pass it the relevant interface details::
399
$ maas-cli <profile> node-group-interface update $uuid eth0 \
400
ip_range_high=192.168.123.200 \
401
ip_range_low=192.168.123.100 \
403
broadcast_ip=192.168.123.255 \
404
router_ip=192.168.123.1 \
406
Replacing the example values with those required for this network. The only
407
non-obvious parameter is 'management' which takes the values 0 (no management), 1
408
(manage DHCP) and 2 (manage DHCP and DNS).
411
node-group-interfaces
412
^^^^^^^^^^^^^^^^^^^^^
414
The node-group-interfaces commands are used for configuring the
415
management of DHCP and DNS services where these are managed by MAAS.
417
Usage: maas-cli *<profile>* node-group-interfaces [-d --debug] [-h
418
--help] [-k --insecure] list | new [parameters...]
420
.. program:: maas-cli node-group-interfaces
424
Displays debug information listing the API responses.
428
Display usage information.
430
:samp:`-k, --insecure`
432
Disables the SSL certificate check.
436
Lists the current stored configurations for the given identifier
437
<label> in a key:value format which should be easy to decipher.
440
:samp:`new <label> ip=<value> interface=<if_device> [parameters...]`
442
Creates a new interface group. The required parameters are the IP
443
address and the network interface this appies to (e.g. eth0). In
444
order to do anything useful, further parameters are required::
446
management= 0 | 1 | 2
447
The service to be managed on the interface
448
( 0= none, 1=DHCP, 2=DHCP and DNS).
451
Apply the given dotted decimal value as the subnet mask.
454
Apply the given dotted decimal value as the
455
broadcast IP address for this subnet.
458
Apply the given dotted decimal value as the
459
default router address for this subnet.
462
The lowest value of IP address to allocate via DHCP
464
ip_range_high=<value>
465
The highest value of IP address to allocate via DHCP
473
Usage: maas-cli <profile> tag read | update-nodes | rebuild | update |
476
.. program:: maas-cli tag
478
:samp:`read <tag_name>`
480
Returns information on the tag specified by <name>
482
:samp:`update-nodes <tag_name> [add=<system_id>] [remove=<system_id>] [nodegroup=<system_id>]`
484
Applies or removes the given tag from a list of nodes specified by
485
either or both of add="<system_id>" and remove="<system_id>". The
486
nodegroup parameter, which restricts the operations to a particular
487
nodegroup, is optional, but only the superuser can execute this
492
Triggers a rebuild of the tag to node mapping.
494
:samp:`update <tag_name> [name=<value>] | [comment=<value>]|[definition=<value>]`
496
Updates the tag identified by tag_name. Any or all of name,comment
497
and definition may be supplied as parameters. If no parameters are
498
supplied, this command returns the current values.
500
:samp:`nodes <tag_name>`
502
Returns a list of nodes which are associated with the given tag.
504
:samp:`delete <tag_name>`
506
Deletes the given tag.
510
Tags are a really useful way of identifying nodes with particular
513
Usage: maas-cli <profile> tag [-d --debug] [-h --help] [-k
514
--insecure] list | new
516
.. program:: maas-cli tag
520
Displays debug information listing the API responses.
524
Display usage information.
526
:samp:`-k, --insecure`
528
Disables the SSL certificate check.
532
Returns a JSON object listing all the current tags known by the MAAS server
534
:samp:`create name=<value> definition=<value> [comment=<value>]`
536
Creates a new tag with the given name and definition. A comment is
537
optional. Names must be unique, obviously - an error will be
538
returned if the given name already exists. The definition is in the form of
539
an XPath expression which parses the XML returned by running ``lshw`` on the
543
Adding a tag to all nodes which have an Intel GPU::
545
$ maas-cli maas tags new name='intel-gpu' \
546
comment='Machines which have an Intel display driver' \
547
definition='contains(//node[@id="display"]/vendor, "Intel")
552
Because the ``maas-cli`` command exposes all of the API, it also lists
553
some command options which are not really intended for end users, such
554
as the "file" and "boot-images" options.
556
Further Documentation
557
^^^^^^^^^^^^^^^^^^^^^
558
For more documentation of MAAS, please see https://maas.ubuntu.com/docs