Fix microversion 2.98 doc/tests for update/rebuild APIs

microversion 2.98 changed the GET and GET list details
API response to expand the image field
- https://review.opendev.org/c/openstack/nova/+/939649

but when we change the views/servers.py then update server
and rebuild server API response also gets updated.
- https://review.opendev.org/c/openstack/nova/+/939649/12/nova/api/openstack/compute/views/servers.py#595

The microversion change actually changed the response for
the update and rebuild API but did not update the documentation
about this change. Neither added test for rebuild and update
which verify the response change.

Since microversion 2.75, we have made all these 4 APIs response
consistent.

Implements: blueprint image-properties-in-server-show

Change-Id: Ifc2edc59c601391a31fd8953c742969e5b368767
This commit is contained in:
Ghanshyam Mann 2025-02-26 20:49:24 -08:00 committed by Ghanshyam
parent f9e89bc0d1
commit 7a00971b8f
13 changed files with 274 additions and 5 deletions

View File

@ -959,6 +959,11 @@ Response
- host_status: host_status_update_rebuild
- key_name: key_name_resp_update
**Example Update Server Details (2.98)**
.. literalinclude:: ../../doc/api_samples/servers/v2.98/server-update-resp.json
:language: javascript
**Example Update Server Details (2.96)**
.. literalinclude:: ../../doc/api_samples/servers/v2.96/server-update-resp.json

View File

@ -73,6 +73,7 @@
},
"name": "foobar",
"os-extended-volumes:volumes_attached": [],
"pinned_availability_zone": "us-west",
"progress": 0,
"security_groups": [
{

View File

@ -0,0 +1,15 @@
{
"rebuild" : {
"accessIPv4" : "1.2.3.4",
"accessIPv6" : "80fe::",
"OS-DCF:diskConfig": "AUTO",
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
"name" : "foobar",
"adminPass" : "seekr3t",
"hostname": "updated-hostname.example.com",
"metadata" : {
"meta_var" : "meta_val"
},
"user_data": "ZWNobyAiaGVsbG8gd29ybGQi"
}
}

View File

@ -0,0 +1,8 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"OS-DCF:diskConfig": "AUTO",
"hostname": "new-server-hostname.example.com"
}
}

View File

@ -0,0 +1,90 @@
{
"server": {
"OS-DCF:diskConfig": "AUTO",
"OS-EXT-AZ:availability_zone": "us-west",
"OS-EXT-SRV-ATTR:hostname": "new-server-hostname.example.com",
"OS-EXT-STS:power_state": 1,
"OS-EXT-STS:task_state": null,
"OS-EXT-STS:vm_state": "active",
"OS-SRV-USG:launched_at": "2025-02-27T03:58:15.509865",
"OS-SRV-USG:terminated_at": null,
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
"private": [
{
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:0d:11:74",
"OS-EXT-IPS:type": "fixed",
"addr": "192.168.1.30",
"version": 4
}
]
},
"config_drive": "",
"created": "2025-02-27T03:58:14Z",
"description": null,
"flavor": {
"disk": 1,
"ephemeral": 0,
"extra_specs": {},
"original_name": "m1.tiny",
"ram": 512,
"swap": 0,
"vcpus": 1
},
"hostId": "2091634baaccdc4c5a1d57069c833e402921df696b7f970791b12ec6",
"id": "39115d82-00be-4432-84b5-381a89d7ebde",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/6f70656e737461636b20342065766572/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
],
"properties": {
"architecture": "x86_64",
"auto_disk_config": "True",
"base_image_ref": "70a599e0-31e7-49b7-b260-868f441e862b",
"container_format": "ova",
"disk_format": "vhd",
"kernel_id": "nokernel",
"min_disk": "1",
"min_ram": "0",
"ramdisk_id": "nokernel"
}
},
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/servers/39115d82-00be-4432-84b5-381a89d7ebde",
"rel": "self"
},
{
"href": "http://openstack.example.com/6f70656e737461636b20342065766572/servers/39115d82-00be-4432-84b5-381a89d7ebde",
"rel": "bookmark"
}
],
"locked": false,
"locked_reason": null,
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"os-extended-volumes:volumes_attached": [],
"pinned_availability_zone": "us-west",
"progress": 0,
"security_groups": [
{
"name": "default"
}
],
"server_groups": [],
"status": "ACTIVE",
"tags": [],
"tenant_id": "6f70656e737461636b20342065766572",
"trusted_image_certificates": null,
"updated": "2025-02-27T03:58:15Z",
"user_id": "fake"
}
}

View File

@ -267,8 +267,8 @@ REST_API_VERSION_HISTORY = """REST API Version History:
``DELETE /servers/{server_id}/shares/{share_id} which delete an
attachment.
* 2.98 - Add support for returning embedded image properties in
``server show`` and ``server list --long`` and in the ``server
rebuild`` responses.
``server show``, ``server list --long``, `server update``, and
in the ``server rebuild`` responses.
* 2.99 - Add the spice-direct console type to the spice console protocol.
* 2.100 - Add support for returning associated scheduler_hints in
``GET /servers/{server_id}``, ``GET /servers/detail``,

View File

@ -1277,8 +1277,9 @@ to the `manage-shares documentation`_.
Add support for including image properties as new ``properties`` subkey
under the struct at the existing ``image`` key in the response for
``GET /servers/{server_id}`` (server show), ``GET /servers/detail``
(list server --long) and in the rebuild case of
``POST /server/{server_id}/action`` (server rebuild) API response.
(list server --long), ``PUT /servers/{server_id}`` (server update), and in the
rebuild case of ``POST /server/{server_id}/action`` (server rebuild)
API response.
.. _microversion 2.99:

View File

@ -73,6 +73,7 @@
},
"name": "foobar",
"os-extended-volumes:volumes_attached": [],
"pinned_availability_zone": "us-west",
"progress": 0,
"security_groups": [
{

View File

@ -0,0 +1,15 @@
{
"rebuild" : {
"accessIPv4" : "%(access_ip_v4)s",
"accessIPv6" : "%(access_ip_v6)s",
"OS-DCF:diskConfig": "AUTO",
"imageRef" : "%(uuid)s",
"name" : "%(name)s",
"adminPass" : "%(pass)s",
"hostname": "%(hostname)s",
"metadata" : {
"meta_var" : "meta_val"
},
"user_data": "ZWNobyAiaGVsbG8gd29ybGQi"
}
}

View File

@ -0,0 +1,8 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"OS-DCF:diskConfig": "AUTO",
"hostname": "new-server-hostname.example.com"
}
}

View File

@ -0,0 +1,90 @@
{
"server": {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"addresses": {
"private": [
{
"addr": "%(ip)s",
"OS-EXT-IPS-MAC:mac_addr": "00:0c:29:0d:11:74",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"created": "%(isotime)s",
"description": null,
"locked": false,
"locked_reason": null,
"flavor": {
"disk": 1,
"ephemeral": 0,
"extra_specs": {},
"original_name": "m1.tiny",
"ram": 512,
"swap": 0,
"vcpus": 1
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(compute_endpoint)s/images/%(uuid)s",
"rel": "bookmark"
}
],
"properties": {
"architecture": "x86_64",
"auto_disk_config": "True",
"base_image_ref": "%(uuid)s",
"container_format": "ova",
"disk_format": "vhd",
"kernel_id": "nokernel",
"min_disk": "1",
"min_ram": "0",
"ramdisk_id": "nokernel"
}
},
"key_name": null,
"links": [
{
"href": "%(versioned_compute_endpoint)s/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(compute_endpoint)s/servers/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"config_drive": "",
"OS-DCF:diskConfig": "AUTO",
"OS-EXT-AZ:availability_zone": "us-west",
"OS-EXT-SRV-ATTR:hostname": "new-server-hostname.example.com",
"OS-EXT-STS:power_state": 1,
"OS-EXT-STS:task_state": null,
"OS-EXT-STS:vm_state": "active",
"os-extended-volumes:volumes_attached": [],
"OS-SRV-USG:launched_at": "%(strtime)s",
"OS-SRV-USG:terminated_at": null,
"pinned_availability_zone": "us-west",
"progress": 0,
"security_groups": [
{
"name": "default"
}
],
"server_groups": [],
"status": "ACTIVE",
"tags": [],
"tenant_id": "6f70656e737461636b20342065766572",
"trusted_image_certificates": null,
"updated": "%(isotime)s",
"user_id": "fake"
}
}

View File

@ -670,6 +670,40 @@ class ServerSampleJson298Test(ServersSampleJsonTest):
scenarios = [('v2_98', {'api_major_version': 'v2.1'})]
ADMIN_API = False
def test_server_rebuild(self):
uuid = self._post_server(
use_common_server_api_samples=self.use_common_server_post
)
params = {
'uuid': self.glance.auto_disk_config_enabled_image['id'],
'name': 'foobar',
'pass': 'seekr3t',
'hostid': '[a-f0-9]+',
'access_ip_v4': '1.2.3.4',
'access_ip_v6': '80fe::',
'hostname': 'updated-hostname.example.com',
}
resp = self._do_post(
'servers/%s/action' % uuid,
'server-action-rebuild',
params,
)
subs = params.copy()
del subs['uuid']
self._verify_response('server-action-rebuild-resp', subs, resp, 202)
def test_update_server(self):
uuid = self._post_server(
use_common_server_api_samples=self.use_common_server_post)
subs = {}
subs['hostid'] = '[a-f0-9]+'
subs['access_ip_v4'] = '1.2.3.4'
subs['access_ip_v6'] = '80fe::'
response = self._do_put('servers/%s' % uuid,
'server-update-req', subs)
self._verify_response('server-update-resp', subs, response, 200)
class ServersSampleJson2100Test(ServersSampleJsonTest):
microversion = '2.100'

View File

@ -4,6 +4,7 @@ features:
The 2.98 microversion has been added. This microversion adds support for
including image properties as new ``properties`` subkey under the struct at
the existing ``image`` key in the response for ``GET /servers/{server_id}``
(server show) and ``GET /servers/detail`` (list server --long) APIs.
(server show), ``PUT /servers/{server_id}``
(server update), and ``GET /servers/detail`` (list server --long) APIs.
Also the same is included in rebuild case of
``POST /server/{server_id}/action`` (server rebuild) API response.