Create vm on specific hypervisor fails

Bug #2043674 reported by Bernard Landon
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openstacksdk
New
Undecided
Unassigned

Bug Description

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.

Revision history for this message
Bernard Landon (thegreenbear) wrote :

FYI: if someone points me in the right direction, I'm happy to try submitting a MR.
I believe the issue is with mapping / the _prepare_request method in https://github.com/openstack/openstacksdk/blob/master/openstack/compute/v2/server.py but I'm not enterely sure.

summary: - Can't cre
+ Can't create server on specific hypervisor
summary: - Can't create server on specific hypervisor
+ Create vm on specific hypervisor fails
Revision history for this message
Kenton McDonough (kent07) wrote :

+1

This same problem applies when trying to set the `hostname` parameter, I get

`Additional properties are not allowed ('OS-EXT-SRV-ATTR:hostname' was unexpected)`

There appear to be some checks done here https://github.com/openstack/openstacksdk/blob/8378110c1ad5abd7a58677369825dbadab461916/openstack/compute/v2/server.py#L277 for similar cases where the attribute name returned from the server is different than the expected name in the request. I think we should add these two attributes to that same check list

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.