CLI commands — osc-placement — branch stable/2026.2
Branch
stable/2026.2@402610a21872(4.9.1+ 2 maintenance commits) — repository https://opendev.org/openstack/osc-placement — analysed on 2026-10-28
osc-placement exposes no API: it is a **plugin of the openstack command line** (python-openstackclient) that turns 31 commands into calls to the Placement REST API. Its "interface" is therefore its commands, and its contract with the outside world is the HTTP requests it sends to Placement (see interactions and client contract).
1. Shared mechanics
- Plugin loading: entry point
openstack.cli.extension = placement(osc_placement/plugin.py). The commands are declared insetup.cfg([entry_points] openstack.placement.v1), one per class. - Microversion choice: the
--os-placement-api-versionoption (envOS_PLACEMENT_API_VERSION), default1(osc_placement/plugin.py:46-58).- With **
1, the client **negotiates: it sendsGET /withOpenStack-API-Version: placement 1.29(MAX_VERSION_NO_GAP). On a 406, it falls back to themax_versionthat the server returns inerrors[0](osc_placement/http.py:69-86,osc_placement/version.py:57-61). - Consequence: by default the CLI uses 1.29 at most. The 1.38 (consumer types) and 1.39 (
in:for traits) features need an explicit version.
- With **
- Supported versions: 1.0 to 1.29, 1.37, 1.38, 1.39 (
osc_placement/version.py:21-55). Any other value is refused by osc-lib before any call [inferred:utils.get_client_classwithAPI_VERSIONS]. - Client-side checks: each command checks the microversion before any HTTP call, through
@version.check(version.ge('X'))orcheck_version(), which raiseValueErrorwith "Operation or argument is not supported with version X; requires at least version Y" (osc_placement/version.py:119-147). Many options are enabled or required depending on the version (required=self.compare_version(...)). - Every request carries
OpenStack-API-Version: placement <version>andAccept: application/json. The endpoint comes from the Keystone catalog (service_type=placement, region and interface of the CLI) (osc_placement/http.py:55-67,osc_placement/plugin.py:29-43).
2. Functional description by family
Resource providers (resource provider create|list|show|set|delete)
- create (
osc_placement/resources/resource_provider.py:26-73):POST /resource_providers, then **GETon the returnedLocation** to show the provider.--parent-providerneeds 1.14. - list (
osc_placement/resources/resource_provider.py:75-219): filters translated into query parameters, each with its minimum microversion: | Filter | Minimum microversion | |---|---| |--uuid,--name| 1.0 | |--member-of| 1.3 | |--resource| 1.4 | |--in-tree| 1.14 | |--required| 1.18, and 1.39 forA,B(in:) | |--forbidden| 1.22 | |--aggregate-uuid| 1.3 | - set (
osc_placement/resources/resource_provider.py:259-310):PUT /resource_providers/{uuid}with name and parent (1.14). - show with
--allocationsaddsGET /resource_providers/{uuid}/allocations.
Inventories (resource provider inventory set|class set|list|show|delete)
- set (
osc_placement/resources/inventory.py:101-252):- replaces the whole inventory, or adds to it with
--amend, which first reads it (GET, thenPUTwith the generation read); --aggregate(1.3) applies the same inventory to every provider of an aggregate: it continues on failure, then reports "Failed to set inventory for N of M resource providers.";--dry-runshows without writing;- resource syntax:
CLASS=totalorCLASS:field=value(osc_placement/resources/inventory.py:80-99).
- replaces the whole inventory, or adds to it with
- class set:
PUTof a single class, with the provider's generation read first (osc_placement/resources/inventory.py:254-305). - delete: one class, or all of them with
--resource-classomitted (1.5+,DELETE /resource_providers/{uuid}/inventories).
Allocations (resource provider allocation set|unset|show|delete)
- set (
osc_placement/resources/allocation.py:47-176):--allocation rp=<uuid>,VCPU=2,...is parsed (osc_placement/resources/allocation.py:23-44);- format: a list before 1.12, a dict after;
--project-idand--user-idare required from 1.8, and--consumer-typefrom 1.38;- from 1.28, read-modify-write:
GET /allocations/{consumer}to readconsumer_generation, thenPUT, thenGETagain to show. There is no retry: if the consumer is changed between the GET and the PUT, the user gets the 409 from Placement.
- unset (1.12+,
osc_placement/resources/allocation.py:178-300): removes some providers or resource classes from the existing allocations. From 1.28 itPUTs an empty dict; before that it usesDELETE.
Resource classes, traits, aggregates, usages, candidates
- resource class (1.2+;
set1.7+ = idempotentPUT). - trait and resource provider trait (1.6+).
resource provider trait setreads the provider to get its generation (osc_placement/resources/trait.py:182-223). - resource provider aggregate set|list (1.1+; from 1.19 with the provider generation,
--generationrequired,osc_placement/resources/aggregate.py:22-89). - resource usage show (1.9+, per project and user); resource provider usage show.
- allocation candidate list (1.10+,
osc_placement/resources/allocation_candidate.py:43-288):--group(1.25) groups the options that follow it into one numbered request group;--limit(1.16),--required(1.17;A,B→in:1.39),--forbidden(1.22),--member-of(1.21),--group-policy(1.25);- the list of
requiredparameters is built byget_required_query_param_from_args(osc_placement/resources/common.py:41-58).
3. Commands, sources and Placement calls
The calls and statuses come from the recording of the functional tests (client contract). "Minimum microversion" is the @version.check of the class; the options may require more.
| Command | Class | Minimum microversion | Placement operations | Statuses seen in tests |
|---|---|---|---|---|
openstack allocation candidate list | osc_placement/resources/allocation_candidate.py:43 | 1.10 | GET /allocation_candidates | 200, 400 |
openstack resource class create | osc_placement/resources/resource_class.py:46 | 1.2 | POST /resource_classes | 201, 400 |
openstack resource class delete | osc_placement/resources/resource_class.py:128 | 1.2 | DELETE /resource_classes/{name} | 204, 400, 404 |
openstack resource class list | osc_placement/resources/resource_class.py:24 | 1.2 | GET /resource_classes | 200 |
openstack resource class set | osc_placement/resources/resource_class.py:70 | 1.7 | PUT /resource_classes/{name} | 201, 204 |
openstack resource class show | osc_placement/resources/resource_class.py:100 | 1.2 | GET /resource_classes/{name} | 200, 404 |
openstack resource provider aggregate list | osc_placement/resources/aggregate.py:91 | 1.1 | GET /resource_providers/{uuid}/aggregates | 200, 404 |
openstack resource provider aggregate set | osc_placement/resources/aggregate.py:22 | 1.1 | PUT /resource_providers/{uuid}/aggregates | 200, 400, 409 |
openstack resource provider allocation delete | osc_placement/resources/allocation.py:348 | 1.0 | DELETE /allocations/{consumer_uuid} | 204, 404 |
openstack resource provider allocation set | osc_placement/resources/allocation.py:47 | 1.0 | GET /allocations/{consumer_uuid}PUT /allocations/{consumer_uuid} | 200, 204 |
openstack resource provider allocation show | osc_placement/resources/allocation.py:302 | 1.0 | GET /allocations/{consumer_uuid} | 200 |
openstack resource provider allocation unset | osc_placement/resources/allocation.py:178 | 1.12 | DELETE /allocations/{consumer_uuid}GET /allocations/{consumer_uuid}PUT /allocations/{consumer_uuid} | 200, 204 |
openstack resource provider create | osc_placement/resources/resource_provider.py:26 | 1.0 | GET /resource_providers/{uuid}POST /resource_providers | 200, 201 |
openstack resource provider delete | osc_placement/resources/resource_provider.py:312 | 1.0 | DELETE /resource_providers/{uuid} | 204, 404, 409 |
openstack resource provider inventory class set | osc_placement/resources/inventory.py:254 | 1.0 | GET /resource_providers/{uuid}PUT /resource_providers/{uuid}/inventories/{resource_class} | 200 |
openstack resource provider inventory delete | osc_placement/resources/inventory.py:307 | 1.0 | DELETE /resource_providers/{uuid}/inventoriesDELETE /resource_providers/{uuid}/inventories/{resource_class} | 204, 404 |
openstack resource provider inventory list | osc_placement/resources/inventory.py:390 | 1.0 | GET /resource_providers/{uuid}/inventoriesGET /resource_providers/{uuid}/usages | 200 |
openstack resource provider inventory set | osc_placement/resources/inventory.py:101 | 1.0 | GET /resource_providersGET /resource_providers/{uuid}GET /resource_providers/{uuid}/inventoriesPUT /resource_providers/{uuid}/inventories | 200, 400, 409 |
openstack resource provider inventory show | osc_placement/resources/inventory.py:350 | 1.0 | GET /resource_providers/{uuid}/inventories/{resource_class}GET /resource_providers/{uuid}/usages | 200, 404 |
openstack resource provider list | osc_placement/resources/resource_provider.py:75 | 1.0 | GET /resource_providers | 200 |
openstack resource provider set | osc_placement/resources/resource_provider.py:259 | 1.0 | PUT /resource_providers/{uuid} | 200, 400, 404 |
openstack resource provider show | osc_placement/resources/resource_provider.py:221 | 1.0 | GET /resource_providers/{uuid}GET /resource_providers/{uuid}/allocations | 200, 404 |
openstack resource provider trait delete | osc_placement/resources/trait.py:225 | 1.6 | DELETE /resource_providers/{uuid}/traits | 204 |
openstack resource provider trait list | osc_placement/resources/trait.py:155 | 1.6 | GET /resource_providers/{uuid}/traits | 200, 404 |
openstack resource provider trait set | osc_placement/resources/trait.py:182 | 1.6 | GET /resource_providers/{uuid}PUT /resource_providers/{uuid}/traits | 200, 400 |
openstack resource provider usage show | osc_placement/resources/usage.py:68 | 1.0 | GET /resource_providers/{uuid}/usages | 200, 404 |
openstack resource usage show | osc_placement/resources/usage.py:24 | 1.9 | GET /usages | 200 |
openstack trait create | osc_placement/resources/trait.py:98 | 1.6 | PUT /traits/{name} | 201 |
openstack trait delete | osc_placement/resources/trait.py:128 | 1.6 | DELETE /traits/{name} | 204, 404 |
openstack trait list | osc_placement/resources/trait.py:24 | 1.6 | GET /traits | 200 |
openstack trait show | osc_placement/resources/trait.py:70 | 1.6 | GET /traits/{name} | 204, 404 |
Source: reverse-spec-osc-placement/01-cli-commands_stable-2026.2.md. The _rewrite/ and _inventory/ files are not published on the site.