MAAS: 3.4.1
https://maas.io/docs/api
POST /MAAS/api/2.0/nodes/{system_id}/raids/
: Set up a RAID
Request body (multipart/form-data)
block_devices
(string): Optional. Block devices to add to the RAID.
block_devices must be array of strings, for example [‘sda’, ‘sdb’]
I found 2 places of calling class CreateRaidForm
from websocket
form = CreateRaidForm(node=node, data=params)
data = {‘level’: ‘raid-0’, ‘name’: ‘md0’, ‘system_id’: ‘yprmdb’, ‘tags’: [], ‘block_devices’: [3, 4]}
from api
form = CreateRaidForm(machine, data=request.data)
data=<QueryDict: {‘block_devices[0]’: [‘sda’], ‘block_devices[1]’: [‘sdb’], ‘level’: [‘raid-1’], ‘name’: [‘md0’]}>
or
data=<QueryDict: {‘block_devices’: [‘sda’], ‘level’: [‘raid-1’], ‘name’: [‘md0’]}>
My test example on PHP + curl
$maas_system_id='yprmdb';
$api_url='http://ubka:5240/MAAS/api/2.0/nodes/'.$maas_system_id.'/raids/';
$consumer_key='d8FT4yh3LJBDXu6hVP';
$consumer_token='KMWt626426JFrWx2kY';
$secret='XyAhzKLL4mmtuBCuEEdSKUJgEc4fZBQ2';
$params=[
'name'=>'md0',
'level'=>'raid-1',
//'block_devices'=>['sda', 'sdb'],//"{"__all__": ["At least one block device or partition must be added to the array."]}"
//'block_devices'=>[3, 4],//"{"__all__": ["At least one block device or partition must be added to the array."]}"
//'block_devices'=>'sda',//"{"__all__": ["RAID level 1 must have at least 2 raid devices and any number of spares."]}"
//'block_devices'=>'sda sdb',//"{"block_devices": ["Select a valid choice. sda sdb is not one of the available choices."]}"
//'block_devices'=>'sda,sdb',//"{"block_devices": ["Select a valid choice. sda,sdb is not one of the available choices."]}"
'block_devices'=>'sda:sdb',//"{"block_devices": ["Select a valid choice. sda:sdb is not one of the available choices."]}"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$hdr[] = "Authorization: "."OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key=$consumer_key, oauth_token=$consumer_token, oauth_signature=&$secret, oauth_nonce=".md5(microtime().mt_rand()).", oauth_timestamp=".time();
curl_setopt($ch, CURLOPT_HTTPHEADER, $hdr);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
$result_txt = curl_exec($ch);
var_dump($result_txt);