0

I am playing with MaaS in a vSphere environment so I can simulate large clusters. I have finished my auto-provisioning PowerShell script, where I can provision a bunch of virtual machines to be added to the MaaS controller. I can add these nodes manually in the Controller GUI and I was able to commission them accordingly. I'm currently trying to figure out how to add the machines via the MaaS CLI, and I'm stuck on the power_parameters parameter. Based off the MaaS API documentation, I have to add everything as a key=value type.

Where I'm stuck is on how to add that parameter in the CLI. If I don't pass power_parameters, I get this error:

400 BAD REQUEST

       Content-Type: application/json; charset=utf-8
               Date: Mon, 25 Mar 2019 21:01:03 GMT
             Server: TwistedWeb/16.0.0
             Status: 400
  Transfer-Encoding: chunked
               Vary: Cookie
    X-Frame-Options: SAMEORIGIN

{"power_parameters": ["This field is required."]}

But I cannot figure out the proper string formatting for the parameter. I have tried several combos:

# tried adding it as a string as the docs say
maas <user> machines create -d \
  ... \
  power_parameters="power_vm_name=<vmname> power_uuid=<vmuuid>"

# tried query string separating
maas <user> machines create -d \
  ... \
  power_parameters="power_vm_name=<vmname>&power_uuid=<vmuuid>"

# tried comma separating
maas <user> machines create -d \
  ... \
  power_parameters=power_vm_name=<vmname>,power_uuid=<vmuuid>

# tried individual parameters
maas <user> machines create -d \
  ... \
  power_vm_name=<vmname> power_uuid=<vmuuid>

I get this error with every permutation I've tried:

400 BAD REQUEST

       Content-Type: text/plain; charset=utf-8
               Date: Mon, 25 Mar 2019 20:54:24 GMT
             Server: TwistedWeb/16.0.0
             Status: 400
  Transfer-Encoding: chunked
               Vary: Cookie
    X-Frame-Options: SAMEORIGIN

Failed to parse JSON power_parameters

I know I can send the raw JSON payload via REST, but I don't really want to implement a REST client in PowerShell for MaaS.

What is the proper string formatting for adding power_parameters in the MaaS CLI?

1

So, I ripped apart the MaaS CLI code base, and I saw lots of references to power_parameters_<param> in the code base, which led me to believe it's looking for a specific key formatting.

This is what ended up working for me:

maas <user> machines create -d \\
    architecture=amd64 \
    mac_addresses=<mac> \
    domain=<domain> \
    hostname=<name> \
    power_type=vmware \
    power_parameters_power_vm_name=<vm_name> \
    power_parameters_power_uuid=<vm_uuid> \
    power_parameters_power_address=<vcenter_host_name> \
    power_parameters_power_user='<maas_user_in_quotes>' \
    power_parameters_power_pass='<password_in_quotes>' \
    power_parameters_power_port=443 \
    power_parameters_power_protocol=https+unverified

I was then able to see the machine in the Controller UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.