From b9b6e37a75aefa99bfb07756f29748732c7d77af Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Sat, 2 Mar 2019 12:23:14 -0500 Subject: [PATCH] Add support for compute API v2.70 - os-volume_attachments This adds the compute API response schema validation for the 2.70 microversion and the following APIs: - GET /servers/{server_id}/os-volume_attachments (list) - GET /servers/{server_id}/os-volume_attachments/{volume_id} (show) - POST /servers/{server_id}/os-volume_attachments (attach) This will be used in an upcoming change for testing root volume attach/detach of a shelved offloaded server. Since the response schema for these have not changed since 2.1 we have to backfill all of the other servers API response schema files going back to 2.1. Change-Id: I2f36a51fa47b28df1afada5396dec3ce7dc43d78 --- doc/source/microversion_testing.rst | 4 + .../response/compute/v2_16/servers.py | 3 + .../response/compute/v2_19/servers.py | 3 + .../response/compute/v2_26/servers.py | 3 + .../response/compute/v2_3/servers.py | 3 + .../response/compute/v2_47/servers.py | 3 + .../response/compute/v2_48/servers.py | 3 + .../response/compute/v2_54/servers.py | 3 + .../response/compute/v2_57/servers.py | 3 + .../response/compute/v2_6/servers.py | 3 + .../response/compute/v2_63/servers.py | 3 + .../response/compute/v2_70/__init__.py | 0 .../response/compute/v2_70/servers.py | 80 +++++++++++++++++++ .../response/compute/v2_8/servers.py | 3 + .../response/compute/v2_9/servers.py | 3 + .../lib/services/compute/servers_client.py | 7 +- 16 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 tempest/lib/api_schema/response/compute/v2_70/__init__.py create mode 100644 tempest/lib/api_schema/response/compute/v2_70/servers.py diff --git a/doc/source/microversion_testing.rst b/doc/source/microversion_testing.rst index 4b1c145fb9..eaab168b27 100644 --- a/doc/source/microversion_testing.rst +++ b/doc/source/microversion_testing.rst @@ -406,6 +406,10 @@ Microversion tests implemented in Tempest .. _2.63: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id57 + * `2.70`_ + + .. _2.70: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id63 + * Volume * `3.3`_ diff --git a/tempest/lib/api_schema/response/compute/v2_16/servers.py b/tempest/lib/api_schema/response/compute/v2_16/servers.py index 72b84f5f2f..fc81ff70aa 100644 --- a/tempest/lib/api_schema/response/compute/v2_16/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_16/servers.py @@ -168,3 +168,6 @@ rebuild_server_with_admin_pass = copy.deepcopy( servers.rebuild_server_with_admin_pass) show_server_diagnostics = copy.deepcopy(servers.show_server_diagnostics) get_remote_consoles = copy.deepcopy(servers.get_remote_consoles) +attach_volume = copy.deepcopy(servers.attach_volume) +show_volume_attachment = copy.deepcopy(servers.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_19/servers.py b/tempest/lib/api_schema/response/compute/v2_19/servers.py index e3e8ad16b9..b6c3c14965 100644 --- a/tempest/lib/api_schema/response/compute/v2_19/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_19/servers.py @@ -58,3 +58,6 @@ rebuild_server_with_admin_pass['response_body']['properties']['server'][ list_servers = copy.deepcopy(serversv216.list_servers) show_server_diagnostics = copy.deepcopy(serversv216.show_server_diagnostics) get_remote_consoles = copy.deepcopy(serversv216.get_remote_consoles) +attach_volume = copy.deepcopy(serversv216.attach_volume) +show_volume_attachment = copy.deepcopy(serversv216.show_volume_attachment) +list_volume_attachments = copy.deepcopy(serversv216.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_26/servers.py b/tempest/lib/api_schema/response/compute/v2_26/servers.py index 8e62dc3940..5a0f98732a 100644 --- a/tempest/lib/api_schema/response/compute/v2_26/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_26/servers.py @@ -101,3 +101,6 @@ delete_tag = {'status_code': [204]} list_servers = copy.deepcopy(servers219.list_servers) show_server_diagnostics = copy.deepcopy(servers219.show_server_diagnostics) get_remote_consoles = copy.deepcopy(servers219.get_remote_consoles) +attach_volume = copy.deepcopy(servers219.attach_volume) +show_volume_attachment = copy.deepcopy(servers219.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers219.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_3/servers.py b/tempest/lib/api_schema/response/compute/v2_3/servers.py index 18fb352982..1674c1b116 100644 --- a/tempest/lib/api_schema/response/compute/v2_3/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_3/servers.py @@ -173,3 +173,6 @@ rebuild_server = copy.deepcopy(servers.rebuild_server) rebuild_server_with_admin_pass = copy.deepcopy( servers.rebuild_server_with_admin_pass) show_server_diagnostics = copy.deepcopy(servers.show_server_diagnostics) +attach_volume = copy.deepcopy(servers.attach_volume) +show_volume_attachment = copy.deepcopy(servers.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_47/servers.py b/tempest/lib/api_schema/response/compute/v2_47/servers.py index 0fbacd3fc4..d580f2c63c 100644 --- a/tempest/lib/api_schema/response/compute/v2_47/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_47/servers.py @@ -66,3 +66,6 @@ check_tag_existence = copy.deepcopy(servers226.check_tag_existence) update_tag = copy.deepcopy(servers226.update_tag) delete_tag = copy.deepcopy(servers226.delete_tag) list_servers = copy.deepcopy(servers226.list_servers) +attach_volume = copy.deepcopy(servers226.attach_volume) +show_volume_attachment = copy.deepcopy(servers226.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers226.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_48/servers.py b/tempest/lib/api_schema/response/compute/v2_48/servers.py index 84b5a2a550..e2e45bc29e 100644 --- a/tempest/lib/api_schema/response/compute/v2_48/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_48/servers.py @@ -129,3 +129,6 @@ update_server = copy.deepcopy(servers247.update_server) rebuild_server = copy.deepcopy(servers247.rebuild_server) rebuild_server_with_admin_pass = copy.deepcopy( servers247.rebuild_server_with_admin_pass) +attach_volume = copy.deepcopy(servers247.attach_volume) +show_volume_attachment = copy.deepcopy(servers247.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers247.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_54/servers.py b/tempest/lib/api_schema/response/compute/v2_54/servers.py index 099e1b89b5..2c2bff04a3 100644 --- a/tempest/lib/api_schema/response/compute/v2_54/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_54/servers.py @@ -55,3 +55,6 @@ delete_all_tags = copy.deepcopy(servers248.delete_all_tags) check_tag_existence = copy.deepcopy(servers248.check_tag_existence) update_tag = copy.deepcopy(servers248.update_tag) delete_tag = copy.deepcopy(servers248.delete_tag) +attach_volume = copy.deepcopy(servers248.attach_volume) +show_volume_attachment = copy.deepcopy(servers248.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers248.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_57/servers.py b/tempest/lib/api_schema/response/compute/v2_57/servers.py index 0099a2bc54..aa57d253bb 100644 --- a/tempest/lib/api_schema/response/compute/v2_57/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_57/servers.py @@ -59,3 +59,6 @@ delete_all_tags = copy.deepcopy(servers254.delete_all_tags) check_tag_existence = copy.deepcopy(servers254.check_tag_existence) update_tag = copy.deepcopy(servers254.update_tag) delete_tag = copy.deepcopy(servers254.delete_tag) +attach_volume = copy.deepcopy(servers254.attach_volume) +show_volume_attachment = copy.deepcopy(servers254.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers254.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_6/servers.py b/tempest/lib/api_schema/response/compute/v2_6/servers.py index d5774de8cc..922bf7923c 100644 --- a/tempest/lib/api_schema/response/compute/v2_6/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_6/servers.py @@ -28,6 +28,9 @@ rebuild_server = copy.deepcopy(servers.rebuild_server) rebuild_server_with_admin_pass = copy.deepcopy( servers.rebuild_server_with_admin_pass) show_server_diagnostics = copy.deepcopy(servers.show_server_diagnostics) +attach_volume = copy.deepcopy(servers.attach_volume) +show_volume_attachment = copy.deepcopy(servers.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers.list_volume_attachments) # NOTE: The consolidated remote console API got introduced with v2.6 # with bp/consolidate-console-api. See Nova commit 578bafeda diff --git a/tempest/lib/api_schema/response/compute/v2_63/servers.py b/tempest/lib/api_schema/response/compute/v2_63/servers.py index 3c3d41c757..01910aab4c 100644 --- a/tempest/lib/api_schema/response/compute/v2_63/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_63/servers.py @@ -73,3 +73,6 @@ delete_all_tags = copy.deepcopy(servers257.delete_all_tags) check_tag_existence = copy.deepcopy(servers257.check_tag_existence) update_tag = copy.deepcopy(servers257.update_tag) delete_tag = copy.deepcopy(servers257.delete_tag) +attach_volume = copy.deepcopy(servers257.attach_volume) +show_volume_attachment = copy.deepcopy(servers257.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers257.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_70/__init__.py b/tempest/lib/api_schema/response/compute/v2_70/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tempest/lib/api_schema/response/compute/v2_70/servers.py b/tempest/lib/api_schema/response/compute/v2_70/servers.py new file mode 100644 index 0000000000..5ca4cc8290 --- /dev/null +++ b/tempest/lib/api_schema/response/compute/v2_70/servers.py @@ -0,0 +1,80 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import copy + +from tempest.lib.api_schema.response.compute.v2_1 import servers as servers2_1 +from tempest.lib.api_schema.response.compute.v2_63 import servers as servers263 + + +########################################################################### +# +# 2.70: +# +# Exposes virtual device tags for volume attachments and virtual interfaces +# (ports). A tag parameter is added to the response body for the following +# APIs: +# +# Volumes +# +# - GET /servers/{server_id}/os-volume_attachments (list) +# - GET /servers/{server_id}/os-volume_attachments/{volume_id} (show) +# - POST /servers/{server_id}/os-volume_attachments (attach) +# +# Ports +# +# - GET /servers/{server_id}/os-interface (list) +# - GET /servers/{server_id}/os-interface/{port_id} (show) +# - POST /servers/{server_id}/os-interface (attach) +# +########################################################################### + +attach_volume = copy.deepcopy(servers2_1.attach_volume) +attach_volume['response_body']['properties']['volumeAttachment'][ + 'properties'].update({'tag': {'type': ['string', 'null']}}) +attach_volume['response_body']['properties']['volumeAttachment'][ + 'required'].append('tag') + +show_volume_attachment = copy.deepcopy(servers2_1.show_volume_attachment) +show_volume_attachment['response_body']['properties']['volumeAttachment'][ + 'properties'].update({'tag': {'type': ['string', 'null']}}) +show_volume_attachment['response_body']['properties'][ + 'volumeAttachment']['required'].append('tag') + +list_volume_attachments = copy.deepcopy(servers2_1.list_volume_attachments) +list_volume_attachments['response_body']['properties']['volumeAttachments'][ + 'items']['properties'].update({'tag': {'type': ['string', 'null']}}) +list_volume_attachments['response_body']['properties'][ + 'volumeAttachments']['items']['required'].append('tag') + +# TODO(mriedem): Handle the os-interface changes when there is a test that +# needs them from this microversion onward. + +# NOTE(lajoskatona): Below are the unchanged schema in this microversion. We +# need to keep this schema in this file to have the generic way to select the +# right schema based on self.schema_versions_info mapping in service client. +# ****** Schemas unchanged since microversion 2.63 *** +list_servers_detail = copy.deepcopy(servers263.list_servers_detail) +rebuild_server = copy.deepcopy(servers263.rebuild_server) +rebuild_server_with_admin_pass = copy.deepcopy( + servers263.rebuild_server_with_admin_pass) +update_server = copy.deepcopy(servers263.update_server) +get_server = copy.deepcopy(servers263.get_server) +list_servers = copy.deepcopy(servers263.list_servers) +show_server_diagnostics = copy.deepcopy(servers263.show_server_diagnostics) +get_remote_consoles = copy.deepcopy(servers263.get_remote_consoles) +list_tags = copy.deepcopy(servers263.list_tags) +update_all_tags = copy.deepcopy(servers263.update_all_tags) +delete_all_tags = copy.deepcopy(servers263.delete_all_tags) +check_tag_existence = copy.deepcopy(servers263.check_tag_existence) +update_tag = copy.deepcopy(servers263.update_tag) +delete_tag = copy.deepcopy(servers263.delete_tag) diff --git a/tempest/lib/api_schema/response/compute/v2_8/servers.py b/tempest/lib/api_schema/response/compute/v2_8/servers.py index df7847f9b0..3dbab3f93d 100644 --- a/tempest/lib/api_schema/response/compute/v2_8/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_8/servers.py @@ -35,3 +35,6 @@ rebuild_server = copy.deepcopy(servers.rebuild_server) rebuild_server_with_admin_pass = copy.deepcopy( servers.rebuild_server_with_admin_pass) show_server_diagnostics = copy.deepcopy(servers.show_server_diagnostics) +attach_volume = copy.deepcopy(servers.attach_volume) +show_volume_attachment = copy.deepcopy(servers.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers.list_volume_attachments) diff --git a/tempest/lib/api_schema/response/compute/v2_9/servers.py b/tempest/lib/api_schema/response/compute/v2_9/servers.py index 55f8e7502d..ee0313dd12 100644 --- a/tempest/lib/api_schema/response/compute/v2_9/servers.py +++ b/tempest/lib/api_schema/response/compute/v2_9/servers.py @@ -54,3 +54,6 @@ rebuild_server_with_admin_pass['response_body']['properties']['server'][ list_servers = copy.deepcopy(servers.list_servers) show_server_diagnostics = copy.deepcopy(servers.show_server_diagnostics) get_remote_consoles = copy.deepcopy(servers.get_remote_consoles) +attach_volume = copy.deepcopy(servers.attach_volume) +show_volume_attachment = copy.deepcopy(servers.show_volume_attachment) +list_volume_attachments = copy.deepcopy(servers.list_volume_attachments) diff --git a/tempest/lib/services/compute/servers_client.py b/tempest/lib/services/compute/servers_client.py index 18e08cc066..b81a3f857b 100644 --- a/tempest/lib/services/compute/servers_client.py +++ b/tempest/lib/services/compute/servers_client.py @@ -33,6 +33,7 @@ from tempest.lib.api_schema.response.compute.v2_54 import servers as schemav254 from tempest.lib.api_schema.response.compute.v2_57 import servers as schemav257 from tempest.lib.api_schema.response.compute.v2_6 import servers as schemav26 from tempest.lib.api_schema.response.compute.v2_63 import servers as schemav263 +from tempest.lib.api_schema.response.compute.v2_70 import servers as schemav270 from tempest.lib.api_schema.response.compute.v2_8 import servers as schemav28 from tempest.lib.api_schema.response.compute.v2_9 import servers as schemav29 from tempest.lib.common import rest_client @@ -55,7 +56,8 @@ class ServersClient(base_compute_client.BaseComputeClient): {'min': '2.48', 'max': '2.53', 'schema': schemav248}, {'min': '2.54', 'max': '2.56', 'schema': schemav254}, {'min': '2.57', 'max': '2.62', 'schema': schemav257}, - {'min': '2.63', 'max': None, 'schema': schemav263}] + {'min': '2.63', 'max': '2.69', 'schema': schemav263}, + {'min': '2.70', 'max': None, 'schema': schemav270}] def __init__(self, auth_provider, service, region, enable_instance_password=True, **kwargs): @@ -426,6 +428,7 @@ class ServersClient(base_compute_client.BaseComputeClient): resp, body = self.post('servers/%s/os-volume_attachments' % server_id, post_body) body = json.loads(body) + schema = self.get_schema(self.schema_versions_info) self.validate_response(schema.attach_volume, resp, body) return rest_client.ResponseBody(resp, body) @@ -460,6 +463,7 @@ class ServersClient(base_compute_client.BaseComputeClient): resp, body = self.get('servers/%s/os-volume_attachments/%s' % ( server_id, volume_id)) body = json.loads(body) + schema = self.get_schema(self.schema_versions_info) self.validate_response(schema.show_volume_attachment, resp, body) return rest_client.ResponseBody(resp, body) @@ -473,6 +477,7 @@ class ServersClient(base_compute_client.BaseComputeClient): resp, body = self.get('servers/%s/os-volume_attachments' % ( server_id)) body = json.loads(body) + schema = self.get_schema(self.schema_versions_info) self.validate_response(schema.list_volume_attachments, resp, body) return rest_client.ResponseBody(resp, body)