Creating traits

PUT /traits/{name}

Insert a new custom trait. If the trait already exists, 204 is returned. This API call requires custom parameters that are only supported in Virtuozzo Infrastructure.

There are two kinds of traits: the standard traits and the custom traits. The standard traits are interoperable across different OpenStack cloud deployments. The definition of standard traits comes from the os-traits library. The standard traits are read-only in the placement API which means that the user cannot modify any standard traits through API. The custom traits are used by admin users to manage the non-standard qualitative information of resource providers.

A custom trait name for Virtuozzo Infrastructure looks like CUSTOM_HCI_<UUID>, where the <UUID> must be generated using Python’s uuid4() function as follows:

>>> str(uuid.uuid4()).upper().replace('-', '')
'E4A64BAA4BE84887ADE712ABB9B5882A'

So a complete name would be

CUSTOM_HCI_E4A64BAA4BE84887ADE712ABB9B5882A

Source: https://docs.openstack.org/api-ref/placement/?expanded=update-traits-detail#update-traits

Request

Parameters

Name In Type Description
name path string The name of a trait.
display_name body string A human-readable trait name to be displayed in the admin panel.
description body string A human-readable trait description to be displayed in the admin panel.

Example

curl -ks -X PUT -H 'Content-Type: application/json' -H 'OpenStack-API-Version: placement 1.32' -H 'X-Auth-Token: gAAAAA<...>' -d '
{
    "display_name": "placement2",
    "description": "Sample placement #2"
}' https://<node_IP_addr>:8780/traits/CUSTOM_HCI_0A7F6A35E650420CB30200A8359861D9

Response

Status codes

Success

Code Reason
201 - Created Resource was created and is ready to use.
204 - No Content The server has fulfilled the request.

Error

Code Reason
400 - Bad Request

Some content in the request was invalid.