blob: 56ba12c5b0947564083b4bd45018cd68114182d2 [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):
26 """Lists all hosts."""
27
28 url = 'os-hosts'
29 if params:
30 url += '?%s' % urllib.urlencode(params)
31
32 resp, body = self.get(url)
33 body = json.loads(body)
34 self.expected_success(200, resp.status)
35 return rest_client.ResponseBody(resp, body)