At the moment, it is not possible to create a server on a specific hypervisor.
Expected behavior
-----------------
Running the following, should create a VM on hypervisor-1:
In [51]: value
Out[51]:
{'name': 'test-vm-1',
'flavorRef': 'e7348885-cb8d-46cd-8910-fa771110ac01',
'block_device_mapping_v2': [{'boot_index': 0,
'delete_on_termination': True,
'source_type': 'image',
'destination_type': 'volume',
'volume_size': '20',
'uuid': 'ac05cb46-ff67-418e-8528-81aeaf636e26'}],
'networks': [{'uuid': '3c0e07ef-fc6d-4339-9306-a53ea724b3d5'}]}
In [52]: c.compute.create_server(**value, hypervisor_hostname="hypervisor-1")
Actual behavior
---------------
An exception is raised:
BadRequestException: BadRequestException: 400: Client Error for url: https://xxxx/v2.1/servers, Invalid input for field/attribute server. Value: {'flavorRef': 'e7348885-cb8d-46cd-8910-fa771110ac01', 'block_device_mapping_v2': [{'boot_index': 0, 'delete_on_termination': True, 'source_type': 'image', 'destination_type': 'volume', 'volume_size': '20', 'uuid': 'ac05cb46-ff67-418e-8528-81aeaf636e26'}], 'networks': [{'uuid': '3c0e07ef-fc6d-4339-9306-a53ea724b3d5'}], 'name': 'test-vm-1', 'OS-EXT-SRV-ATTR:hypervisor_hostname': 'hypervisor-1'}. Additional properties are not allowed ('OS-EXT-SRV-ATTR:hypervisor_hostname' was unexpected)
Observations
------------
The problem seems to be the following:
The nova v2.1/servers/ accepts "hypervisor_hostname". But instead of sending it, openstacksdk sends "'OS-EXT-SRV-ATTR:hypervisor_hostname'".
Thus Nova reject the request.
The request sent was:
REQ: curl -g -i -X POST https://xxxx/v2.1/servers -H "Content-Type: application/json" -H "OpenStack-API-Version: compute 2.90" -H "User-Agent: openstacksdk/1.2.0 keystoneauth1/5.3.0 python-requests/2.25.1 CPython/3.10.12" -H "X-Auth-Token: {SHA256}xxxx" -H "X-OpenStack-Nova-API-Version: 2.90" -d '{"server": {"flavorRef": "e7348885-cb8d-46cd-8910-fa771110ac01", "block_device_mapping_v2": [{"boot_index": 0, "delete_on_termination": true, "source_type": "image", "destination_type": "volume", "volume_size": "20", "uuid": "ac05cb46-ff67-418e-8528-81aeaf636e26"}], "networks": [{"uuid": "3c0e07ef-fc6d-4339-9306-a53ea724b3d5"}], "name": "test-vm-1", "OS-EXT-SRV-ATTR:hypervisor_hostname": "hypervisor-1"}}'
Versions
--------
openstacksdk==1.2.0
compute api version used: 2.90.
FYI: if someone points me in the right direction, I'm happy to try submitting a MR. /github. com/openstack/ openstacksdk/ blob/master/ openstack/ compute/ v2/server. py but I'm not enterely sure.
I believe the issue is with mapping / the _prepare_request method in https:/