Maas cli create raids - block_devices?

Hi, I’m trying to use the maas CLI to define storage layout of my machines and especially raid arrays

I can’t figure out what type of data is needed for the block_devices parameter

maas $profile raids create 6qc6gt name=test level=raid-0 block_devices=["sdh"
,"sdi"]
{"block_devices": ["Select a valid choice. [sdh,sdi] is not one of the available choices."]}

If I put IDs of the block devices, it is the same and also different string format give same error like : “sdh,sdi” ; ‘sdh,sdi’ ; "{[‘sdh’,‘sdi’]} and almost any possible variants

From the CLI doc
:param block_devices: Optional. Block devices to add
to the RAID.
:type block_devices: String

Thanks for your help (was not able to find an example on INTERNET even there : maas-docs/en/installconfig-storage.md at master · CanonicalLtd/maas-docs · GitHub
https://github.com/CanonicalLtd/maas-docs/blob/master/en/manage-cli-advanced.md

I managed to capture traffic while using the webUI because it is working via WebUI. Using tcpdump I can see in the websocket traffic the POST call to API with these datas :

{"method":"machine.create_raid","type":0,"params":{"level":"raid-0","name":"md042","system_id":"nchbrq","tags":[],"block_devices":[849,850]},"request_id":16}

But when I do it through CLI, I have the same problem

maas preDEV-maas-user raids create nchbrq name=test level=raid-0 block_devices=[849,850]
{"block_devices": ["Select a valid choice. [849,850] is not one of the available choices."]}

I also captured the API call of the CLI still a POST with multi-part DATA, we can see the base64 encoded value of all the parameters

POST /MAAS/api/2.0/nodes/nchbrq/raids/ HTTP/1.1
Host: 192.168.2.2:5240
content-type: multipart/form-data; boundary="===============5263540941563289710=="
mime-version: 1.0
content-length: 642
authorization: OAuth oauth_nonce="*******************", oauth_timestamp="***********", oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="GByPaU5yHkpppvKn9J", oauth_token="**************", oauth_signature="*************************"
user-agent: Python-httplib2/0.20.2 (gzip)
accept-encoding: gzip, deflate

--===============5263540941563289710==
Content-Transfer-Encoding: base64
Content-Disposition: form-data; name="name"
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"

dGVzdA==

--===============5263540941563289710==
Content-Transfer-Encoding: base64
Content-Disposition: form-data; name="level"
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"

cmFpZC0w

--===============5263540941563289710==
Content-Transfer-Encoding: base64
Content-Disposition: form-data; name="block_devices"
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"

Wzg0OSw4NTBd

--===============5263540941563289710==--

And the base64 decode is giving us the right format, I really don’t understand what is going on…
Is it a bug ?

echo "Wzg0OSw4NTBd" | base64 -d
[849,850]

Thanks a lot if you can help

Following my investigation, I now have the exact same problem for the creation of a LVM volume group which need IDs of disks

maas <profile> volume-groups create nchbrq name=vgtest block_devices=[849,850]
{"block_devices": ["Select a valid choice. [849,850] is not one of the available choices."]}

I was willing to look the source code of the CLI but I don’t understand how it works when looking here : maas/src/maascli at 3.4 · canonical/maas (github.com)

I’m not able to locate how commands like raids or volume-groups are handled, even while searching for these keywords in the whole repository I found almost nothing.

I’m really stuck, help is more than welcome

To be fully tested but it seems that this syntax should work, hope it could help other folks.
Documentation should be definitely updated to help people

maas <profile> raids create 6qc6gt name=test level=raid-0 block_devices=1022   block_devices=1023 

the CLI documentation is not crystal clear :

$ maas <profile> raids create
...
 :param block_devices: Optional.  Block devices to add
to the RAID.
:type block_devices: String

 :param level: Required.  RAID level.
:type level: Int

You have to repeat block_devices=id for each block device, using the device ID.

first, get the device ID of the desired block device :

$ maas preDEV-maas-user  block-devices read  <machineID> | jq  '.[] | "\(.id) \(.name)"'
"1021 vda"
"1022 vdb"
"1023 vdc"
"1029 vgroot-lvroot"

then create your raid array :

$ maas preDEV-maas-user raids create -d e846ge name=md0 level=raid-0  block_devices=1022   block_devices=1023

Note that raid-0 is not exactly an Int