Rest API - Deploy

Hello folks,

I’ve been exploring MaaS for automated provisioning with a python script that does BMC config and then initate maas provisioning. So far everything worked well, until I sent the deploy command. It only deploys the default ubuntu release.

Here is my rest code,

def machine_deploy(self, machine_id:str, release:str, osystem="exsi", max_retry:int = 0, current_retry:int = 0, timeout=300):
        payload = {"distro_series": release, "osystem" : osystem}
        print(payload)
        resp = self.session.post(
            url=f"{self.api_url}/machines/{machine_id}/?op=deploy", 
            json=payload,
            **self.req_common_params,
        )
        try:
            resp.raise_for_status()
            logger.info("Machine Deployement Initiated.")
            return
        except Exception as e:
            logger.error(e, resp.content)
            if max_retry and current_retry!= max_retry:
                logger.info(f"Retry Deploy - Attempt {current_retry + 1} / {max_retry}")
                time.sleep(timeout)
                self.machine_deploy(machine_id, release, max_retry, current_retry+1, timeout=timeout)
            resp.raise_for_status()
            return resp.json()

maas.machine_deploy(machine_id=machine.system_id, release="esxi/7.0.3.m", max_retry=3)

Let me know how do I deploy the desired esxi image.

Here is my image list on the rack controller

{
    "images": [
        {
            "name": "esxi/7.0.3.m",
            "architecture": "amd64",
            "subarches": [
                "generic"
            ]
        },
        {
            "name": "ubuntu/jammy",
            "architecture": "amd64",
            "subarches": [
                "ga-22.04",
                "ga-22.04-lowlatency",
                "generic"
            ]
        },
        {
            "name": "ubuntu/focal",
            "architecture": "amd64",
            "subarches": [
                "ga-20.04",
                "ga-20.04-lowlatency",
                "generic",
                "hwe-20.04",
                "hwe-20.04-edge",
                "hwe-20.04-lowlatency",
                "hwe-20.04-lowlatency-edge"
            ]
        },
        {
            "name": "bootloader/uefi",
            "architecture": "arm64",
            "subarches": [
                "generic"
            ]
        },
        {
            "name": "bootloader/uefi",
            "architecture": "amd64",
            "subarches": [
                "generic"
            ]
        },
        {
            "name": "bootloader/open-firmware",
            "architecture": "ppc64el",
            "subarches": [
                "generic"
            ]
        },
        {
            "name": "bootloader/pxe",
            "architecture": "i386",
            "subarches": [
                "generic"
            ]
        }
    ],
    "connected": true,
    "status": "synced"
}

I see a typo in the default value for osystem: osystem="exsi" (instead of "esxi").

That might be the cause, as the deploy would fallback to the default operating system.

I think I might have figured out why it fails, I was sending a it as request body, but sending it as query params worked. Thank you.

But still not able to figure out how to set a static IP for the interface with API

@highlow7, ever get this resolved to your satisfaction?