blob: 23de064570b7ab8b4e4070d5dd33c5d3464b66a9 [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# Copyright 2014 NEC Corporation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from oslo_serialization import jsonutils as json
16from six.moves.urllib import parse as urllib
17
18from tempest.lib.api_schema.response.compute.v2_1 import migrations as schema
Eli Qiaoe07eacc2016-03-03 13:49:37 +080019from tempest.lib.api_schema.response.compute.v2_23 import migrations \
20 as schemav223
Matthew Treinish9e26ca82016-02-23 11:43:20 -050021from tempest.lib.common import rest_client
Ghanshyamee9af302016-02-25 06:12:43 +090022from tempest.lib.services.compute import base_compute_client
Matthew Treinish9e26ca82016-02-23 11:43:20 -050023
24
Ghanshyamee9af302016-02-25 06:12:43 +090025class MigrationsClient(base_compute_client.BaseComputeClient):
Eli Qiaoe07eacc2016-03-03 13:49:37 +080026 schema_versions_info = [
27 {'min': None, 'max': '2.22', 'schema': schema},
28 {'min': '2.23', 'max': None, 'schema': schemav223}]
Matthew Treinish9e26ca82016-02-23 11:43:20 -050029
30 def list_migrations(self, **params):
31 """List all migrations.
32
OTSUKA, Yuanyingfaac5712016-09-15 13:53:55 +090033 For a full list of available parameters, please refer to the official
34 API reference:
Andreas Jaegerbf30ae72019-07-22 19:22:57 +020035 https://docs.openstack.org/api-ref/compute/#list-migrations
Matthew Treinish9e26ca82016-02-23 11:43:20 -050036 """
37
38 url = 'os-migrations'
39 if params:
40 url += '?%s' % urllib.urlencode(params)
41
42 resp, body = self.get(url)
43 body = json.loads(body)
Eli Qiaoe07eacc2016-03-03 13:49:37 +080044 schema = self.get_schema(self.schema_versions_info)
Matthew Treinish9e26ca82016-02-23 11:43:20 -050045 self.validate_response(schema.list_migrations, resp, body)
46 return rest_client.ResponseBody(resp, body)