# OS build model

> An OS build names an operating system once, then maps that name to the image or template each resource handler needs

---

Site [llms.txt](/llms.txt)

---

An OS build is an instance of `externalcontent.models.OSBuild`. It lets a user pick Windows Server 2022 without knowing that it means one AMI in AWS and a different template in vCenter.

![Diagram of one OS build mapped to a different image or template on each resource handler.](/img/cmp/developer-resources/guide/models/os-builds/os-build-object-model.png)

## Mapping a build to provider images

Each pairing of an OS build with a technology that can provide it is an `OSBuildAttribute`, whose `template_name` field holds the provider's identifier for the image or template. They have the global ID prefix `IMG`.

`OSBuildAttribute` is sub-typed, meaning the returned object is a technology-specific subclass with extra fields: `AmazonMachineImage` for AWS, `AzureARMImage` for Azure Resource Manager, `VsphereOSBuildAttribute` for vCenter. Call `cast()` to reach those fields.

## Where a build is offered

`OSBuild.environments` decides which environments offer the build; from an environment, read `environment.os_builds`. Applications declare the builds they can be installed on as `Application.os_builds`; from a build, read `os_build.application_set`.

Two fields shape how a server is built:

- `use_handler_template`, labeled Use Template Provisioning, provisions from the handler's template rather than building the server from scratch, and stops a provisioning engine from being asked to install the operating system. Builds created in the Add OS Build dialog are template-based.
- `os_family` is what `is_windows()` and `is_linux()` test, by walking up to the root of the family tree. Use them instead of parsing the build's name.

## Related

- [OS Builds](/docs/cmp/configure/infrastructure/os-builds/): Create OS builds and map them to images and templates.
- [Resource handler model](/docs/cmp/developer-resources/guide/models/resource-handlers/): The handler mapping, including the capability flag for imports.
- [Environment model](/docs/cmp/developer-resources/guide/models/environments/): Where a build is offered and what else an environment governs.
