Creating a Pool with the api/v2.0

Llibyddap

Cadet
Joined
Dec 9, 2017
Messages
6
I'm trying to setup some Ansible automation for TrueNAS-SCALE-22.12.0 running in VirtualBox (for testing). So far I've had great success with most of the endpoints needed, but what doesn't seem to work is the api/v2.0/pool endpoint. I'm working on a new install without any modification other than adding a password for the admin user. Skipping all the Ansible coding, and going right to the swagger interface I've made the following POST to the endpoint (not worried about the authentication it is not meant to be secure):

Code:
curl -X 'POST' \
  'http://192.168.58.102/api/v2.0/pool' \
-H 'accept: */*' \
-H 'Authorization: Basic YWRtaW46MSRQYXNzd29yZA==' \
-H 'Content-Type: application/json' \
-d '{
"data": [
{
"disks": ["sdb", "sdc", "sdd", "sde"],
"name": "Tank",
"type": "RAIDZ1"
}
]
}'


This returns code 200 and a response body of 186. This response code changes with every execution but is always a two or three digit number. However, it does not result in the creation of a new Pool named Tank with four disks.

What I've tired:
- with and without providing a "name" (unsuccessfully)
- exactly replicating the swagger example with all 6 disks (unsuccessfully)
- manually creating my above example/desired structure using the GUI (successfully)

Because I'm able to do everything I'd like via the UI, it doesn't appear to be a VirtualBox issue.

Any thoughts?
 

deamonmv

Cadet
Joined
Mar 7, 2023
Messages
8
If anyone will read it, you need to know this
- payload should be like this

Code:
{
  "name": "mypool",
  "encryption": false,
  "deduplication": null,
  "checksum": null,
  },
  "topology": {
      "data": [
       {
           "disks": ["sdb", "sdc", "sdd", "sde"],
           "type": "RAIDZ1"
       }
  },
  "allow_duplicate_serials": true
}


- API endpoint will return 200 in, i think, all cases.
- Here is important number in response. That is a ID of a job which is resposible for creation of the pool
- You can call this endpoint with ID from response. And check the `state` in response or if you set not correct fields in first place see an error.
Code:
http://xxxxxxxxxxxx/api/v2.0/core/get_jobs/?id=35
 
Top