MAAS API - Changing storage to flat layout

Hi,

I’m having a little trouble getting the op-set_storage_layout call to work.

I’m using Ansibles URI module to make the call.

 - name: Change Storage Layout to flat
    uri:
      url: "{{ maas_url }}/MAAS/api/2.0/machines/{{ system_id }}/op-set_storage_layout"
      method: POST
      headers:
        Content-Type: "application/json"
        Authorization: "OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key={{ consumer_key }}, oauth_token={{ token }}, oauth_signature={{ signature }}, oauth_nonce={{ lookup('pipe', 'uuidgen') }}, oauth_timestamp={{ lookup('pipe', 'date +%s') }}"
      body_format: json
      body: |
        {
        "storage_layout":"flat"
        }
      status_code:
        - 200
    register: block_devices_result
    delegate_to: 192.168.0.100

I’m getting an error 400 which also states in the body: “Failed to configure storage layout ‘f’: Unknown storage layout: f”.

I’m unsure as to why its cutting off the lat…

Hi @ryans17 and welcome to MAAS discourse.

What version of MAAS are you using?

Are you able to reproduce the error using the MAAS API or CLI?

The content type is not json, it’s multipart/form-data. See https://maas.io/docs/api

2 Likes

Yes my bad! Thank you for the assist.

All of my other calls were like the previous one and I didn’t have an issue.

  - name: Change Storage Layout to flat
    uri:
      url: "{{ maas_url }}/MAAS/api/2.0/machines/{{ system_id }}/op-set_storage_layout"
      method: POST
      headers:
        Content-Type: "multipart/form-data"
        Authorization: "OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key={{ consumer_key }}, oauth_token={{ token }}, oauth_signature={{ signature }}, oauth_nonce={{ lookup('pipe', 'uuidgen') }}, oauth_timestamp={{ lookup('pipe', 'date +%s') }}"
      body_format: form-multipart
      body:
        storage_layout: "flat"
      status_code:
        - 200
    register: block_devices_result
    delegate_to: 192.168.0.100

I’m using version 3.3.5

My issue is now resolved. Thank you for taking the time to offer assistance.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.