From 7a00971b8f429c07294fa2feabdb87deabaac134 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: 2025年2月26日 20:49:24 -0800 Subject: [PATCH] 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 --- api-ref/source/servers.inc | 5 ++ .../v2.98/server-action-rebuild-resp.json | 1 + .../servers/v2.98/server-action-rebuild.json | 15 ++++ .../servers/v2.98/server-update-req.json | 8 ++ .../servers/v2.98/server-update-resp.json | 90 +++++++++++++++++++ nova/api/openstack/api_version_request.py | 4 +- .../compute/rest_api_version_history.rst | 5 +- .../v2.98/server-action-rebuild-resp.json.tpl | 1 + .../v2.98/server-action-rebuild.json.tpl | 15 ++++ .../servers/v2.98/server-update-req.json.tpl | 8 ++ .../servers/v2.98/server-update-resp.json.tpl | 90 +++++++++++++++++++ .../api_sample_tests/test_servers.py | 34 +++++++ ...props-in-server-show-e28886d164774343.yaml | 3 +- 13 files changed, 274 insertions(+), 5 deletions(-) create mode 100644 doc/api_samples/servers/v2.98/server-action-rebuild.json create mode 100644 doc/api_samples/servers/v2.98/server-update-req.json create mode 100644 doc/api_samples/servers/v2.98/server-update-resp.json create mode 100644 nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-req.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-resp.json.tpl diff --git a/api-ref/source/servers.inc b/api-ref/source/servers.inc index ae2073ae5c98..fbfcb35b1495 100644 --- a/api-ref/source/servers.inc +++ b/api-ref/source/servers.inc @@ -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 diff --git a/doc/api_samples/servers/v2.98/server-action-rebuild-resp.json b/doc/api_samples/servers/v2.98/server-action-rebuild-resp.json index 21e1680bdf00..559e3ddf74b8 100644 --- a/doc/api_samples/servers/v2.98/server-action-rebuild-resp.json +++ b/doc/api_samples/servers/v2.98/server-action-rebuild-resp.json @@ -73,6 +73,7 @@ }, "name": "foobar", "os-extended-volumes:volumes_attached": [], + "pinned_availability_zone": "us-west", "progress": 0, "security_groups": [ { diff --git a/doc/api_samples/servers/v2.98/server-action-rebuild.json b/doc/api_samples/servers/v2.98/server-action-rebuild.json new file mode 100644 index 000000000000..3bea3dd5e2f6 --- /dev/null +++ b/doc/api_samples/servers/v2.98/server-action-rebuild.json @@ -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" + } +} \ No newline at end of file diff --git a/doc/api_samples/servers/v2.98/server-update-req.json b/doc/api_samples/servers/v2.98/server-update-req.json new file mode 100644 index 000000000000..32bc2ddde6b7 --- /dev/null +++ b/doc/api_samples/servers/v2.98/server-update-req.json @@ -0,0 +1,8 @@ +{ + "server": { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", + "OS-DCF:diskConfig": "AUTO", + "hostname": "new-server-hostname.example.com" + } +} \ No newline at end of file diff --git a/doc/api_samples/servers/v2.98/server-update-resp.json b/doc/api_samples/servers/v2.98/server-update-resp.json new file mode 100644 index 000000000000..d92b16a435d7 --- /dev/null +++ b/doc/api_samples/servers/v2.98/server-update-resp.json @@ -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" + } +} \ No newline at end of file diff --git a/nova/api/openstack/api_version_request.py b/nova/api/openstack/api_version_request.py index 4864c60134ff..469aeb114ebc 100644 --- a/nova/api/openstack/api_version_request.py +++ b/nova/api/openstack/api_version_request.py @@ -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``, diff --git a/nova/api/openstack/compute/rest_api_version_history.rst b/nova/api/openstack/compute/rest_api_version_history.rst index f86acf172d1d..70f97fad8700 100644 --- a/nova/api/openstack/compute/rest_api_version_history.rst +++ b/nova/api/openstack/compute/rest_api_version_history.rst @@ -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: diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild-resp.json.tpl index 653e75b0869a..fa0e60cc000b 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild-resp.json.tpl @@ -73,6 +73,7 @@ }, "name": "foobar", "os-extended-volumes:volumes_attached": [], + "pinned_availability_zone": "us-west", "progress": 0, "security_groups": [ { diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild.json.tpl new file mode 100644 index 000000000000..3becc83fba6f --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-action-rebuild.json.tpl @@ -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" + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-req.json.tpl new file mode 100644 index 000000000000..bc4be64a8e67 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-req.json.tpl @@ -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" + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-resp.json.tpl new file mode 100644 index 000000000000..aac2e4f0bf8b --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.98/server-update-resp.json.tpl @@ -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" + } +} diff --git a/nova/tests/functional/api_sample_tests/test_servers.py b/nova/tests/functional/api_sample_tests/test_servers.py index 20c4a1b457f2..cd5a35ff3b00 100644 --- a/nova/tests/functional/api_sample_tests/test_servers.py +++ b/nova/tests/functional/api_sample_tests/test_servers.py @@ -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' diff --git a/releasenotes/notes/image-props-in-server-show-e28886d164774343.yaml b/releasenotes/notes/image-props-in-server-show-e28886d164774343.yaml index 1d0e4d630159..25bf6767e380 100644 --- a/releasenotes/notes/image-props-in-server-show-e28886d164774343.yaml +++ b/releasenotes/notes/image-props-in-server-show-e28886d164774343.yaml @@ -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.

AltStyle によって変換されたページ (->オリジナル) /