# Добавление Custom Properties для ВМ

oVirt позволяет добавлять дополнительные свойства в конфигурацию ВМ, которые могут использоваться для хранения информации о ВМ или для гранулярной настройки ВМ (с помощью [VDSM Hooks](https://www.ovirt.org/develop/developer-guide/vdsm/hooks.html)).

По умолчанию в oVirt есть несколько предустановленных Custom Properties, например, sndbuf, jugepages, vhost и другие. Перечень доступных Custom Properties и их назначение описано в [Virtual Machine Management Guide](https://www.ovirt.org/documentation/virtual_machine_management_guide/#Virtual_Machine_Custom_Properties_settings_explained).

Для создания собственных Custom Properties потребуется сначала задать их с помощью команды engine-config на сервере oVirt Engine.

Проверить текущие установленные Custom Properties можно с помощью команды:

```
engine-config -g UserDefinedVMProperties
```

Например, для добавления в Custom Properties свойства owner, в котором можно будет указать имя или e-mail адрес владельца ВМ, выполните команду:

```
engine-config -s UserDefinedVMProperties="owner=^[a-zA-Z0-9_.-@ ]+$" --cver=4.7
```

, где **owner=^\[a-zA-Z0-9\_.-@ ]+$** - это имя свойства и regex выражение для проверки корректности вводимых данных, **--cver=4.7** - атрибут, указывающий версию конфигурацию, которую использует кластер oVirt. Уточнить версию конфигурации можно в свойствах кластера **Compute > Clusters > {*****Cluster\_Name}*****&#x20;> Edit > Compatibility Version**.

При необходимости добавить несколько свойств укажите их через точку с запятой, например:

```
engine-config -s UserDefinedVMProperties="owner=^[a-zA-Z0-9_.-@ ]+$;environment=^(prod|dev|test)$" --cver=4.7
```

После изменения настроек перезапустите службу ovirt-engine.service:

```
systemctl restart ovirt-engine.service
```

Теперь в свойствах ВМ на вкладке Custom Properties появится возможность добавить свойство owner.

Увидеть все настроенные для ВМ свойства можно при выполнении REST API запроса:

<pre><code>    "custom_properties": {
        "custom_property": [
            {
                "name": "owner",
                "value": "user@lab.internal"
            }
        ]
<strong>    }
</strong></code></pre>

или в файле конфигурации ВМ:

```
    <metadata>
        <ns1:qos/>
        <ovirt-vm:vm>
            <ovirt-vm:clusterVersion>4.7</ovirt-vm:clusterVersion>
            <ovirt-vm:custom>
                <ovirt-vm:owner>user@lab.internal</ovirt-vm:owner>
            </ovirt-vm:custom>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://omnimod.gitbook.io/ovirt/konfigurirovanie/dobavlenie-custom-properties-dlya-vm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
