blob: d8bbadd0cb1f38c344dc471e601c30177a73d82d [file] [log] [blame]
YuikoTakadaac0879a2015-01-22 02:40:03 +00001# Copyright 2015 NEC Corporation. All rights reserved.
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
15import json
16import urllib
17
18from tempest.api_schema.response.compute import baremetal_nodes as schema
19from tempest.common import service_client
20
21
22class BaremetalNodesClientJSON(service_client.ServiceClient):
23 """
24 Tests Baremetal API
25 """
26
27 def list_baremetal_nodes(self, params=None):
28 """List all baremetal nodes."""
29 url = 'os-baremetal-nodes'
30 if params:
31 url += '?%s' % urllib.urlencode(params)
32 resp, body = self.get(url)
33 body = json.loads(body)
34 self.validate_response(schema.list_baremetal_nodes, resp, body)
35 return service_client.ResponseBodyList(resp, body['nodes'])
36
37 def get_baremetal_node(self, baremetal_node_id):
38 """Returns the details of a single baremetal node."""
39 url = 'os-baremetal-nodes/%s' % baremetal_node_id
40 resp, body = self.get(url)
41 body = json.loads(body)
42 self.validate_response(schema.get_baremetal_node, resp, body)
43 return service_client.ResponseBody(resp, body['node'])