blob: f3446780d470109616b607ed95af1f0f3c64f391 [file] [log] [blame]
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +03001# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Ken'ichi Ohmichiaff2f8d2016-07-29 10:30:24 -070016from oslo_serialization import jsonutils as json
17from six.moves.urllib import parse as urllib
18
19from tempest.lib.common import rest_client
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030020
21
Ken'ichi Ohmichiaff2f8d2016-07-29 10:30:24 -070022class HostsClient(rest_client.RestClient):
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +030023 """Client class to send CRUD Volume Host API V1 requests"""
Ken'ichi Ohmichiaff2f8d2016-07-29 10:30:24 -070024
25 def list_hosts(self, **params):
Felipe Monteiro25084512017-11-14 22:07:31 +000026 """Lists all hosts.
Ken'ichi Ohmichiaff2f8d2016-07-29 10:30:24 -070027
Felipe Monteiro25084512017-11-14 22:07:31 +000028 For a full list of available parameters, please refer to the official
29 API reference:
Andreas Jaegerbf30ae72019-07-22 19:22:57 +020030 https://docs.openstack.org/api-ref/block-storage/v2/#list-all-hosts
Felipe Monteiro25084512017-11-14 22:07:31 +000031 """
Ken'ichi Ohmichiaff2f8d2016-07-29 10:30:24 -070032 url = 'os-hosts'
33 if params:
34 url += '?%s' % urllib.urlencode(params)
35
36 resp, body = self.get(url)
37 body = json.loads(body)
38 self.expected_success(200, resp.status)
39 return rest_client.ResponseBody(resp, body)