Adding Machine via CLI | IPMI

Hi All,

I newbie to this MAAS so Please ignore me if i’m asking anything silly.

How can i add a machine with IPMI via CLI

Can anyone help me

1 Like

Here’s a snippet of help text from the CLI that will help you find more

maas $PROFILE machines create --help
usage: maas $PROFILE machines create [--help] [-d] [-k] [data [data ...]]

Create a new machine                            
                                                                               
                                                                               
This method accepts keyword arguments.  Pass each argument as a
key-value pair with an equals sign between the key and the value:
key1=value1 key2=value key3=value3.  Keyword arguments must come after
any positional arguments.                                          
                                                                               
Create a new machine.                                           
                                                                               
Adding a server to MAAS wipes its disks and re-installs its operating
system, in the event that it PXE boots.  In anonymous enlistment (and
when the enlistment is done by a non-admin), the machine is held in the
"New" state for approval by a MAAS admin.            
                                                                               
The minimum data required is:                                       
                                                                               
architecture=<arch string> (e.g. "i386/generic")
mac_addresses=<value> (e.g. "aa:bb:cc:dd:ee:ff")

To specify power parameters, you should pass power_type=ipmi power_parameters={'power_address': 'IP_OF_BMC', 'power_user': 'IPMI_USERNAME', 'power_pass': 'IPMI_PASSWORD'}

Hi Sparkiegeek,

Thank you so much for your response i will check it…

1 Like

Hi Sparkiegeek,
i can able to add the machine via CLI with a help of your command thanks much!

Sorry to bug you again :frowning: , i have one more doubt.

How can i get the machines list through api
these are the doc which is provided by maas


in the above doc they have given the example api, to list all machines, you might GET “/MAAS/api/2.0/machines”.

but how can i apply it.

when i used this command am getting the following response.
(amc) root@assistanz-maas:~# curl -X GET “http://192.168.4.51:5240/MAAS/api/2.0/machines/
Unrecognised signature: method=GET op=None(amc)

and also i did’t get any response for this command (GET “/MAAS/api/2.0/machines/”
)

i have installed the maas 2.8 by using the below steps:

sudo apt update && sudo apt upgrade
sudo snap install maas --channel=2.8
sudo snap install maas-test-db
maas-test-db.psql
sudo maas init region+rack --database-uri maas-test-db:///
sudo maas createadmin

do you have any idea about this?

Yes that’s the right docs for the API, but you’re missing the important part of authorisation!

Instead of using curl which will be tricky to get the authentication and authorisation correct, it’s better to use the CLI that you get out of the box with the snap of MAAS.

https://maas.io/docs/maas-cli#heading--log-in-required has some details - start with maas login then give your login profile a name, and then maas $PROFILE_NAME machines read to list the machines.

Hello Sparkiegeek,

Thanks Again :slight_smile: !! Got it and now can able to manage the servers via cli,

# API key = "<consumer_key>:<key>:<secret>"
response = perform_API_request(
     "http://server/MAAS/api/1.0", "/nodes/?op=list", "<key>", "<secret>",
     "consumer_key>")

Here what is consumer_key:key:secret
i have generated a single key for performing cli opreations
(qNpxpTEJvHrysNyZtF:5Q4tQs5DuFc4PqLeyt:BzjTwELcEm5VkSqBmRLpDQnzxasdasdsawSqxfex)
in this key there is three separate values which i mentioned below
qNpxpTEJvHrysNyZtF
5Q4tQs5DuFc4PqLeyt
BzjTwELcEm5VkSqBmRLpasdsadsaDQnzxwSqxfex

my question is how can i find the key,secret,consumer_key :frowning:

The comment is trying to tell you the parts of the key that you get from the UI/CLI

# API key = '<consumer_key>:<key>:<secret>'

It’s : separated and had three parts:

  • The first part beginning qNp in your example is consumer_key
  • The second, beginning `5Q4q is the key,
  • and finally the third part is the secret (which you shouldn’t share here, or anywhere else!)

Hello Sparkiegeek,

Thank you so much for your quick reply and your assistance , i will deleted the key generated the new one now :grimacing:

1 Like